Skip to content

OLS-3565 Add oc agentic run cleanup CLI command - #413

Open
sriroopar wants to merge 2 commits into
openshift:mainfrom
sriroopar:ols-3566-cleanup-cli
Open

OLS-3565 Add oc agentic run cleanup CLI command#413
sriroopar wants to merge 2 commits into
openshift:mainfrom
sriroopar:ols-3566-cleanup-cli

Conversation

@sriroopar

Copy link
Copy Markdown

Summary

  • Add oc agentic run cleanup subcommand for batch deletion of terminal AgenticRun resources during maintenance windows
  • Supports filtering by terminal state (--state), age (--older-than), and namespace scope (-A)
  • Includes --dry-run mode to preview what would be deleted without acting
  • Depends on TTL CRD fields from OLS-3566 Add TTL lifecycle CRD fields and reconciler enforcement #412 (cherry-picked into this branch)

CLI Interface

oc agentic run cleanup [--older-than=7d] [--state=completed,failed] [--namespace=foo] [-A] [--dry-run]
Flag Description Default
--older-than Only runs terminal longer than this duration (supports Nd for days) "" (all terminal)
--state Comma-separated terminal states to include all terminal
--namespace / -A Namespace scope current namespace
--dry-run List matching runs without deleting false

Behavior

  • Lists all AgenticRun resources and filters client-side to terminal phases
  • Derives phase via DerivePhase() — consistent with existing CLI commands
  • --older-than uses status.terminalTime; runs without it are skipped with a warning
  • Deletion errors are reported per-run but do not halt the batch
  • Follows existing CLI Options pattern (Complete/Validate/Run)

Files Changed

File Change
cli/run/cleanup.go New — cleanup command implementation
cli/run/cleanup_test.go New — 10 unit tests covering all acceptance criteria
cli/run/run.go Edit — register cleanup subcommand

Test plan

  • make test passes (all existing + 10 new cleanup tests)
  • make vet passes
  • go build ./cmd/oc-agentic/ compiles
  • Verify oc agentic run cleanup deletes all terminal runs
  • Verify --state filters by terminal state
  • Verify --older-than filters by status.terminalTime
  • Verify --dry-run lists without deleting
  • Verify -A scopes to all namespaces
  • Verify runs without terminalTime are skipped with warning when --older-than used

Depends on: #412

🤖 Generated with Claude Code

sriroopar and others added 2 commits August 4, 2026 00:27
Cherry-pick from ols-3566-ttl-lifecycle branch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add batch deletion of terminal AgenticRun resources with filters:
- --state: comma-separated terminal states (completed,failed,denied,etc)
- --older-than: duration filter using status.terminalTime (supports Nd)
- --dry-run: list matching runs without deleting
- -A: all namespaces scope

Deletion errors are reported per-run but do not halt the batch.
Runs without status.terminalTime are skipped with a warning
when --older-than is used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sriroopar, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e32d3756-80b4-451f-a12d-ee9c004d365d

📥 Commits

Reviewing files that changed from the base of the PR and between 5d52adf and bd6bbd0.

⛔ Files ignored due to path filters (2)
  • config/crd/bases/agentic.openshift.io_agenticolsconfigs.yaml is excluded by !config/crd/bases/**
  • config/crd/bases/agentic.openshift.io_agenticruns.yaml is excluded by !config/crd/bases/**
📒 Files selected for processing (8)
  • api/v1alpha1/agenticolsconfig_types.go
  • api/v1alpha1/agenticrun_types.go
  • cli/run/cleanup.go
  • cli/run/cleanup_test.go
  • cli/run/run.go
  • controller/agenticrun/helpers.go
  • controller/agenticrun/reconciler.go
  • controller/agenticrun/ttl_test.go

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.

@openshift-ci
openshift-ci Bot requested review from harche and raptorsun August 4, 2026 04:31
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign blublinsky for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown

@sriroopar: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@sriroopar sriroopar changed the title OLS-3566 Add oc agentic run cleanup CLI command OLS-3565 Add oc agentic run cleanup CLI command Aug 4, 2026
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.

1 participant