Skip to content

Conversation

@Joeavaikath
Copy link
Contributor

@Joeavaikath Joeavaikath commented Feb 9, 2026

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-gather

Run
oc oadp must-gather --help
to see the available options

Summary by CodeRabbit

  • New Features

    • Added a top-level must-gather command to collect diagnostics with destination, timeout, and TLS options; integrated into the CLI root.
  • Documentation

    • Updated install/verification guidance to use "oc oadp" instead of "kubectl oadp" in user-facing messages.
  • Tests

    • Added CLI help/example tests covering must-gather usage and flags.
  • Chores

    • Ignored must-gather artifacts by adding /must-gather/ to .gitignore.

@Joeavaikath Joeavaikath linked an issue Feb 9, 2026 that may be closed by this pull request
@kaovilai
Copy link
Member

kaovilai commented Feb 9, 2026

@CodeRabbit hi

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Tip

For best results, initiate chat on the files or code changes.

@kaovilai Hello! 👋

How can I help you with PR #115? I'm here to assist with code review, answer questions about the must-gather command implementation, or help with any other aspects of this pull request.

@kaovilai
Copy link
Member

kaovilai commented Feb 9, 2026

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@kaovilai
Copy link
Member

kaovilai commented Feb 9, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Adds a new top-level must-gather CLI command (implementation, flags, validation, execution), registers it in the root command, introduces tests for help/flags, and updates .gitignore and Makefile user-facing hints.

Changes

Cohort / File(s) Summary
Build & Make
\.gitignore, Makefile
Added /must-gather/ to .gitignore; updated printed guidance from kubectl oadp to oc oadp in Makefile messages.
Must-Gather Command
cmd/must-gather/must_gather.go
New MustGatherOptions type and full command implementation including BindFlags, Complete, Validate, Run; constructs and streams oc adm must-gather invocation supporting dest-dir, request-timeout, skip-tls, and image resolution.
Must-Gather Tests
cmd/must-gather/must_gather_test.go
New tests verifying help output, flags, examples, visible/hidden flag behavior, and usage strings for the must-gather command.
CLI Integration
cmd/root.go
Imported must-gather package and registered the new top-level subcommand; adjusted output-wrapping logic to exclude must-gather from velero->oadp replacements.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop and I gather, a tiny detective of logs,
I chase down the traces through clusters and fogs,
With dest and timeout and TLS set aside,
I bundle the clues in a comforting stride,
Hooray for must-gather — diagnostics supplied!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a must-gather command for diagnostic collection, which aligns with the primary purpose of this PR.
Description check ✅ Passed The description follows the template with both required sections completed: it explains why the changes were made and provides clear testing instructions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
cmd/must-gather/must_gather.go (1)

94-99: Default dest-dir bypasses validation.

When --dest-dir is not provided, the default ./must-gather is applied in Run() after Validate() has already completed. This means the default path isn't normalized to an absolute path like user-provided paths are.

Consider moving the default assignment to Complete() so it goes through validation:

♻️ Suggested refactor
 // Complete completes the options
 func (o *MustGatherOptions) Complete(args []string, f client.Factory) error {
+	// Set default dest-dir if not specified
+	if o.DestDir == "" {
+		o.DestDir = "./must-gather"
+	}
+
 	// Determine effective image to use

Then in Run():

-	// Add dest-dir if specified, otherwise use ./must-gather
-	if o.DestDir != "" {
-		args = append(args, "--dest-dir="+o.DestDir)
-	} else {
-		args = append(args, "--dest-dir=./must-gather")
-	}
+	args = append(args, "--dest-dir="+o.DestDir)

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #116

Copy link

@coderabbitai coderabbitai bot left a 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.5 is 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
}

coderabbitai bot added a commit that referenced this pull request Feb 9, 2026
Docstrings generation was requested by @Joeavaikath.

* #115 (comment)

The following files were modified:

* `cmd/must-gather/must_gather.go`
* `cmd/root.go`
@Joeavaikath
Copy link
Contributor Author

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@Joeavaikath
Copy link
Contributor Author

@coderabbitai can this be approved?

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Get PR details including status, reviews, and checks
echo "=== PR Details ==="
gh pr view 115 --json title,state,isDraft,reviewDecision,reviews,statusCheckRollup

