reconciler-patterns

Enforces non-blocking, state-machine-driven reconciler invariants for Kubernetes controllers in Go.

4|Updated Dec 1, 2025
One-click install
npx skills add https://github.com/simplyblock/simplyblock-operator --skill reconciler-patterns-simplyblock
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: reconciler-patterns
Source: https://github.com/simplyblock/simplyblock-operator/tree/main/.claude/skills/reconciler-patterns
Command: npx skills add https://github.com/simplyblock/simplyblock-operator --skill reconciler-patterns-simplyblock

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Kubernetes reconcilers that block, lose state across restarts, or repeat side effects cause stalled controllers and multi-hour outages. This Skill codifies the eight invariants every reconciler in this repository must follow and ships a checker that verifies them by following the call graph out of Reconcile. ## Core Features & Use Cases - Call-graph blocking detection: scripts/check-reconcilers.py follows calls out of Reconcile to find time.Sleep, time.After, polling, and WaitGroup waits that a grep cannot see, plus result-and-error returns, fatal exits, status-via-Update writes, and finalizers that are never removed. - State machine guidance: references/state-machines.md explains phase/step modeling with atlas-lib/statemachine, per-action graphs via MultiConfig, snapshot persistence with deadlines, and how to convert a hand-rolled switch. - Concurrency rules: references/concurrency.md covers generation, observedGeneration, resourceVersion conflict retries, informer cache staleness, lock-field mutual exclusion, and per-cluster keying traps. - Use Case: While writing or reviewing a StorageNodeOps reconciler, run the checker with --changed to confirm no blocking call or missing finalizer removal was introduced, then consult the references before adding a new phase. ## Quick Start Ask the AI to review the reconciler you just wrote against the reconciler-patterns invariants and run the checker on the changed controller files.

Frequently Asked Questions about reconciler-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a non-blocking Kubernetes reconciler in Go?

Compute current state, persist it to status, and return with an error or RequeueAfter instead of sleeping or polling. Express waiting as state plus requeue, and use .Owns(&batchv1.Job{}) so a Job's terminal event wakes the reconcile.

How do I detect blocking calls inside a Reconcile call graph?

Run scripts/check-reconcilers.py, which parses Go functions under operator/internal and follows callees out of Reconcile. It reports time.Sleep, time.After, wait.Poll, and WaitGroup waits even when they hide several helper calls deep.

When should a controller use a state machine instead of a switch on phase?

Use atlas-lib/statemachine whenever an operation has multiple steps, because a declared graph validates transitions, carries per-step deadlines, and survives restarts via Snapshot/Restore. Ops kinds with several actions need one graph per action through MultiConfig.

Why does my reconciler repeat a side effect after a restart?

The intent was not persisted before the external call. Write ahead by recording the step and target ID in status first, and make every retried call idempotent or guarded by a read that checks whether it already landed.

Does the checker replace manual review of reconcilers?

No. The checker verifies blocking, result-and-error, status-update, and finalizer rules, but state modeling, lock release on all paths, observedGeneration, and event emission still require reading the code against the skill's checklist.