ROX-35081: Add instance report admin command - #2764
Conversation
Add `fleet-manager admin central report` command that fetches all centrals from the fleet-manager API and generates a summary report. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kovayur The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Warning Review limit reached
Next review available in: 58 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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change adds the admin command to ChangesAdmin central reporting
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AdminCLI
participant AdminCommand
participant FleetManagerClient
participant FleetManagerAPI
participant ReportWriter
AdminCLI->>AdminCommand: Execute central report
AdminCommand->>FleetManagerClient: Create and retrieve authenticated client
AdminCommand->>FleetManagerAPI: Fetch paginated central instances
FleetManagerAPI-->>AdminCommand: Return central records
AdminCommand->>ReportWriter: Filter, group, and format records
ReportWriter-->>AdminCLI: Write Slack-compatible report
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/central/pkg/api/admin/private/model_central.go`:
- Around line 28-47: Keep the organisation_name field defined in the canonical
OpenAPI specification rather than editing model_central.go directly, then run
make generate and commit the regenerated output. Ensure the generated Central
model retains the organisation_name JSON property.
In `@internal/central/pkg/cmd/admin/centrals/report.go`:
- Around line 94-150: Extend the report generation around the existing
allCentrals classification loop and writeSection calls to aggregate and print
counts by cloud provider, region, plan, and status for all relevant centrals,
rather than only the current recent-region, eval, expiration, and failed tables.
Reuse the central fields and established report formatting helpers, ensure probe
instances follow the existing exclusion behavior, and add tests covering each
aggregate’s counts before release.
- Around line 52-70: Update the pagination loop around api.GetCentrals to return
an error when list.Items is empty while the fetched count is still below
list.Total, preventing further page requests. Compare the counts using a
non-narrowing type instead of converting len(all) to int32, while preserving the
existing completion condition and error context.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0ae94c87-d189-44ae-9fb3-a4e6b55eda72
📒 Files selected for processing (12)
cmd/acsfleetctl/main.gocmd/fleet-manager/main.gointernal/central/pkg/api/admin/private/api/openapi.yamlinternal/central/pkg/api/admin/private/model_central.gointernal/central/pkg/cmd/admin/centrals/cmd.gointernal/central/pkg/cmd/admin/centrals/list.gointernal/central/pkg/cmd/admin/centrals/report.gointernal/central/pkg/cmd/admin/centrals/report_test.gointernal/central/pkg/cmd/admin/cmd.gointernal/central/pkg/cmd/fleetmanagerclient/client.gointernal/central/pkg/presenters/admin_central.goopenapi/fleet-manager-private-admin.yaml
💤 Files with no reviewable changes (1)
- cmd/acsfleetctl/main.go
The pagination loop in fetchAllCentrals only terminated when the accumulated count reached list.Total, which could spin forever if the API returned an empty Items slice. Break early on empty pages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@coderabbitai review |
|
Summary
fleet-manager admin central reportcommand that fetches all centrals via the fleet-manager admin API and generates a summary report (instance counts by cloud provider, region, plan, and status)adminsubcommand fromacsfleetctltofleet-managerso the report can be run from the fleet-manager container imagemain()to use a properrootCommand()function and clean exit codes instead ofglog.Fatalffleetmanagerclientto use functional options and support RHSSO authexpired_atfield to the admin Central model and OpenAPI specPR split
This is part 1 of 2 for ROX-35081. This PR contains the binary/Go changes (the report command, client refactoring, and OpenAPI updates). Next part #2752 adds the Tekton pipeline that runs this command on a schedule and posts results to Slack.
Test plan
report_test.go)make lintpassesmake testpassesfleet-manager admin central report --helpshows usage🤖 Generated with Claude Code