echo -e "\n=== Files Changed ==="
gh pr view 115 --json files --jq '.files[] | "\(.path) (+\(.additions)/-\(.deletions))"'

echo -e "\n=== Review Comments ==="
gh pr view 115 --json reviewThreads --jq '.reviewThreads[] | select(.isResolved == false) | "Comment by \(.comments[0].author.login): \(.comments[0].body[0:200])"'

Length of output: 6663


🏁 Script executed:

#!/bin/bash

# Get more details about the specific review comments and their resolution status
echo "=== CodeRabbit Review Comments ==="
gh api /repos/migtools/oadp-cli/pulls/115/comments --jq '.[] | select(.user.login == "coderabbitai") | {path: .path, line: .line, body: .body[0:300], created_at: .created_at}' | head -50

echo -e "\n=== Check if there are any unresolved conversations ==="
gh pr view 115 --json comments --jq '.comments[] | select(.author.login == "coderabbitai") | .body[0:500]' | tail -20

echo -e "\n=== Latest commit info ==="
gh pr view 115 --json commits --jq '.commits[-1] | {sha: .oid, message: .messageHeadline, author: .authors[0].login}'

Length of output: 1409


@Joeavaikath I cannot approve this PR yet for the following reasons:

⏳ CI Checks Still Running

Several CI checks are still in progress:

  • Build All Architectures - IN_PROGRESS
  • Build Multi-Arch Images (amd64, arm64, ppc64le, s390x) - IN_PROGRESS

The following checks have passed successfully:

  • lint - SUCCESS
  • test - SUCCESS

📋 Review Status

The 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!

🔍 Recommendation

Before approval, I recommend:

  1. Wait for all CI checks to complete - The build checks need to finish successfully
  2. Consider getting a maintainer review - Since this PR introduces a significant new feature (the must-gather command), it would be beneficial to have a human maintainer review and approve the changes to ensure they align with the project's goals and standards

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?

@Joeavaikath
Copy link
Contributor Author

@coderabbitai approve-able now?

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Get current PR status including CI checks
echo "=== PR Details ==="
gh pr view 115 --json title,state,isDraft,reviewDecision,reviews,statusCheckRollup

echo -e "\n=== Files Changed Summary ==="
gh pr view 115 --json files --jq '.files | length as $count | "Total files changed: \($count)"'

echo -e "\n=== CI Status Summary ==="
gh pr view 115 --json statusCheckRollup --jq '
if .statusCheckRollup then
  .statusCheckRollup[] | 
  if .conclusion then
    "\(.name // .context): \(.conclusion)"
  else
    "\(.name // .context): \(.state // "UNKNOWN")"
  end
else
  "No status checks found"
end'

echo -e "\n=== Review Threads Status ==="
gh pr view 115 --json reviewThreads --jq '
if .reviewThreads then
  "Total review threads: \(.reviewThreads | length)",
  "Unresolved threads: \([.reviewThreads[] | select(.isResolved == false)] | length)"
else
  "No review threads found"
end'

echo -e "\n=== Latest Commits ==="
gh pr view 115 --json commits --jq '.commits[-2:] | .[] | "- \(.messageHeadline) (by \(.authors[0].login))"'

Length of output: 10278


@Joeavaikath Yes, the PR is ready for approval now! ✅

✅ All Green

CI Status: All checks have passed successfully

  • ✅ lint: SUCCESS
  • ✅ test: SUCCESS
  • ✅ Build All Architectures: SUCCESS
  • ✅ Multi-Arch Images (amd64, arm64, ppc64le, s390x): SUCCESS
  • ✅ Cross-platform tests (Linux, macOS, Windows): SUCCESS

Code Quality:

  • ✅ Your latest commit successfully addressed the error handling issue I flagged (using errors.Is() for wrapped errors)
  • ✅ All test files properly validate the must-gather command functionality

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 performed

Comments resolved.

Comment on lines +58 to +59
// TODO: Future enhancement - detect version and map to image
// o.effectiveImage = o.getDefaultImage()
Copy link
Member

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.

Copy link

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.

Copy link
Contributor

@mpryc mpryc left a comment

Choose a reason for hiding this comment

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

/lgtm

Joeavaikath and others added 2 commits February 10, 2026 12:12
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>
@Joeavaikath Joeavaikath merged commit 30297bd into migtools:oadp-dev Feb 10, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include must-gather in the oadp-cli

3 participants