Add OpenShift router inspection commands and shared skills#274
Add OpenShift router inspection commands and shared skills#274alebedev87 wants to merge 1 commit intoopenshift-eng:mainfrom
Conversation
This commit adds three new commands to the OpenShift plugin for inspecting router configuration and runtime data from router pods: - /openshift:router-show-config - Display router configuration - /openshift:router-show-sessions - Display active sessions - /openshift:router-show-info - Display process information To eliminate code duplication, two shared skills were created: - oc-prereqs - Generic OpenShift CLI and cluster connectivity checks - router-pod-helper - Router-specific pod discovery and validation All three commands reference these skills for common prerequisites and pod discovery logic, making the implementation maintainable and reusable for future router-related commands. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
WalkthroughThree new OpenShift router inspection commands are introduced—router-show-config, router-show-info, and router-show-sessions—along with supporting skills for prerequisite checks and router pod discovery. Documentation and data structure entries register these additions. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as oc CLI
participant API as OpenShift API
participant Pod as Router Pod
participant HAProxy as HAProxy Socket
User->>CLI: Run /openshift:router-show-*
Note over CLI: Verify oc installed & cluster accessible
CLI->>API: Authenticate & query pods
API-->>CLI: Return router pod in openshift-ingress
CLI->>Pod: oc exec [pod-name]
Note over Pod: Execute socket query via socat
Pod->>HAProxy: Query socket<br/>(config/info/sessions)
HAProxy-->>Pod: Return HAProxy data
Pod-->>CLI: Return output
CLI->>CLI: Save to .work/openshift/router-*
CLI-->>User: Display data & file path
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @plugins/openshift/commands/router-show-config.md:
- Around line 10-12: The code block showing the command
"/openshift:router-show-config [router-pod-name]" is missing a Markdown language
specifier; update the fenced code block around that line to include a language
(e.g., add ```text before the block) so it becomes a labeled code block and
resolves the markdown lint error.
In @plugins/openshift/skills/router-pod-helper/SKILL.md:
- Around line 91-96: The markdown code block that starts with the line
containing echo "Available router pods:" and the oc get pods command lacks a
language specifier; update the opening fence to use a bash specifier (i.e.,
change the triple backticks before the echo line to ```bash) so the block
containing "echo \"Available router pods:\"" and the oc get pods -n $NAMESPACE
... lines is properly marked as bash.
🧹 Nitpick comments (4)
plugins/openshift/commands/router-show-info.md (2)
10-12: Fix markdown linting: specify language for synopsis code block.The synopsis code block should specify a language identifier to comply with markdown best practices and resolve the MD040 linting warning.
📝 Proposed fix
## Synopsis -``` +```text /openshift:router-show-info [router-pod-name]</details> --- `69-100`: **Consider standardizing the socat command syntax.** Two different syntaxes are shown for executing the socat command: - Line 81 uses: `/bin/sh -c 'socat ... <<<"show info"'` - Line 95 uses: `socat ... <<< "show info"` While both approaches should work, using consistent syntax throughout the documentation would improve clarity. The simpler form (line 95) is sufficient unless there's a specific reason to invoke `/bin/sh -c`. <details> <summary>♻️ Standardize to the simpler syntax</summary> ```diff # Execute "show info" command against the HAProxy socket # Using socat to communicate with the Unix socket -oc exec -n $NAMESPACE $ROUTER_POD -- /bin/sh -c 'socat stdio /var/lib/haproxy/run/haproxy.sock <<<"show info"' +oc exec -n $NAMESPACE $ROUTER_POD -- socat stdio /var/lib/haproxy/run/haproxy.sock <<< "show info"plugins/openshift/commands/router-show-sessions.md (2)
10-12: Fix markdown linting: specify language for synopsis code block.The synopsis code block should specify a language identifier to comply with markdown best practices and resolve the MD040 linting warning.
📝 Proposed fix
## Synopsis -``` +```text /openshift:router-show-sessions [router-pod-name]</details> --- `68-99`: **Consider standardizing the socat command syntax.** Similar to router-show-info.md, two different syntaxes are shown: - Line 80 uses: `/bin/sh -c 'socat ... <<<"show sess all"'` - Line 94 uses: `socat ... <<< "show sess all"` For consistency across all three router commands, consider using the same simplified syntax throughout all documentation. <details> <summary>♻️ Standardize to the simpler syntax</summary> ```diff # Execute "show sess all" command against the HAProxy socket # Using socat to communicate with the Unix socket -oc exec -n $NAMESPACE $ROUTER_POD -- /bin/sh -c 'socat stdio /var/lib/haproxy/run/haproxy.sock <<<"show sess all"' +oc exec -n $NAMESPACE $ROUTER_POD -- socat stdio /var/lib/haproxy/run/haproxy.sock <<< "show sess all"
📜 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
📒 Files selected for processing (7)
PLUGINS.mddocs/data.jsonplugins/openshift/commands/router-show-config.mdplugins/openshift/commands/router-show-info.mdplugins/openshift/commands/router-show-sessions.mdplugins/openshift/skills/oc-prereqs/SKILL.mdplugins/openshift/skills/router-pod-helper/SKILL.md
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
plugins/openshift/commands/router-show-config.md
10-10: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
plugins/openshift/commands/router-show-sessions.md
10-10: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
plugins/openshift/commands/router-show-info.md
10-10: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (10)
plugins/openshift/skills/oc-prereqs/SKILL.md (1)
1-136: LGTM! Well-structured and comprehensive skill documentation.This new skill provides a clear, reusable pattern for prerequisite checks in OpenShift commands. The bash examples are correct, the error handling is appropriate, and the documentation clearly explains when and how to use this skill. The separation of concerns (CLI check → connectivity check → optional context display) is logical and easy to follow.
docs/data.json (2)
708-725: LGTM! Command entries are consistent and well-structured.The three new router inspection commands follow a consistent pattern with optional pod name arguments and clear descriptions. The JSON structure is valid and aligns with the existing command format in the data.json file.
748-752: Router Pod Helper skill documentation exists and is properly documented.The
plugins/openshift/skills/router-pod-helper/SKILL.mdfile is in place with comprehensive documentation covering pod discovery, validation logic, prerequisites, error handling, and usage patterns. The skill correctly references theoc-prereqsskill and provides clear examples for consuming commands.PLUGINS.md (1)
247-249: LGTM! Plugin documentation entries are properly formatted.The three new router inspection commands are correctly documented with consistent formatting and descriptions that match the data.json entries. The placement in the OpenShift plugin section is appropriate.
plugins/openshift/commands/router-show-info.md (2)
48-67: Excellent use of shared skills for common prerequisites.The implementation correctly delegates to the oc-prereqs and router-pod-helper skills for reusable logic. This promotes consistency across the three router commands and reduces duplication. The documented variables (
$NAMESPACEand$ROUTER_POD) provide clear contracts between the skills and the command implementation.
163-166: The router-show-config command documentation exists at the expected location and follows the same structure as the other router commands. No issues found.plugins/openshift/commands/router-show-sessions.md (1)
1-152: Excellent documentation with good consistency across router commands.This command documentation follows the same well-structured pattern as router-show-info.md, including:
- Clear prerequisites and skill references
- Detailed implementation steps
- Comprehensive examples with realistic output
- Proper cross-referencing to related commands
The consistency across the three router inspection commands will make them easier to maintain and use.
plugins/openshift/commands/router-show-config.md (1)
68-103: Verify HAProxy config path and command accuracy.The implementation assumes the HAProxy config exists at
/var/lib/haproxy/conf/haproxy.config(line 79) and uses output redirection to save to the.workdirectory (line 93). Please confirm:
- The HAProxy config path is correct for OpenShift router pods
- The
.workdirectory pattern is an established project convention for temporary/working files- The
oc execcommand with output redirection properly captures the file content without requiringteeor similar workaroundsplugins/openshift/skills/router-pod-helper/SKILL.md (2)
23-79: Verify ingress controller label selector and jsonpath syntax.The skill uses the label selector
ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default(lines 38, 128) to discover router pods, and jsonpath queries for pod names and status. Please confirm:
- The label selector is accurate for OpenShift 4.x default ingress controller routers
- The jsonpath syntax at lines 39 (pod names), 71 (pod phase) is compatible with the target oc CLI version
- The silent error suppression at line 71 (
2>/dev/null) is appropriate, or if explicit error messages should be provided
1-198: Excellent skill structure and documentation.The Router Pod Helper skill is well-designed and comprehensive. It clearly codifies the reusable pod discovery and validation pattern, provides a complete example workflow, and includes helpful notes for non-default ingress controllers and HA deployments. The documented environment variable exports (
$NAMESPACE,$ROUTER_POD,$POD_STATUS) establish a clear contract for commands that depend on this skill. Error handling is explicit and actionable.
|
/hold Considering another home for these tools... |
|
Something like this can be a better way of doing what this PR does: openshift/openshift-mcp-server#98. |
|
/lgtm This looks well-aligned with the repo's intent and structure, particularly the use of shared skills to maintain consistency and reduce duplication. These new router commands effectively complement the existing openshift plugin toolset. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alebedev87, bentito 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 |
This commit adds three new commands to the OpenShift plugin for inspecting router configuration and runtime data from router pods:
/openshift:router-show-config- Display router configuration/openshift:router-show-sessions- Display active sessions/openshift:router-show-info- Display process informationTo eliminate code duplication, two shared skills were created:
oc-prereqs- Generic OpenShift CLI and cluster connectivity checksrouter-pod-helper- Router-specific pod discovery and validationAll three commands reference these skills for common prerequisites and pod discovery logic, making the implementation maintainable and reusable for future router-related commands.
🤖 Generated with Claude Code
What this PR does / why we need it:
It adds three new commands to the OpenShift plugin for inspecting router configuration and runtime data.
Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
Checklist:
Summary by CodeRabbit
New Features
router-show-config(display HAProxy configuration),router-show-info(display process information), androuter-show-sessions(display active sessions) for cluster troubleshooting and diagnostics.Notes
ai-helpers?