Inferensys

Prompt

Node Scheduling Failure Recovery Prompt

A practical prompt playbook for using a Node Scheduling Failure Recovery Prompt in production AI-assisted platform engineering workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, the ideal user, required context, and constraints for the Node Scheduling Failure Recovery Prompt.

This prompt is designed for platform engineers and SRE teams who need to diagnose and resolve pod scheduling failures in Kubernetes clusters. The core job-to-be-done is to take a pending pod's specification and the cluster's current node conditions, then propose a corrected set of scheduling rules—such as node affinity, tolerations, or topology spread constraints—that will allow the pod to be placed. It is not a general-purpose Kubernetes assistant; it is specifically scoped to failures caused by affinity/anti-affinity mismatches, taint/toleration conflicts, and topology constraint violations.

Use this prompt when you have a concrete scheduling failure event: a pod stuck in Pending status with a clear FailedScheduling event message, and you can provide both the pod manifest and a snapshot of relevant node labels and taints. The prompt requires structured input, including the pod's current scheduling directives and the target node pool's topology. Do not use this prompt for generic pod startup failures, image pull errors, crash loops, or resource exhaustion issues where the scheduler is not the root cause. It is also unsuitable for clusters with custom schedulers that use non-standard plugin logic.

Before invoking this prompt, ensure you have extracted the exact scheduling error from kubectl describe pod and have a sanitized view of node metadata. The output should be treated as a suggested configuration, not an auto-applied fix. Always validate the proposed scheduling rules against your cluster's admission controllers and policy engines (e.g., OPA/Gatekeeper) before applying. For production clusters, route the generated diff through a peer review or a GitOps pull request rather than applying it directly.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Node Scheduling Failure Recovery Prompt works, where it fails, and the operational preconditions required before wiring it into a production harness.

01

Good Fit: Constraint Solvability

Use when: The pending pod has a clear set of node selectors, affinities, taints, or topology constraints that can be satisfied by at least one node in the cluster. The prompt excels at reading the pod spec and node list to propose corrected rules when the current configuration is unsatisfiable. Guardrail: Always provide the full pod spec and a representative sample of node conditions—not just the error message—so the model can reason about alternatives.

02

Bad Fit: Resource Exhaustion

Avoid when: The scheduling failure is caused by genuine resource exhaustion—no nodes have sufficient CPU, memory, or GPU to run the pod regardless of constraint tuning. The prompt cannot create capacity. Guardrail: Pre-check cluster allocatable resources before invoking the recovery prompt. If total pending requests exceed cluster capacity, escalate to cluster autoscaling or capacity planning rather than retrying constraint rewrites.

03

Required Inputs

Required: The pending pod's full spec (affinity, tolerations, nodeSelector, topologySpreadConstraints), the scheduling error message from the event log, and a list of candidate nodes with their labels and taints. Guardrail: Without node conditions, the model cannot verify whether its proposed constraint changes are satisfiable. Build a pre-fetch step in the harness that runs kubectl describe nodes for the relevant node group before calling the prompt.

04

Operational Risk: Anti-Affinity Conflicts

Risk: The model proposes a scheduling rule that satisfies the immediate pod but violates anti-affinity rules with other workloads, creating a cascading placement problem. Guardrail: After generating corrected scheduling rules, run a dry-run simulation against the full workload set. Check that the proposed changes do not force existing pods into Pending state. Log any conflicts for human review before applying.

05

Operational Risk: Taint Misinterpretation

Risk: The model misreads a taint effect (e.g., treating NoExecute as NoSchedule) and proposes a toleration that does not actually permit scheduling. Guardrail: Validate every generated toleration against the target node's actual taint set. The harness must confirm that the toleration key, operator, value, and effect exactly match or exceed the taint before applying the change.

06

When to Skip the Prompt and Escalate

Avoid when: The scheduling failure involves custom scheduler plugins, dynamic admission controllers, or non-standard topology keys that the model has no context for. Guardrail: If the error message references an unknown plugin or the node conditions include custom extended resources without documentation, escalate to a human operator with the full audit log. Do not let the model guess at proprietary scheduling logic.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for diagnosing and correcting Kubernetes pod scheduling failures caused by affinity, taint, or topology constraints.

This prompt template is designed to be wired into an automated recovery harness. It receives a pending pod's specification and the current state of candidate nodes, then produces a corrected scheduling configuration. The output is structured JSON, making it suitable for direct consumption by a control loop or a human operator reviewing a suggested fix. The template uses square-bracket placeholders for all dynamic inputs, ensuring it can be adapted to different clusters and failure contexts without modification.

text
You are an expert Kubernetes scheduler debugger. Your task is to analyze a pod scheduling failure and propose a corrected pod specification or node configuration that will allow the pod to be scheduled.

