RFE-5434: Add cluster ID and timestamp to must-gather directory name#2252
RFE-5434: Add cluster ID and timestamp to must-gather directory name#2252asadawar wants to merge 2 commits intoopenshift:mainfrom
Conversation
|
@asadawar: This pull request references RFE-5434 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature request to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 22 minutes and 28 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughDefault must-gather output directory naming changed: when unset, DestDir is now generated by a new generateDestDir() method that includes a UTC timestamp and, when available, a cluster-id suffix (last 12 chars of cluster ID); if unavailable, the suffix is omitted. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 8 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (8 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: asadawar The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @asadawar. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/cli/admin/mustgather/mustgather.go`:
- Around line 277-279: generateDestDir() currently calls
o.ConfigClient.ConfigV1().ClusterVersions().Get with context.TODO(), which can
block startup on slow/unreachable API servers; replace the context.TODO() with a
short timeout context (e.g., using context.WithTimeout) and defer cancel so the
lookup is bounded, then use that ctx when calling
ConfigV1().ClusterVersions().Get; target the call site referencing
o.ConfigClient, ConfigV1(), ClusterVersions().Get and ensure errors from context
deadline are handled the same as other lookup failures so the fallback path
still executes.
🪄 Autofix (Beta)
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: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: b20ea37c-8b72-4cbd-a950-65a1fbfb2bad
📒 Files selected for processing (2)
pkg/cli/admin/mustgather/mustgather.gopkg/cli/admin/mustgather/mustgather_test.go
1c1f293 to
7785cf8
Compare
|
Wouldn't it be nicer to use |
7785cf8 to
7396e5b
Compare
|
Good point, reordered to |
|
@asadawar: This pull request references RFE-5434 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature request to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
7396e5b to
67a47be
Compare
|
@asadawar: This pull request references RFE-5434 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature request to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
| // times. If the cluster ID cannot be retrieved (e.g. cluster is unreachable), it falls back | ||
| // to the timestamp and random ID only. | ||
| // See: https://issues.redhat.com/browse/RFE-5434 | ||
| func (o *MustGatherOptions) generateDestDir(ctx context.Context) string { |
There was a problem hiding this comment.
Honestly would be nicer to pass a clock.Clock interface so that the tests are deterministic. And then align the tests to check for exact names instead of just contains.
There was a problem hiding this comment.
Good suggestion, done. Added a clock.PassiveClock field to MustGatherOptions — that's a smaller interface from k8s.io/utils/clock that only requires Now() and Since(), which is all we need here (the full Clock interface includes timers that we don't use).
In production, it's initialized with clock.RealClock{} in NewMustGatherOptions(), so it calls the real time.Now(). In tests, I created a simple fakeClock struct that returns a fixed time (2026-04-14T12:00:00Z), which lets us assert exact prefixes like must-gather.local.76708af6b91c.20260414T120000Z. instead of regex patterns.
The random suffix from rand.Int63() is still non-deterministic, but that's fine — the important parts (cluster ID and timestamp) are now fully testable.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/cli/admin/mustgather/mustgather.go`:
- Around line 76-77: Update the example text in the must-gather help/usage block
(the comment containing "# Gather information..." and the example line "oc adm
must-gather") to explicitly show that the `<cluster-id-suffix>` is optional —
state that the default output directory is
`must-gather.local.<cluster-id-suffix>.<timestamp>.<rand>` but when a cluster ID
is unavailable the suffix is omitted producing
`must-gather.local.<timestamp>.<rand>`, and adjust the example line or add a
second example to demonstrate the fallback form without `<cluster-id-suffix>`.
🪄 Autofix (Beta)
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: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 8609b9a3-7893-43d3-83a6-26b82ef7ddbe
📒 Files selected for processing (2)
pkg/cli/admin/mustgather/mustgather.gopkg/cli/admin/mustgather/mustgather_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/cli/admin/mustgather/mustgather_test.go
Include the last 12 characters of the cluster ID and a UTC timestamp in the auto-generated must-gather destination directory name. This helps support engineers distinguish must-gather archives from different clusters and collection times, especially when customers upload multiple archives to the same support case. New format: must-gather.local.<rand>.<cluster-id-suffix>.<timestamp> Example: must-gather.local.5119224030749742202.76708af6b91c.20260413T141030Z If the cluster ID cannot be retrieved (e.g. cluster is unreachable), the directory name falls back to: must-gather.local.<rand>.<timestamp> See: https://issues.redhat.com/browse/RFE-5434
67a47be to
dda7aec
Compare
The example text now mentions both the format with cluster ID suffix and the fallback format without it, so users know what to expect when the cluster ID is unavailable.
Summary
New format:
must-gather.local.<rand>.<cluster-id-suffix>.<timestamp>Example:
must-gather.local.5119224030749742202.76708af6b91c.20260413T141030ZFallback (cluster unreachable):
must-gather.local.<rand>.<timestamp>Details
The change is in
Complete()withinpkg/cli/admin/mustgather/mustgather.go. A newgenerateDestDir()method:ClusterVersion"version" via the existingConfigClientto retrieveSpec.ClusterID20060102T150405Z) — theZsuffix avoids timezone ambiguitymust-gather.local.<rand>.<timestamp>ifClusterVersionis unreachableNo new CLI flags are introduced — the consensus in the RFE discussion was to change the default naming rather than adding an opt-in option.
Test plan
generateDestDir()covering: full cluster ID, short cluster ID, empty cluster ID, nil ConfigClientoc adm must-gatherproduces directory with cluster ID suffix and timestamp--dest-dirflag: custom directory name is still respected (no change in behavior)must-gather.local.<rand>.<timestamp>See: https://issues.redhat.com/browse/RFE-5434
Summary by CodeRabbit
New Features
Tests