Skip to content

feat(cleanup): clean failed gitjobs after a retention period - #5447

Open
susesamu wants to merge 2 commits into
rancher:mainfrom
susesamu:5440-retention-period
Open

feat(cleanup): clean failed gitjobs after a retention period#5447
susesamu wants to merge 2 commits into
rancher:mainfrom
susesamu:5440-retention-period

Conversation

@susesamu

Copy link
Copy Markdown
Contributor

Refers to #5440

Copilot AI review requested due to automatic review settings July 15, 2026 14:08
@susesamu
susesamu requested a review from a team as a code owner July 15, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional retention period to the Fleet cleanup CLI so failed GitRepo Jobs (and their Pods via background propagation) can be automatically deleted once they’re older than a configured threshold, while preserving the current default behavior (failed jobs kept indefinitely).

Changes:

  • Extend cleanup gitjob to accept a --retention duration for failed jobs and pass it through to cleanup logic.
  • Update job cleanup logic to delete failed GitRepo-owned Jobs only when retention > 0 and the job’s CompletionTime is older than the threshold.
  • Add integration test coverage for retention behavior (delete old failed jobs, keep recent failed jobs, and preserve default behavior when retention is unset/zero).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/cmd/cli/cleanup/cleanup.go Adds retention-aware deletion rules for failed GitRepo Jobs while keeping immediate deletion for succeeded Jobs.
internal/cmd/cli/cleanup.go Introduces --retention CLI flag, parses the duration, and wires it into the cleanup execution path.
integrationtests/cli/cleanup/cleanup_jobs_test.go Adds integration tests validating retention-based cleanup semantics for failed jobs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +168 to +171
retention, err = time.ParseDuration(r.Retention)
if err != nil {
return fmt.Errorf("invalid retention duration: %w", err)
}
susesamu added 2 commits July 15, 2026 12:25
Signed-off-by: Samuel Vasconcelos <samuel.vasconcelos@suse.com>
Signed-off-by: Samuel Vasconcelos <samuel.vasconcelos@suse.com>
@susesamu
susesamu force-pushed the 5440-retention-period branch from b701561 to 64714e3 Compare July 15, 2026 15:25
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.

2 participants