## INPUT
- Pending Pod Specification (YAML):
[PENDING_POD_YAML]

- Candidate Node Conditions (JSON list of node names, taints, labels, and allocatable resources):
[NODE_CONDITIONS_JSON]

- Scheduler Error Message (plain text from `kubectl describe pod`):
[SCHEDULER_ERROR_MESSAGE]

## CONSTRAINTS
- Do not change the pod's container images, command, or core application logic.
- Prefer the least invasive fix: adjust pod scheduling directives before suggesting node-level changes.
- If a node-level change is the only option, explicitly flag it as a cluster-admin action.
- Ensure the proposed fix does not violate any explicit anti-affinity rules already in the pod spec.
- If the failure is due to a resource shortage (CPU, memory), suggest a specific, minimal reduction in requests that aligns with the node's allocatable capacity.

## OUTPUT_SCHEMA
Respond with a single JSON object conforming to this structure:
{
  "diagnosis": "A concise, one-sentence summary of the root cause.",
  "proposed_fix_type": "One of: 'pod_spec_patch', 'node_label_patch', 'node_taint_patch', 'resource_adjustment', 'human_escalation'.",
  "corrected_pod_spec_yaml": "The full, corrected pod YAML if fix_type is 'pod_spec_patch' or 'resource_adjustment'; otherwise, null.",
  "node_patch_commands": ["A list of kubectl patch or taint commands if fix_type is 'node_label_patch' or 'node_taint_patch'; otherwise, an empty list."],
  "explanation": "A step-by-step explanation of why the fix resolves the specific error, referencing the constraints that were violated.",
  "risk_assessment": "One of: 'low', 'medium', 'high'. 'high' if the fix could affect other workloads on the node."
}

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## RISK_LEVEL
[RISK_LEVEL]

To adapt this template, replace the placeholders with data from your cluster's API. The [PENDING_POD_YAML] should be the exact output of kubectl get pod <name> -o yaml. The [NODE_CONDITIONS_JSON] is a critical input; construct it by querying nodes with kubectl get nodes -o json and filtering for the fields relevant to scheduling: spec.taints, metadata.labels, and status.allocatable. The [FEW_SHOT_EXAMPLES] placeholder should be populated with 2-3 worked examples of common scheduling failures and their correct fixes to improve model accuracy. For high-risk environments, set [RISK_LEVEL] to high to instruct the model to prefer the human_escalation fix type when node taints must be altered. The next step is to integrate this prompt into a validation harness that checks the proposed YAML against the target cluster's API version schema before applying any changes.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Node Scheduling Failure Recovery Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how the harness should check input quality before incurring model cost.

PlaceholderPurposeExampleValidation Notes

[PENDING_POD_SPEC]

Full YAML or JSON spec of the pod that failed to schedule, including affinity, tolerations, and nodeSelector fields

apiVersion: v1 kind: Pod spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchLabels: app: web topologyKey: kubernetes.io/hostname

Parse check: must be valid YAML or JSON. Schema check: must contain spec.affinity, spec.tolerations, or spec.nodeSelector. Reject if empty or missing spec.

[NODE_CONDITIONS]

JSON array of node objects with their labels, taints, capacity, allocatable resources, and current conditions

[{"name":"node-1","labels":{"zone":"us-east-1a"},"taints":[{"key":"dedicated","effect":"NoSchedule"}],"conditions":[{"type":"MemoryPressure","status":"False"}]}]

Parse check: valid JSON array. Schema check: each node must have name, labels, taints, and conditions fields. Minimum 1 node required. Null allowed if cluster has no nodes.

[SCHEDULING_ERROR_MESSAGE]

Exact error message from the Kubernetes scheduler event or kubectl describe output

0/5 nodes are available: 3 node(s) had untolerated taint {dedicated: infra}, 2 node(s) didn't match pod anti-affinity rules.

Parse check: non-empty string. Content check: must contain node count and reason keywords (taint, affinity, selector, resources). Reject if generic timeout message without scheduling detail.

[TOPOLOGY_CONSTRAINTS]

Cluster topology metadata including zones, regions, and node grouping labels relevant to scheduling

{"zones":["us-east-1a","us-east-1b"],"topologyKeys":["topology.kubernetes.io/zone","kubernetes.io/hostname"]}

Parse check: valid JSON object. Schema check: must include zones or topologyKeys array. Null allowed if topology is not a factor in the failure.

[RESOURCE_REQUESTS]

The resource requests and limits from the pending pod's containers, extracted separately for clarity

{"containers":[{"name":"app","requests":{"cpu":"500m","memory":"1Gi"},"limits":{"cpu":"2","memory":"4Gi"}}]}

Parse check: valid JSON object. Schema check: must contain containers array with requests map. Reject if requests exceed cluster node capacity maximum.

[EXISTING_SCHEDULING_POLICIES]

