-
Notifications
You must be signed in to change notification settings - Fork 11
Add must-gather command for diagnostic collection #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@CodeRabbit hi |
|
Tip For best results, initiate chat on the files or code changes.
How can I help you with PR |
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughAdds a new top-level Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI as "oadp CLI"
participant Validator as "Local Validator"
participant Oc as "oc adm must-gather"
User->>CLI: oadp must-gather --dest-dir ... --request-timeout ... [--skip-tls]
CLI->>CLI: Complete (resolve image, normalize dest)
CLI->>Validator: Validate (oc available, dest absolute)
Validator-->>CLI: ok / error
alt valid
CLI->>Oc: Execute built must-gather command (image, timeout, tls, gather-script)
Oc-->>CLI: Stream stdout/stderr
CLI-->>User: Display streamed output and exit status
else invalid
CLI-->>User: Return formatted validation error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
|
Note Docstrings generation - SUCCESS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@cmd/must-gather/must_gather.go`:
- Around line 128-140: The exec.ErrNotFound comparison in
MustGatherOptions.formatError is too strict and will miss wrapped errors; update
formatError to use errors.Is(err, exec.ErrNotFound) when checking for a missing
'oc' binary (and import "errors" if not present) so wrapped *exec.Error or
*os.PathError cases are handled; keep the existing exec.ExitError handling
(exitErr.ExitCode()) and the fallback fmt.Errorf("must-gather failed: %w", err).
🧹 Nitpick comments (2)
cmd/must-gather/must_gather.go (1)
55-61: Hardcoded image version may require maintenance.The default image
registry.redhat.io/oadp/oadp-mustgather-rhel9:v1.5is pinned to a specific version. As noted in the TODO comment, consider implementing version detection in the future to automatically select the appropriate image based on the installed OADP version.For now, this approach is acceptable for the initial implementation.
cmd/must-gather/must_gather_test.go (1)
27-39: Consider consolidating tests to reduce binary rebuild overhead.Each test function calls
testutil.BuildCLIBinary(t), which rebuilds the entire CLI binary. For faster test execution, consider consolidating these into a single test with subtests that share the built binary.♻️ Example consolidation pattern
func TestMustGatherHelp(t *testing.T) { binaryPath := testutil.BuildCLIBinary(t) t.Run("basic help", func(t *testing.T) { expectContains := []string{ "Collect diagnostic information", "--dest-dir", "--request-timeout", "--skip-tls", "Examples:", } testutil.TestHelpCommand(t, binaryPath, []string{"must-gather", "--help"}, expectContains) }) t.Run("help flags", func(t *testing.T) { for _, flag := range []string{"--help", "-h"} { t.Run(flag, func(t *testing.T) { output, err := testutil.RunCommand(t, binaryPath, "must-gather", flag) // ... existing assertions }) } }) // ... other subtests }
Docstrings generation was requested by @Joeavaikath. * #115 (comment) The following files were modified: * `cmd/must-gather/must_gather.go` * `cmd/root.go`
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai can this be approved? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 6663 🏁 Script executed: Length of output: 1409
⏳ CI Checks Still RunningSeveral CI checks are still in progress:
The following checks have passed successfully:
📋 Review StatusThe PR currently has a review decision of REVIEW_REQUIRED. I can see that you've addressed the error handling issue I previously flagged with your latest commit "Fix error handling in must-gather command", which is great! 🔍 RecommendationBefore approval, I recommend:
Once all CI checks pass and a maintainer has reviewed the implementation, the PR should be ready for approval. Would you like me to check back once the CI checks complete? |
|
@coderabbitai approve-able now? |
🧩 Analysis chain🏁 Script executed: Length of output: 10278
✅ All GreenCI Status: All checks have passed successfully
Code Quality:
Status: The PR is not in draft and is ready for merge. The implementation looks solid. The only remaining comments were minor nitpicks (hardcoded image version with a TODO, and test optimization suggestion), neither of which are blockers for this initial implementation. Approving now! 🚀 ✅ Actions performedComments resolved. |
| // TODO: Future enhancement - detect version and map to image | ||
| // o.effectiveImage = o.getDefaultImage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai open issue to follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Create a GitHub issue for the TODO follow-up
gh issue create \
--repo migtools/oadp-cli \
--title "Implement version detection for must-gather image selection" \
--body "## Description
Currently, the must-gather command uses a hardcoded default image when the \`--image\` flag is not specified:
\`\`\`go
o.effectiveImage = \"registry.redhat.io/oadp/oadp-mustgather-rhel9:v1.5\"
\`\`\`
As noted in the TODO comment in \`cmd/must-gather/must_gather.go\`, a future enhancement should automatically detect the installed OADP version and map it to the appropriate must-gather image.
## Proposed Enhancement
- Detect the OADP operator version installed in the cluster
- Maintain a mapping of OADP versions to their corresponding must-gather images
- Automatically select the correct must-gather image based on the detected version
- Fall back to a reasonable default if version detection fails
## References
- PR: https://github.com/migtools/oadp-cli/pull/115
- Comment: https://github.com/migtools/oadp-cli/pull/115#discussion_r2788814569
- Requested by: `@kaovilai`" \
--assignee kaovilai
Length of output: 47
@kaovilai I've created issue #117 to track the enhancement for automatic OADP version detection and must-gather image mapping. The issue has been assigned to you and includes references back to this PR and comment.
mpryc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
1852e7a to
8770ccb
Compare
Adds a new must-gather subcommand to collect diagnostic information from OADP installations. Also updates Makefile references from kubectl oadp to oc oadp and adds /must-gather/ to .gitignore to exclude generated artifacts. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Joseph <jvaikath@redhat.com>
Use errors.Is() instead of direct comparison for exec.ErrNotFound to properly handle wrapped errors from exec.Command failures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Joseph <jvaikath@redhat.com>
8770ccb to
dec4652
Compare
Why the changes were made
Adds a new must-gather subcommand to collect diagnostic information from OADP installations. Also updates Makefile references from kubectl oadp to oc oadp and adds /must-gather/ to .gitignore to exclude generated artifacts.
How to test the changes made
Run
oc oadp must-gatherRun
oc oadp must-gather --helpto see the available options
Summary by CodeRabbit
New Features
Documentation
Tests
Chores