[Bug]: ClusterPolicy isDaemonSetReady can report Ready from a DaemonSet status of an older generation
Describe the bug
#2968 fixed internal/state/state_skel.go:isDaemonSetReady to require status.observedGeneration >= metadata.generation. The ClusterPolicy implementation in controllers/object_controls.go:4030 still lacks that check:
- line 4040 returns Ready whenever
status.desiredNumberScheduled == 0, including for a DaemonSet whose status the DaemonSet controller has not populated yet; - line 4045 trusts
status.numberUnavailablebefore the new generation is observed.
A freshly created or just-updated operand DaemonSet can therefore be reported Ready on the first reconcile pass, so ClusterPolicy can flip Ready → NotReady and later states proceed before the operand is actually scheduled.
To Reproduce
Found by code review; not yet reproduced on a cluster. Unit-level: call isDaemonSetReady with a DaemonSet with generation: 2, status.observedGeneration: 1, desiredNumberScheduled: 0 → returns Ready.
Expected behavior
Same semantics as the fixed state_skel implementation: not ready until observedGeneration >= generation.
Suggested fix Add the observedGeneration guard, or share one readiness helper between the ClusterPolicy and NVIDIADriver/GPUCluster stacks.
Environment (please provide the following information):
- GPU Operator Version: main @ f806d6b (code inspection)
I’m working on this with regression coverage for stale DaemonSet generations in ClusterPolicy readiness.
Thanks @efegokdemir for the fix and @kvalliyurnatt for the review. Confirmed on current main: isDaemonSetReady in controllers/object_controls.go now returns NotReady while status.observedGeneration < metadata.generation.