fix: fail Deployment tracking fast on ReplicaSet pod-create errors

Closed
SH
25d ago
+2649-122

This PR makes the Deployment tracker observe ReplicaSet pod-create failures such as FailedCreate ... exceeded quota instead of waiting for the tracking timeout.

The ReplicaSet controller reports these failures on the ReplicaSet, while the Deployment tracker previously watched only the Deployment object and its events. StatefulSet and DaemonSet tracking are unaffected because their controllers report FailedCreate on the object kubedog already watches.

Behavior

  • Read FailedCreate from the durable ReplicaSetReplicaFailure condition. This catches failures that predate informer startup and works with KUBEDOG_DISABLE_EVENTS=1.
  • Treat invalid specs and quota failures with no rollout path to release quota as fatal immediately.
  • Keep rollout-recoverable quota failures counted against the allowed-failures budget. The first classification stays latched until the condition clears and reappears, because Kubernetes can retain a stale FailedCreate condition while retrying.
  • Account for TerminatingReplicas when deciding whether an old ReplicaSet can release quota for the rollout.
  • Wait for the complete initial ReplicaSet snapshot before classifying failures.
  • Track ReplicaSet incarnations by UID, handle same-name replacement, and preserve failures across selector leave/reentry without accepting stale events.
  • Preserve informer ordering with unbuffered, cancellation-aware sends so cleanup cannot leave the shared informer goroutine blocked.
  • Keep the original failure reason and message in the reported diagnostic.
  • Mark a fatal resource state as failed only for fail modes that should stop the deploy process. IgnoreAndContinueDeployProcess remains unchanged.

Only ReplicaSets controlled by the tracked Deployment are considered, because label selectors alone are not unique.

Verification

  • go build ./...
  • go test ./...
  • Race-enabled tests for the Deployment, ReplicaSet, dynamic tracker, and utility packages
  • go vet on the changed package trees
  • Lifecycle coverage for initial sync, failure classification, recovery, UID replacement, selector reentry, stale conditions, successor promotion, and informer cleanup
  • kind reproduction with a ResourceQuota of pods: 0: tracking previously waited for the timeout and now returns the original FailedCreate quota diagnostic within seconds

Closes #398
Refs #216, #363