Current PriorityClass, schedulerName, or custom scheduler configuration applied to the namespace or pod

{"schedulerName":"default-scheduler","priorityClassName":"high-priority","preemptionPolicy":"PreemptLowerPriority"}

Parse check: valid JSON object. Null allowed if using default scheduler with no custom policies. Schema check: schedulerName must match a known scheduler in the cluster.

[NAMESPACE_CONTEXT]

Namespace-level constraints including ResourceQuota, LimitRange, and NetworkPolicy that may block scheduling

{"namespace":"production","resourceQuotas":[{"hard":{"pods":"50"},"used":{"pods":"50"}}],"limitRanges":[{"max":{"cpu":"4"}}]}

Parse check: valid JSON object. Schema check: must include namespace name. Null allowed if no namespace-level constraints exist. Check for quota exhaustion before sending prompt.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Node Scheduling Failure Recovery Prompt into an operational debugging workflow with validation, retries, and escalation.

This prompt is designed to be called within an automated triage pipeline, not as a standalone chat interaction. The harness should trigger when a pod remains in a Pending state beyond a configurable threshold (e.g., 5 minutes) and the scheduling event reason matches known failure classes (Unschedulable, FailedScheduling). The input assembly step must collect the full pod spec (kubectl get pod <name> -o yaml), the node list with taints and conditions (kubectl get nodes -o json), and the specific scheduling error message from kubectl describe pod. This context is packed into the [POD_SPEC], [NODE_CONDITIONS], and [SCHEDULING_ERROR] placeholders before the prompt is rendered.

After the model returns a proposed correction, the harness must not apply it automatically. First, validate the output structure: confirm the corrected_scheduling_rules block contains valid nodeSelectorTerms, affinity, or tolerations fields. Second, run a satisfiability check by using a dry-run scheduler or a lightweight constraint solver that tests whether at least one existing node matches the proposed rules. If no node satisfies the corrected constraints, increment a retry counter and re-invoke the prompt with the unsatisfiability reason appended to the error context. Implement a hard retry budget of 3 attempts; after the budget is exhausted, escalate to a human operator via your incident management system with the full chain of attempts and the original pod state.

Model choice matters here. Use a model with strong structured-output capabilities and a context window large enough to hold multiple node definitions. For production, prefer a model that supports JSON mode or function calling so you can enforce the output schema at the API level rather than relying solely on prompt instructions. Log every invocation—input context, raw output, validation result, and retry count—to your observability platform. This trace is essential for debugging prompt drift, model refusals, or unexpected constraint suggestions. Never apply the corrected scheduling rules directly to a running cluster without human approval unless the pod is in a pre-production namespace and the change is limited to soft preferences (preferredDuringScheduling) rather than hard requirements.

IMPLEMENTATION TABLE

Expected Output Contract

Validate the structure and content of the model's recovery response before applying any suggested scheduling changes.

Field or ElementType or FormatRequiredValidation Rule

recovery_summary

String (1-3 sentences)

Must describe the root cause of the scheduling failure by referencing specific node conditions, taints, or affinity rules from the input.

corrected_pod_spec

Valid Kubernetes PodSpec YAML block

Must be parseable by a YAML validator. The spec must differ from the original only in scheduling-related fields (affinity, tolerations, nodeSelector, topologySpreadConstraints).

change_explanation

Array of objects

Each object must contain 'field_path' (string), 'original_value' (string), 'new_value' (string), and 'rationale' (string). The 'field_path' must be a valid JSONPath to the changed field.

constraint_satisfiability_check

Boolean

Must be true. A post-generation check must confirm that no node in the provided node list simultaneously satisfies conflicting hard anti-affinity rules in the corrected spec.

anti_affinity_conflict_flag

Boolean

Must be false. If true, the harness must reject the output and retry. A separate validation pass must check for conflicting podAntiAffinity terms.

suggested_node_name

String or null

If provided, the node name must exist in the input node list and must satisfy all taints, tolerations, and resource requests in the corrected spec. Null is acceptable if no single node is suggested.

warnings

Array of strings

If present, each string must describe a non-fatal scheduling risk (e.g., 'Node [NAME] has low available memory'). Must not contain generic or hallucinated node names.

PRACTICAL GUARDRAILS

Common Failure Modes

Node scheduling failures are rarely caused by a single bad line of YAML. They are often the result of conflicting constraints, misunderstood topology, or resource fragmentation. These cards cover the most common failure modes when using AI to recover from scheduling failures and how to guard against them.

01

Hallucinated Node Labels

Risk: The model invents node labels or topology keys that do not exist in the cluster, producing a corrected pod spec that still cannot schedule. Guardrail: Always provide the actual kubectl get nodes --show-labels output in the prompt context and validate any label referenced in the output against the live cluster before applying.

02

Anti-Affinity Deadlock

Risk: The model proposes podAntiAffinity rules that are so strict they prevent any pod from scheduling, or it fails to detect that the desired replica count exceeds the number of available topology domains. Guardrail: Include the number of available nodes per topology zone in the prompt. Validate that requiredDuringScheduling rules allow at least one feasible placement per replica.

03

Ignoring Taint-Toleration Mismatch

Risk: The model focuses on affinity rules but overlooks that the target nodes have taints without matching tolerations in the pod spec, or it proposes removing tolerations that are required for other workloads. Guardrail: Always include kubectl describe nodes output showing active taints. The harness must diff the original and proposed tolerations and flag any removal of existing tolerations for human review.

04

Resource Fragmentation Oversight

Risk: The model proposes a scheduling rule that is technically satisfiable but fails because no single node has enough contiguous CPU or memory to meet the pod's requests. The prompt corrects constraints without addressing the underlying resource shortage. Guardrail: Include kubectl describe nodes resource summaries. The harness should run a dry-run scheduler simulation or kubectl run --dry-run=server before returning the fix as complete.

05

Over-Correction to Broad Selectors

Risk: To resolve a scheduling failure, the model removes all node affinity rules or replaces specific selectors with a catch-all matchExpressions operator, causing the pod to land on inappropriate nodes and creating a worse operational problem. Guardrail: The prompt must instruct the model to preserve the original scheduling intent. The harness should diff the proposed spec and flag any removal of nodeAffinity or topologySpreadConstraints for explicit approval.

06

Stale Cluster State

Risk: The model operates on a snapshot of node conditions that is minutes old. Nodes may have become NotReady, cordoned, or had their labels changed between the time the error was captured and the fix is applied. Guardrail: The harness must re-fetch live node state immediately before applying any generated manifest. If the cluster state has changed, the prompt must be re-run with fresh context rather than applying a stale fix.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality and correctness of a Node Scheduling Failure Recovery Prompt before deploying it into a production harness. Each criterion targets a specific failure mode common to scheduling constraint reasoning.

CriterionPass StandardFailure SignalTest Method

Constraint Satisfiability

Proposed nodeSelector, affinity, or tolerations resolve the scheduling failure without introducing new conflicts.

Output suggests a node label that does not exist or a taint that no node tolerates.

Parse the proposed spec fragment and run kubectl --dry-run=server against the target cluster. Assert status is created or unchanged.

Anti-Affinity Conflict Avoidance

Corrected rules do not place pods from the same anti-affinity group on the same topology domain.

Output removes or weakens an anti-affinity rule that was required for high availability.

Simulate scheduling of the original and corrected specs with a scheduler simulator. Assert no two pods with conflicting anti-affinity land on the same node.

Taint and Toleration Matching

Every taint on the target node has a matching toleration in the corrected pod spec.

Output adds a toleration with a mismatched effect, key, or operator.

Extract taints from node description and tolerations from the prompt output. Assert for each taint, there exists a toleration where key matches and effect matches.

Resource Request Feasibility

Corrected resource requests do not exceed allocatable resources on any candidate node.

Output suggests a node that lacks sufficient CPU, memory, or ephemeral storage.

Compare proposed resources.requests against node.status.allocatable for all candidate nodes. Assert requests <= allocatable for each resource type.

Topology Spread Constraint Validity

Proposed topology spread constraints use valid topologyKey values and respect maxSkew limits.

Output references a topologyKey that does not exist as a node label.

Validate topologyKey exists in node labels via kubectl get nodes --show-labels. Assert maxSkew is a positive integer and whenUnsatisfiable is a valid enum.

Output Schema Adherence

Output is valid JSON matching the expected schema with corrected_spec and explanation fields.

Output is plain text, YAML, or JSON missing required fields.

Parse output with a strict JSON schema validator. Assert corrected_spec is a valid Kubernetes PodSpec and explanation is a non-empty string.

Explanation Traceability

Explanation references specific error messages, node conditions, or constraint violations from the input.

Explanation is generic, hallucinates error details not present in the input, or cites non-existent nodes.

Check that every claim in the explanation maps to a substring in the input error or node description. Assert no fabricated node names or error codes.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single pending pod spec and node list. Skip formal schema validation and rely on manual review of the output. Accept plain-text scheduling suggestions without requiring structured JSON output.

Prompt modification

  • Remove [OUTPUT_SCHEMA] placeholder and ask for a bulleted list of corrections
  • Replace [CONSTRAINTS] with a simple instruction: 'Suggest one change at a time'
  • Drop eval harness integration; review output manually against kubectl describe

Watch for

  • Suggestions that violate existing anti-affinity rules already in place
  • Overly broad taint tolerations that open scheduling to unintended nodes
  • Missing topology spread constraint awareness when suggesting node selectors
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.