Repository navigation
fix(operator): stop the KapeAgentServer reconcile hot loop on API defaults - #271
Merged
Merged
Conversation
…aults applySpec assigned the rendered Deployment.Spec wholesale, which zeroes every field the API server defaults (dnsPolicy, restartPolicy, probe successThreshold/timeoutSeconds, terminationMessagePath, volume defaultMode). The merge-patch diff against a live object was therefore never empty, so every reconcile patched the Deployment, bumping metadata.generation ~10/s. The Deployment never reported availability, so the CR stayed Ready=False (Progressing) forever — observed on the live cluster as generation 1309 -> 1511 in 20s. Inherit those defaults from the live object into the rendered spec before assigning (pod-level scalars, per-container/probe/volume defaults), and keep the live strategy/ingressClassName when the renderer does not set them. A re-apply against a defaulted object is now a no-op, pinned by TestAgentServerAdapterApplyIgnoresAPIDefaults.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Symptom (live cluster, kape 0.1.0 operator, kape #261 close-out)
The operator rendered
kape-controller-defaultfine, the pod was 1/1 Ready, but the Deployment never became available and the CR sat atReady=False (Progressing: controller Deployment is not available yet).metadata.generationclimbed 1309 → 1511 in 20 s — a patch hot loop.Cause
applySpecdoeslive.Spec = d.Specfor Deployments. The rendered spec omits everything the API server defaults:dnsPolicy,restartPolicy,terminationGracePeriodSeconds,securityContextterminationMessagePath,terminationMessagePolicysuccessThreshold,failureThreshold,timeoutSecondsdefaultMode,sizeLimitA merge patch computed against a live object therefore always differs (armor: the containers list is replaced wholesale, so the defaults are dropped and re-applied every time), so
ensurepatched on every reconcile. Each patch bumped generation → the writer'sDeploymentStatuscheck (ObservedGeneration >= Generationwith available replicas) never converged → CR never Ready.Fix
Before assigning, inherit the live values for every field the renderer does not own (
inheritPodDefaults→ containers/probes/volumes, plusstrategy/ingressClassName). A re-apply against a defaulted Deployment is now a true no-op.TestAgentServerAdapterApplyIgnoresAPIDefaults: applies, simulates API defaulting on the stored object, re-applies, assertsresourceVersionandgenerationare unchangedgo test ./operator/infra/k8s/passes; the two failures inoperator/controller/reconcileandoperator/infra/qdrantreproduce on unmodifiedmain(env-dependent, unrelated)Follow-up (not in this PR)
KAPE_MONITOR_*env emitted by the chart reaches the controller, but the chart'scontrollerWiring.extraEnvpath is untested against a real Deployment; separate issue if it bites.