Skip to content

Add OpenShift router inspection commands and shared skills#274

Open
alebedev87 wants to merge 1 commit intoopenshift-eng:mainfrom
alebedev87:add-router-show-commands
Open

Add OpenShift router inspection commands and shared skills#274
alebedev87 wants to merge 1 commit intoopenshift-eng:mainfrom
alebedev87:add-router-show-commands

Conversation

@alebedev87
Copy link

@alebedev87 alebedev87 commented Jan 7, 2026

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

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:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.

Summary by CodeRabbit

New Features

  • Added three new OpenShift router inspection commands: router-show-config (display HAProxy configuration), router-show-info (display process information), and router-show-sessions (display active sessions) for cluster troubleshooting and diagnostics.
  • Added OpenShift CLI prerequisite checker and router pod helper utilities to support command execution.

Notes

  • Is this PR too domain specific (OpenShift router) to be in ai-helpers?

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>
@openshift-ci openshift-ci bot requested review from bentito and enxebre January 7, 2026 08:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

Walkthrough

Three 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

Cohort / File(s) Summary
Plugin Registry & Configuration
PLUGINS.md, docs/data.json
Registered three new OpenShift router commands (router-show-config, router-show-info, router-show-sessions) and two new skills (oc-prereqs, router-pod-helper) in plugin manifest and CLI data.
Router Command Implementations
plugins/openshift/commands/router-show-config.md, router-show-info.md, router-show-sessions.md
Added command documentation for querying HAProxy router configuration, process information, and active sessions from OpenShift router pods, each including prerequisites, implementation steps, and usage examples.
Support Skills
plugins/openshift/skills/oc-prereqs/SKILL.md, router-pod-helper/SKILL.md
Defined reusable skills for verifying OpenShift CLI prerequisites and discovering/validating router pods in openshift-ingress namespace.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective of the pull request: adding three new OpenShift router inspection commands and two shared skills to reduce code duplication.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
No Real People Names In Style References ✅ Passed No references to real people's names were found in plugin commands, skill documentation, example prompts, or style references across all files.
No Assumed Git Remote Names ✅ Passed The pull request does not contain any hardcoded git remote names like 'origin' or 'upstream' in the new files added.
Git Push Safety Rules ✅ Passed This pull request contains no git push operations, force push commands, or instructions to push to any branch.
No Untrusted Mcp Servers ✅ Passed The pull request introduces only documentation and command definitions for OpenShift router inspection utilities and shared skills. Shell search confirms none of the added files contain MCP server installations, npx commands, npm packages, or references to external untrusted sources.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 99f44d9 and 5802cc1.

📒 Files selected for processing (7)
  • PLUGINS.md
  • docs/data.json
  • plugins/openshift/commands/router-show-config.md
  • plugins/openshift/commands/router-show-info.md
  • plugins/openshift/commands/router-show-sessions.md
  • plugins/openshift/skills/oc-prereqs/SKILL.md
  • plugins/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.md file is in place with comprehensive documentation covering pod discovery, validation logic, prerequisites, error handling, and usage patterns. The skill correctly references the oc-prereqs skill 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 ($NAMESPACE and $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 .work directory (line 93). Please confirm:

  1. The HAProxy config path is correct for OpenShift router pods
  2. The .work directory pattern is an established project convention for temporary/working files
  3. The oc exec command with output redirection properly captures the file content without requiring tee or similar workarounds
plugins/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:

  1. The label selector is accurate for OpenShift 4.x default ingress controller routers
  2. The jsonpath syntax at lines 39 (pod names), 71 (pod phase) is compatible with the target oc CLI version
  3. 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.

@alebedev87
Copy link
Author

/hold

Considering another home for these tools...

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 8, 2026
@alebedev87
Copy link
Author

Something like this can be a better way of doing what this PR does: openshift/openshift-mcp-server#98.

@bentito
Copy link
Contributor

bentito commented Jan 12, 2026

/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.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 12, 2026
@openshift-ci
Copy link

openshift-ci bot commented Jan 12, 2026

[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

Details 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments