Skip to content

fix: preserve backup_dir on finalizer path for clean_backup_on_delete - #363

Merged
jamesmarshall24 merged 1 commit into
mainfrom
AAP-87836
Aug 27, 2026
Merged

jamesmarshall24 merged 1 commit into
mainfrom
AAP-87836

Conversation

@jamesmarshall24

@jamesmarshall24 jamesmarshall24 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The postgres_skip_data refactor (#353) moved backup_dir/timestamp
setup into init.yml, which finalizer.yml also runs on CR deletion.
set_fact overwrote the block-scoped backup_dir passed in from CR
status, so delete_backup.yml deleted a freshly created empty
directory instead of the real backup, silently breaking
clean_backup_on_delete.

Guards the three affected tasks with when: not finalizer_run | bool,
matching the existing finalizer_run branching in main.yml.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented backup initialization and backup-directory creation during finalizer execution.
    • Ensured backup timestamps and directory naming are handled only during regular runs.

Same regression as automationcontroller-operator: postgres_skip_data
moved backup_dir/timestamp setup into init.yml, which finalizer.yml
also runs on CR deletion. set_fact overwrote the block-scoped
backup_dir from CR status, so the wrong (empty) directory got deleted
instead of the real backup.

Guard the three init.yml tasks with `when: not finalizer_run | bool`,
consistent with main.yml's existing finalizer_run branching.

Assisted by: Claude

Signed-off-by: James Marshall <jamarsha@redhat.com>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cf762359-7cb2-4f39-8400-794643fdc2e8

📥 Commits

Reviewing files that changed from the base of the PR and between 72fd559 and f05f146.

📒 Files selected for processing (1)
  • roles/backup/tasks/init.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Backup initialization

Layer / File(s) Summary
Guard backup setup during finalizer execution
roles/backup/tasks/init.yml
Backup timestamp initialization, backup directory naming, and management-pod directory creation now run only when finalizer_run is false.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to f05f1

The change preserves the backup directory during finalizer cleanup, preventing deletion of a newly created empty directory instead of the real backup. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes preserving backup_dir during the finalizer path to support clean_backup_on_delete. This matches the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch AAP-87836

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@ptoscano

Copy link
Copy Markdown
Contributor

Guards the three affected tasks with when: not finalizer_run | bool, matching the existing finalizer_run branching in main.yml.

Nitpick: maybe moved these 3 tasks in an own block guarded by the newly added condition? This way the condition is not repeated, and the tasks belonging to backups are logically grouped.

@rooftopcellist rooftopcellist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same regression and same fix as ansible/awx-operator#2135 — verified the call graph here matches (finalizer.yml sets a block-scoped backup_dir from CR status, init.yml's unconditional set_fact was overwriting it). Guard looks correct. LGTM.

@jamesmarshall24
jamesmarshall24 merged commit cd0d211 into main Aug 27, 2026
8 checks passed
@jamesmarshall24
jamesmarshall24 deleted the AAP-87836 branch August 27, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants