forked from containers/kubernetes-mcp-server
-
Notifications
You must be signed in to change notification settings - Fork 56
Add TNF two-node fencing diagnostics toolset #367
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
Open
dhensel-rh
wants to merge
4
commits into
openshift:main
Choose a base branch
from
dhensel-rh:OCPEDGE-2742shiftweek
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fda3ff4
Add TNF two-node fencing diagnostics toolset
dhensel-rh 0e1e2ef
Add TNF eval tasks and snapshot test
dhensel-rh b730040
Skip FAR/NHC checks on TNF clusters and port eval knobs
dhensel-rh 04d0dde
Regenerate TNF toolset snapshot to match updated description
dhensel-rh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| # TNF (Two-Node Fencing) Support | ||
|
|
||
| The `tnf` toolset extends the OpenShift MCP server with diagnostics for Two-Node Fencing clusters. These are 2-node bare metal OpenShift clusters that use pacemaker and STONITH for fencing to prevent split-brain scenarios. | ||
|
|
||
| ## Tools | ||
|
|
||
| ### tnf_check_fencing_config | ||
|
|
||
| Validates fencing configuration and readiness for a TNF cluster. Checks cluster topology (platform, node count, TNF profile), critical operator health (etcd, machine-api, baremetal), Machine/Node/BareMetalHost correlation, BMC addresses and credential secrets, FenceAgentsRemediation templates and active remediations, and NodeHealthCheck resources. Returns a diagnostic summary identifying configuration issues that could prevent fencing from functioning correctly. | ||
|
|
||
| **Arguments:** | ||
| - `namespace` (optional): Namespace containing BareMetalHost resources (default: searches all namespaces) | ||
|
|
||
| ### tnf_check_stonith_status | ||
|
|
||
| Creates a temporary privileged debug pod on a control-plane node to run `pcs` diagnostic commands. Returns pacemaker cluster state, STONITH device configuration, quorum status, and recent fencing history. The debug pod is automatically cleaned up after execution. | ||
|
|
||
| **Arguments:** | ||
| - `node` (optional): Name of the node to run diagnostics on (default: auto-detects the first control-plane node) | ||
| - `namespace` (optional): Namespace to create the temporary debug pod in (default: `default`) | ||
| - `timeout_seconds` (optional): Maximum time in seconds to wait for the diagnostic commands to complete (default: 120) | ||
|
|
||
| ## Prompt | ||
|
|
||
| ### tnf-troubleshoot | ||
|
|
||
| Runs a full TNF fencing diagnostic workflow that collects cluster topology, node health, critical operator status, BareMetalHost/BMC health, pacemaker/STONITH status, and remediation operator status into a single structured report. Guides the LLM through analysis using the domain knowledge resource to assess split-brain risk and recommend actions. | ||
|
|
||
| **Arguments:** | ||
| - `node` (optional): Preferred node to run STONITH diagnostics from | ||
|
|
||
| **Invoke in Claude Code:** | ||
| ```text | ||
| /mcp__kubernetes-mcp-server__tnf-troubleshoot | ||
| ``` | ||
|
|
||
| ## Resource | ||
|
|
||
| ### tnf://domain-knowledge/fencing | ||
|
|
||
| Static reference material covering: | ||
| - How two-node fencing works (corosync, pacemaker, STONITH) | ||
| - Two-node quorum rules and `wait_for_all` behavior | ||
| - Split-brain risk assessment matrix | ||
| - Common issues and recovery procedures (STONITH disabled, BMC unreachable, node won't rejoin, quorum lost, fence race) | ||
|
|
||
| ## Enable the TNF Toolset | ||
|
|
||
| ### Option 1: Command Line | ||
|
|
||
| ```bash | ||
| kubernetes-mcp-server --toolsets core,config,tnf | ||
| ``` | ||
|
|
||
| ### Option 2: Configuration File | ||
|
|
||
| ```toml | ||
| toolsets = ["core", "config", "tnf"] | ||
| ``` | ||
|
|
||
| ### Option 3: MCP Client Configuration | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "kubernetes": { | ||
| "command": "kubernetes-mcp-server", | ||
| "args": ["--toolsets", "core,config,tnf"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| TNF support requires: | ||
|
|
||
| 1. **Two-node bare metal OpenShift cluster** with pacemaker/STONITH fencing configured | ||
| 2. **BareMetalHost CRDs** installed (standard on bare metal clusters via the baremetal-operator) | ||
| 3. **Proper RBAC** for reading Nodes, BareMetalHosts, Secrets, and creating debug pods | ||
|
|
||
| ### Verify TNF Setup | ||
|
|
||
| ```bash | ||
| # Check for 2-node bare metal cluster | ||
| oc get nodes | ||
| oc get infrastructure cluster -o jsonpath='{.status.platform}' | ||
|
|
||
| # Check BareMetalHosts exist | ||
| oc get baremetalhosts -A | ||
|
|
||
| # Check pacemaker is running | ||
| oc debug node/<node-name> -- chroot /host pcs status | ||
| ``` | ||
|
|
||
| ## What It Diagnoses | ||
|
|
||
| | Area | What's Checked | | ||
| |------|---------------| | ||
| | Cluster topology | Platform, node count, TNF profile detection | | ||
| | Node health | Kubernetes Ready status, conditions | | ||
| | BareMetalHost | Provisioning state, power status, BMC address | | ||
| | BMC credentials | Secret existence, username/password keys present | | ||
| | Pacemaker | Cluster name, online/offline/standby nodes | | ||
| | STONITH devices | Configuration, agent type, target node, started status | | ||
| | Quorum | Quorate status, vote count, two-node flags | | ||
| | Fencing history | Recent fencing events, success/failure | | ||
| | Remediation operators | FenceAgentsRemediation and NodeHealthCheck CRD status | | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **API must be reachable**: All tools depend on the Kubernetes API. When the API is unreachable (e.g. during a fencing event that takes down the API server), the tools detect the failure and return an out-of-band recovery guide with BMC access and manual diagnostic procedures instead of raw cluster data. The `tnf-troubleshoot` prompt integrates this fallback automatically. | ||
| - **Read-only diagnostics**: The tools do not trigger, stop, or modify fencing operations. | ||
| - **Debug pod privileges**: The STONITH check requires creating a privileged debug pod with host access (same as `oc debug node/<name>`). | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| kind: Task | ||
| metadata: | ||
| labels: | ||
| suite: tnf | ||
| name: check-fencing-config | ||
| difficulty: easy | ||
| steps: | ||
| prompt: | ||
| inline: Check the fencing configuration for this Two-Node Fencing cluster. Verify that BareMetalHost resources exist, BMC credentials are valid, and the cluster topology matches a TNF profile. | ||
| verify: | ||
| contains: "BMC" | ||
| assertions: | ||
| toolsUsed: | ||
| - server: kubernetes | ||
| toolPattern: "tnf_check_fencing_config" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| kind: Task | ||
| metadata: | ||
| labels: | ||
| suite: tnf | ||
| name: check-stonith-status | ||
| difficulty: medium | ||
| steps: | ||
| prompt: | ||
| inline: Check the pacemaker and STONITH status on this cluster. Report which STONITH devices are configured, whether they are started, and the current quorum status. | ||
| verify: | ||
| contains: "STONITH" | ||
| assertions: | ||
| toolsUsed: | ||
| - server: kubernetes | ||
| toolPattern: "tnf_check_stonith_status" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| kind: Task | ||
| metadata: | ||
| labels: | ||
| suite: tnf | ||
| name: diagnose-fencing-health | ||
| difficulty: hard | ||
| steps: | ||
| prompt: | ||
| inline: Perform a full fencing health assessment for this Two-Node Fencing cluster. Check the fencing configuration, STONITH status, and analyze whether there is any split-brain risk. Provide a summary with an overall health status and any recommended actions. | ||
| verify: | ||
| contains: "fencing" | ||
| assertions: | ||
| toolsUsed: | ||
| - server: kubernetes | ||
| toolPattern: "tnf_.*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| [ | ||
| { | ||
| "annotations": { | ||
| "destructiveHint": false, | ||
| "idempotentHint": true, | ||
| "openWorldHint": false, | ||
| "readOnlyHint": true, | ||
| "title": "TNF: Check Fencing Config" | ||
| }, | ||
| "description": "Check fencing configuration and readiness for a Two-Node Fencing (TNF) cluster. Validates cluster topology, critical operator health (etcd, machine-api, baremetal), Machine/Node/BareMetalHost correlation, BMC addresses and credentials, pacemaker/STONITH fencing status via Kubernetes resources. Returns a diagnostic summary identifying configuration issues that could prevent fencing from functioning correctly.", | ||
| "inputSchema": { | ||
| "properties": { | ||
| "namespace": { | ||
| "description": "Namespace containing BareMetalHost resources (e.g. 'openshift-machine-api'). If omitted, searches all namespaces.", | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "type": "object" | ||
| }, | ||
| "name": "tnf_check_fencing_config", | ||
| "title": "TNF: Check Fencing Config" | ||
| }, | ||
| { | ||
| "annotations": { | ||
| "destructiveHint": false, | ||
| "idempotentHint": true, | ||
| "openWorldHint": false, | ||
| "readOnlyHint": true, | ||
| "title": "TNF: Check STONITH Status" | ||
| }, | ||
| "description": "Check STONITH and pacemaker fencing status on a Two-Node Fencing (TNF) cluster. Creates a temporary privileged debug pod on a control-plane node to run pcs diagnostic commands. Returns pacemaker cluster state, STONITH device configuration, quorum status, and recent fencing history. The debug pod is automatically cleaned up after execution.", | ||
| "inputSchema": { | ||
| "properties": { | ||
| "namespace": { | ||
| "description": "Namespace to create the temporary debug pod in (optional, defaults to 'default').", | ||
| "type": "string" | ||
| }, | ||
| "node": { | ||
| "description": "Name of the node to run diagnostics on. If omitted, auto-detects the first control-plane node.", | ||
| "type": "string" | ||
| }, | ||
| "timeout_seconds": { | ||
| "description": "Maximum time in seconds to wait for the diagnostic commands to complete (optional, defaults to 120).", | ||
| "minimum": 1, | ||
| "type": "integer" | ||
| } | ||
| }, | ||
| "type": "object" | ||
| }, | ||
| "name": "tnf_check_stonith_status", | ||
| "title": "TNF: Check STONITH Status" | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Rename this doc to lowercase.
docs/**/*.mdrequires lowercase filenames for new documentation, sodocs/TNF.mdshould bedocs/tnf.md. As per path instructions, docs/**/*.md: Use lowercase filenames for new documentation files (e.g., configuration.md, prompts.md).🤖 Prompt for AI Agents
Source: Path instructions