Keeping operator .status accurate under failures
status reliability under faults.
status can lag or go stale during partitions and crashes; make reconcile idempotent, observe true state each loop, use conditions and observedGeneration, handle conflicts.
What's really being asked
Whether you understand that status reflects observed reality at a point in time and that there is no atomic transaction spanning an external action and the status write.
The full answer
The core challenge is that updating an external service and writing the custom resource's status are two separate operations with no shared transaction. If the operator performs the external action, for example provisioning a database, and then crashes before writing status, the status is stale on restart; conversely a status write could succeed while the external call is uncertain. Network partitions compound this: the operator may be unable to observe the external service, so it cannot know the true state, and any cached value may be wrong. The robust approach is to treat reconcile as idempotent and source-of-truth-driven: each loop, actively re-observe the real external state rather than trusting cached or previously written status, then reconcile both the external resource and the status to match observed reality. Use the status subresource so spec and status writes do not clobber each other, model state with conditions and a observedGeneration field so consumers know which spec the status reflects, requeue on errors with backoff, and handle optimistic-concurrency conflict errors on status updates by retrying with a fresh object. Accept that status is eventually consistent.
The mistakes people make
Assuming the action and status update are atomic, trusting cached or last-written status as ground truth, ignoring update conflicts, or not re-observing external state after a restart.
What usually comes next
What is observedGeneration for? How do conditions help? How do you handle resourceVersion conflicts on status updates? How do you detect partitions versus real failures?
A concrete example
Your operator provisions an external cache, then crashes before setting status to Ready. On restart, instead of assuming anything from old status, reconcile queries the cache provider's API, sees it already exists and is healthy, and only then sets the Ready condition and observedGeneration. During a partition where the provider is unreachable, it sets a degraded condition and requeues rather than reporting a stale Ready.
Interview question
After an operator crashes between provisioning an external service and writing .status, what is the most robust recovery on restart?
- a.Re-observe the real external state each reconcile and set status from that, idempotentlyCorrect
- b.Assume the external action failed and recreate the service unconditionally
- c.Trust the last cached status value to avoid redundant external calls
- d.Skip status updates until the next user-triggered change
Why? this is the answer
Because the action and status write are not atomic, the only reliable source is the external system itself; reconcile must re-observe and reconcile idempotently. Trusting cached status risks reporting stale or wrong state, and unconditional recreation can duplicate resources.
Just read this? Test yourself on what you have been reading.
Read the original → redhat.com
- #kubernetes
- #operators
- #status
- #consistency
- #fault-tolerance
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.
See open roles