fix(stackresource): report PortNotListening on workloads that never serve - #61
Merged
Merged
Conversation
…erve A container listening on the wrong port never turns Ready, so no further workload events arrive and nothing wakes the reconcile again. The not-serving path captured the port diagnosis into LastFailureDetails and then stopped: it never started the grace clock, never filed a verdict and never requeued, so the StackResource sat in Phase=Pending forever with the reason buried in status. Unify both paths behind checkPorts, so a declared port nobody listens on reaches the same terminal verdict whether or not the workload serves: - One grace clock for both. The clock runs on the first refusal from a running pod on the revision, serving or not. - The reconcile requeues itself while the clock runs, because a refused port produces no Kubernetes event that would otherwise bring it back. - A failed serving workload keeps being re-dialed, so an app that binds its port late recovers without a new revision. The wait is the length of the outage so far, which doubles it on every retry between 1m and 10m. Alongside the behaviour change, verifyPorts now writes only Status.PortCheck and checkPorts is the only writer of LastFailureDetails on the port path, so the verdict has a single owner. A crash detail still outranks a port verdict at every call site. status_derive.go is restructured only for readability: each verdict kind gets a named function and the stale-generation condition lookup is shared. No derivation behaviour changes.
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.
The bug
A container listening on the wrong port (or on
127.0.0.1instead of0.0.0.0) never turns Ready. No further workload events arrive, so nothing wakes the reconcile again.mainhandled that case by capturing the port diagnosis intoLastFailureDetailsand stopping. It never started the grace clock, never filed a verdict, and never requeued — so the StackResource sat inPhase=Pendingforever with the reason buried in status. The serving path did report a failure, but only for a dead secondary port, and never re-checked afterwards.The change
Both paths now go through one
checkPorts, so a declared port nobody listens on reaches the same terminal verdict either way.FailingSincewas previously serving-only.Available=True(ServingButStalled).Resulting status:
Phase=Failed,Stalled=True, reasonPortNotListening, with a message naming the dead port.Alongside it
verifyPortsnow writes onlyStatus.PortCheck;checkPortsis the only writer ofLastFailureDetailson the port path. The failure message is rendered from status rather than from the dial, so a repeated verdict reads identically to a fresh one. The four duplicated caller blocks indeployment.go/statefulset.gocollapsed to one line each.status_derive.gois restructured for readability only — each verdict kind gets a named function and the stale-generation lookup is shared. No derivation behaviour changes; existing tests cover it untouched.Review notes
A code review of this branch raised one real defect, now fixed:
checkPortsdiscarded the "a dial is in flight" signal, so the recovery poll ran at half the intended rate and every answer it read was a full interval stale. The existing test had encoded that behaviour, and was corrected.Two items were assessed and deliberately left:
main; called out as a known limitation rather than fixed here.portCheckRequeueIntervalis 30s rather than 10s: six samples inside a three-minute window is enough to decide something only acted on at the end of it, and the dials go against user pods.Test plan
make test(codegen, fmt, vet, unit suite with envtest)portRetryAfter's doubling and capmake test-integration— includes a new spec assertingPhase=Failed/Stalled=True/PortNotListeningfor a workload that never serves. Not run locally; needs Docker and ~11 minutes.