Skip to content

Conversation

@chiragkyal
Copy link
Contributor

@chiragkyal chiragkyal commented Nov 19, 2025

What this PR does / why we need it:

This PR updated the must-gather command to dynamically discover script locations using find and absolute paths.

Which issue(s) this PR fixes:

/must-gather:analyze and /must-gather:ovn-dbs failed when run outside the ai-helpers repo directory because they used relative paths to find analysis scripts.

Summary by CodeRabbit

Documentation

  • Updated guidance on locating and using must-gather analysis scripts with dynamic path discovery instead of static file paths
  • Added clarification on plugin root locations and script availability
  • Improved error handling with user-friendly messages when scripts cannot be located

@openshift-ci openshift-ci bot requested review from bryan-cox and mrunalp November 19, 2025 12:35
@openshift-ci
Copy link

openshift-ci bot commented Nov 19, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Walkthrough

Two documentation files are updated to replace hardcoded script paths with dynamic discovery mechanisms. A new preliminary step is introduced to locate analysis scripts by searching the directory structure, with fallback error messaging. Subsequent steps use discovered path variables instead of static paths.

Changes

Cohort / File(s) Summary
Documentation Updates
plugins/must-gather/commands/analyze.md, plugins/must-gather/commands/ovn-dbs.md
Refactor documentation to implement dynamic script discovery instead of hardcoded paths. Introduce new "Locate Analysis Script" step that searches for scripts and sets SCRIPTS_DIR variable. Renumber subsequent implementation steps. Add clarification on <plugin-root> semantics and error handling for missing scripts. Update command examples to reference discovered paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Both files follow a consistent and straightforward documentation pattern
  • Changes are primarily structural (step reordering) and path variable substitution
  • No code logic or API modifications present
  • Verify accuracy of the described script discovery process and path variable usage

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
No Real People Names In Style References ❓ Inconclusive Documentation changes appear limited to technical procedural content for must-gather script discovery with no evident style references or real person names. Provide direct access to modified files or confirm documentation contains only technical content with no style references or real person names.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: updating must-gather documentation to implement dynamic script directory discovery instead of fixed paths.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
No Assumed Git Remote Names ✅ Passed No assumed git remote names like 'origin' or 'upstream' found in modified documentation files.
Git Push Safety Rules ✅ Passed The pull request contains only documentation updates to markdown files that improve script discovery mechanisms for must-gather plugins with no git push operations.
No Untrusted Mcp Servers ✅ Passed PR contains only documentation updates to markdown files with bash commands for script discovery; no MCP server installations or npm packages are introduced.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@chiragkyal
Copy link
Contributor Author

/cc @swghosh

@openshift-ci
Copy link

openshift-ci bot commented Nov 19, 2025

@chiragkyal: GitHub didn't allow me to request PR reviews from the following users: swghosh.

Note that only openshift-eng members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @swghosh

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.

Copy link
Contributor

@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: 2

🧹 Nitpick comments (1)
plugins/must-gather/commands/ovn-dbs.md (1)

75-97: Verify that SCRIPTS_DIR is used consistently in subsequent steps.

The step numbering is correct after adding the preliminary discovery step. However, the documentation for steps 2–5 describes what to do but doesn't explicitly show the command invocation using $SCRIPTS_DIR/analyze_ovn_dbs.py. While the steps appear logically sound, consider adding a brief note showing how SCRIPTS_DIR is used when executing the script in step 4 for clarity.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between b008a09 and 7a24c89.

📒 Files selected for processing (2)
  • plugins/must-gather/commands/analyze.md (4 hunks)
  • plugins/must-gather/commands/ovn-dbs.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
plugins/must-gather/commands/analyze.md

50-50: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


148-148: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (6)
plugins/must-gather/commands/ovn-dbs.md (2)

49-56: Clear explanation of plugin root and automatic discovery.

The updated documentation effectively clarifies where scripts are located and that automatic discovery is independent of the working directory. This is helpful for end-users.


62-73: Review comment is incorrect; the code block already has the bash language identifier.

