← Back to Pull requests

Add TNF two-node fencing diagnostics toolset #367

Open
unknown opened this pull request with 604 lines diff across 7 files
View on GitHub
unknown unknown commented on Jun 29, 2026 18:07 UTC
Author

Summary

Extends the OpenShift MCP server with a new tnf toolset that brings two-node fencing (TNF) diagnostics into the MCP tool/prompt/resource model. TNF clusters rely on out-of-band STONITH fencing to prevent split-brain, but diagnosing fencing failures today requires manually cross-referencing Kubernetes node health, BMC credentials, hardware state, and RHEL HA fencing agent configuration — this toolset correlates all of those into conversational diagnostics that surface split-brain risks before they become outages.

Ref: OCPEDGE-2742

Scope


This toolset is diagnostic-only. It collects and reports cluster state — it does
not modify fencing configuration, trigger remediation, or alter any cluster resources.

The one caveat: tnf_check_stonith_status creates a temporary privileged debug pod
on a control-plane node to run pcs status. This follows the same pattern as
cluster-diagnostics/nodesdebug — it's a read mechanism, not a write operation
against fencing config. Cleanup is handled by the nodesdebug package's deferred
teardown; verify behavior on abnormal exit (process crash, client disconnect) if
cleanup guarantees are important for review.

Future work may add remediation actions (e.g., restarting a fencing agent, unfencing
a node), but those would be a separate toolset or an explicit opt-in — not added to
these diagnostic tools.

What's included

Tools

  • tnf_check_fencing_config — validates fencing configuration including BareMetalHost resources, BMC credentials, cluster operator health, machine/node/BMH correlation, FenceAgentsRemediation templates, and NodeHealthCheck config

  • tnf_check_stonith_status — creates a temporary privileged debug pod on a control-plane node (via nodesdebug) to run pcs diagnostic commands. Returns pacemaker cluster state, STONITH device configuration, quorum status, and fencing history. The debug pod is automatically cleaned up after execution.
  • Prompts

  • tnf-troubleshoot — comprehensive fencing troubleshooting guide that collects cluster topology, node health, operator status, BMH state, remediation config, and STONITH diagnostics. Includes API-down detection: when the cluster API is unreachable, returns an out-of-band recovery guide with BMC/IPMI procedures instead of failing.
  • Resources

  • tnf://domain-knowledge/fencing — static reference for two-node fencing domain knowledge: corosync/pacemaker quorum rules, split-brain risk assessment matrix, and common recovery procedures. Extracted from the prompt to keep responses focused while making domain knowledge available on demand.
  • Design notes

  • See Scope above for the diagnostic-only contract.

  • All operations are read-only. tnf_check_stonith_status creates a temporary debug pod (same pattern as cluster-diagnostics/nodesdebug), but does not modify user-visible cluster state.

  • BMC credentials are validated for presence but never included in output — passwords are not leaked to the LLM.

  • Gracefully degrades when optional CRDs (FenceAgentsRemediation, NodeHealthCheck) are not installed.

  • Test fakes use hand-built CoreV1Interface implementations (interface embedding) instead of k8s.io/client-go/kubernetes/fake, avoiding ~280 vendored files that would otherwise bloat the PR.
  • Test plan

  • go build ./... passes

  • go vet ./pkg/toolsets/tnf/... passes

  • go test ./pkg/toolsets/tnf/... passes (tnf + fencing packages)

  • go test ./pkg/toolsets/... passes (includes global resource URI uniqueness checks)

  • Tested against a live 2-node bare metal TNF cluster

  • Verified API-down detection against an unreachable cluster (SSH tunnel to disconnected environment)

  • Verified graceful degradation when FenceAgentsRemediation/NodeHealthCheck CRDs are absent

  • No vendor files added — find vendor -path '/kubernetes/fake' | wc -l returns 0
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Summary by CodeRabbit

    New Features
    Added TNF (Two-Node Fencing) diagnostics for fencing health and STONITH status, plus a full tnf-troubleshoot walkthrough prompt.
    Included TNF domain-knowledge content with step-by-step recovery guidance and structured Markdown output.

    Bug Fixes
    Enhanced behavior and messaging when the Kubernetes API is unreachable.
    Added stronger input validation and clearer reporting when expected cluster data isn’t available.

    Documentation
    Added a TNF toolset guide page covering tools, arguments, outputs, and prerequisites.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 604 lines (+453 / -151) across 7 files Reviewer: dhensel-rh Review duration: 151751m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.57) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 604 lines diff across 7 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.383
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #367"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57.1% (MEDIUM) · Higher = larger blast radius
    57.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.6% · Safe to merge
    31.6%