gpu-operator icon indicating copy to clipboard operation
gpu-operator copied to clipboard

[Bug]: ClusterPolicy isDaemonSetReady can report Ready from a DaemonSet status of an older generation

Open CloneOfAlex opened this issue 1 month ago • 2 comments

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.numberUnavailable before 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)

CloneOfAlex avatar Oct 13 '26 17:10 CloneOfAlex

I’m working on this with regression coverage for stale DaemonSet generations in ClusterPolicy readiness.

efegokdemir avatar Oct 14 '26 09:10 efegokdemir

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.

CloneOfAlex avatar Nov 05 '26 23:11 CloneOfAlex