The actual file content shows the fenced code block at lines 62-73 already includes the bash language specification (\``bash`). The review claim that "the bash script block is missing a language identifier" is contradicted by the file itself. The provided diff makes no meaningful changes—it only adjusts whitespace while the language identifier remains present.

The secondary note about find command performance (searching from home directory) is a reasonable observation but is not a critical or mandatory fix.

Likely an incorrect or invalid review comment.

plugins/must-gather/commands/analyze.md (4)

49-63: Clear and consistent documentation of plugin installation location.

The explanation of <plugin-root> and typical installation path aligns well with the similar update in ovn-dbs.md and provides helpful context for users.


139-151: Execution approach is clear and demonstrates correct SCRIPTS_DIR usage.

The new "Locate Plugin Scripts" step and updated "Execute Analysis Scripts" section properly show how to use the dynamically discovered $SCRIPTS_DIR variable. The example at lines 150–151 effectively demonstrates the pattern.


49-99: Overall assessment: Dynamic script discovery is well-structured and documented.

The changes successfully introduce a robust script discovery mechanism to replace hardcoded paths. The bash patterns are consistent across both files, error handling is in place, and the documentation clearly explains the <plugin-root> concept. The main action items are addressing the markdown linting issues (missing language specifications) and verifying the directory structure assumption.


62-93: Path patterns are correct; no changes needed.

The verification confirms that the find command patterns in the documentation correctly match the actual installation structure. All analysis scripts are present at plugins/must-gather/skills/must-gather-analyzer/scripts/ as expected by the documented patterns.

Comment on lines +81 to +93
1. Locate the scripts directory by searching for a known script:
```bash
SCRIPT_PATH=$(find ~ -name "analyze_clusteroperators.py" -path "*/must-gather/skills/must-gather-analyzer/scripts/*" 2>/dev/null | head -1)

if [ -z "$SCRIPT_PATH" ]; then
echo "ERROR: Must-gather analysis scripts not found."
echo "Please ensure the must-gather plugin from ai-helpers is properly installed."
exit 1
fi

# All scripts are in the same directory, so just get the directory
SCRIPTS_DIR=$(dirname "$SCRIPT_PATH")
```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add bash language specification to fenced code block.

The script discovery block is missing a language identifier on the opening fence. This should match the approach in ovn-dbs.md for consistency.

Apply this diff:

  1. Locate the scripts directory by searching for a known script:
-    ```
+    ```bash
     SCRIPT_PATH=$(find ~ -name "analyze_clusteroperators.py" -path "*/must-gather/skills/must-gather-analyzer/scripts/*" 2>/dev/null | head -1)
     
     if [ -z "$SCRIPT_PATH" ]; then
         echo "ERROR: Must-gather analysis scripts not found."
         echo "Please ensure the must-gather plugin from ai-helpers is properly installed."
         exit 1
     fi
     
     # All scripts are in the same directory, so just get the directory
     SCRIPTS_DIR=$(dirname "$SCRIPT_PATH")
     ```
🤖 Prompt for AI Agents
plugins/must-gather/commands/analyze.md around lines 81 to 93: the fenced code
block containing the script discovery snippet is missing the language
identifier; update the opening fence to use "```bash" (matching ovn-dbs.md) so
the block begins with ```bash and leave the rest unchanged.

Comment on lines +145 to 151
python3 "$SCRIPTS_DIR/<script>.py" <must-gather-path>
```

Example:
```bash
python3 plugins/must-gather/skills/must-gather-analyzer/scripts/<script>.py <must-gather-path>
python3 "$SCRIPTS_DIR/analyze_clusteroperators.py" ./must-gather.local.123/quay-io-...
```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add bash language specification to example code block.

The execution example is missing a language identifier, consistent with the issue at lines 81–93.

Apply this diff:

  3. **Locate Plugin Scripts**:
     - Use the script availability check from the Error Handling section to find the plugin root
     - Store the scripts directory path in `$SCRIPTS_DIR`
  
  4. **Execute Analysis Scripts**:
-    ```
+    ```bash
     python3 "$SCRIPTS_DIR/<script>.py" <must-gather-path>
     ```
     
     Example:
     ```bash
     python3 "$SCRIPTS_DIR/analyze_clusteroperators.py" ./must-gather.local.123/quay-io-...
     ```
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

148-148: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In plugins/must-gather/commands/analyze.md around lines 145 to 151, the fenced
code blocks for the execution example lack a language identifier; update the
opening fences to use "```bash" for the execution snippet and the Example
snippet (i.e., change the opening "```" to "```bash" for both blocks) and leave
the contained commands unchanged.

@swghosh
Copy link

swghosh commented Nov 19, 2025

/cc @Prashanth684
we encountered this bug today which is intended to be fixed with this,

⏺ Bash(ls plugins/must-gather/skills/must-gather-analyzer/scripts/analyze_clusteroperators.py)
  ⎿  Error: Exit code 1
     ls: plugins/must-gather/skills/must-gather-analyzer/scripts/analyze_clusteroperators.py: No such file or directory

⏺ The must-gather analysis scripts are not available at the expected path. According to the command instructions, I should stop and inform the user
  about this issue. Let me update my todo list and provide the appropriate response.

@openshift-ci openshift-ci bot requested a review from Prashanth684 November 19, 2025 12:54
@Prashanth684
Copy link
Contributor

/cc @Prashanth684 we encountered this bug today which is intended to be fixed with this,

⏺ Bash(ls plugins/must-gather/skills/must-gather-analyzer/scripts/analyze_clusteroperators.py)
  ⎿  Error: Exit code 1
     ls: plugins/must-gather/skills/must-gather-analyzer/scripts/analyze_clusteroperators.py: No such file or directory

⏺ The must-gather analysis scripts are not available at the expected path. According to the command instructions, I should stop and inform the user
  about this issue. Let me update my todo list and provide the appropriate response.

is this with the plugin locally installed or from the marketplace?

```
1. Locate the scripts directory by searching for a known script:
```bash
SCRIPT_PATH=$(find ~ -name "analyze_clusteroperators.py" -path "*/must-gather/skills/must-gather-analyzer/scripts/*" 2>/dev/null | head -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a better way to do this that just grep for a script with the same name? i thought for a local plugin you could specify the github repo in your filesystem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel this approach is more robust since it doesn't depend on from which directory we are starting the Claude CLI. I am open to suggestions as well!

@chiragkyal
Copy link
Contributor Author

/cc @Prashanth684 we encountered this bug today which is intended to be fixed with this,

⏺ Bash(ls plugins/must-gather/skills/must-gather-analyzer/scripts/analyze_clusteroperators.py)
  ⎿  Error: Exit code 1
     ls: plugins/must-gather/skills/must-gather-analyzer/scripts/analyze_clusteroperators.py: No such file or directory

⏺ The must-gather analysis scripts are not available at the expected path. According to the command instructions, I should stop and inform the user
  about this issue. Let me update my todo list and provide the appropriate response.

is this with the plugin locally installed or from the marketplace?

I have faced this issue in both the cases, while installing locally or from the Marketplace as a git repo

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.

3 participants