Skip to content

Commit ee254fc

Browse files
committed
OCPBUGS-86009: Fix dns operator reporting Progressing=True on scale up
The cluster-dns-operator was incorrectly reporting Progressing=True during normal cluster scale up events. This was caused by the computeDNSProgressingCondition checking UpdatedNumberScheduled against DesiredNumberScheduled. When a new node is added, DesiredNumberScheduled increases immediately, but UpdatedNumberScheduled lags until the pod is running, causing the operator to appear to be rolling out. This commit introduces an isDaemonSetRollingOut helper, modeled after similar logic in the cluster-ingress-operator. It checks if the DaemonSet Generation matches ObservedGeneration, and checks if UpdatedNumberScheduled is less than CurrentNumberScheduled. If not, the operator is simply scaling and should not report Progressing=True.
1 parent 3d21411 commit ee254fc

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

pkg/operator/controller/dns_status.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ func computeDNSProgressingCondition(oldCondition *operatorv1.OperatorCondition,
208208
have := dnsDaemonset.Status.UpdatedNumberScheduled // num of nodes running the updated pod.
209209
// It's progressing when have < want. If have >= want, that's okay.
210210
if have < want {
211-
messages = append(messages, fmt.Sprintf("Have %d up-to-date DNS pods, want %d.", have, want))
211+
if isDaemonSetRollingOut(dnsDaemonset) {
212+
messages = append(messages, fmt.Sprintf("Have %d up-to-date DNS pods, want %d.", have, want))
213+
}
212214
}
213215

214216
haveSelector := dnsDaemonset.Spec.Template.Spec.NodeSelector
@@ -231,7 +233,9 @@ func computeDNSProgressingCondition(oldCondition *operatorv1.OperatorCondition,
231233

232234
// It's progressing when have < want. If have >= want, that's okay.
233235
if have < want {
234-
messages = append(messages, fmt.Sprintf("Have %d available node-resolver pods, want %d.", have, want))
236+
if isDaemonSetRollingOut(nodeResolverDaemonset) {
237+
messages = append(messages, fmt.Sprintf("Have %d available node-resolver pods, want %d.", have, want))
238+
}
235239
}
236240
}
237241
if len(messages) != 0 {
@@ -350,3 +354,16 @@ func lastTransitionTimeIsRecent(currTime, prevTime time.Time, toleration time.Du
350354
return elapsed <= toleration
351355
}
352356
}
357+
358+
// isDaemonSetRollingOut determines if the DaemonSet is currently in a rollout state
359+
// (i.e., actively replacing old pods with new ones or applying a new configuration)
360+
// versus simply stabilizing (e.g., waiting for pods to start after a node reboot or scale up).
361+
func isDaemonSetRollingOut(ds *appsv1.DaemonSet) bool {
362+
if ds.Generation != ds.Status.ObservedGeneration {
363+
return true
364+
}
365+
if ds.Status.UpdatedNumberScheduled < ds.Status.CurrentNumberScheduled {
366+
return true
367+
}
368+
return false
369+
}

pkg/operator/controller/dns_status_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func TestDNSStatusConditions(t *testing.T) {
111111
DesiredNumberScheduled: tc.inputs.desireDNS,
112112
NumberAvailable: tc.inputs.availDNS,
113113
UpdatedNumberScheduled: tc.inputs.updatedDNS,
114+
CurrentNumberScheduled: tc.inputs.desireDNS,
114115
},
115116
}
116117
dnsDaemonset.Spec.Template.Spec.NodeSelector = nodeSelectorForDNS(&operatorv1.DNS{})
@@ -132,6 +133,7 @@ func TestDNSStatusConditions(t *testing.T) {
132133
DesiredNumberScheduled: tc.inputs.desireNR,
133134
NumberAvailable: tc.inputs.availNR,
134135
UpdatedNumberScheduled: tc.inputs.updatedNR,
136+
CurrentNumberScheduled: tc.inputs.desireNR,
135137
},
136138
}
137139
}
@@ -240,6 +242,7 @@ func TestComputeDNSDegradedCondition(t *testing.T) {
240242
Status: appsv1.DaemonSetStatus{
241243
DesiredNumberScheduled: int32(desired),
242244
NumberAvailable: int32(available),
245+
CurrentNumberScheduled: int32(desired),
243246
},
244247
}
245248
}
@@ -471,6 +474,7 @@ func TestComputeDNSProgressingCondition(t *testing.T) {
471474
Status: appsv1.DaemonSetStatus{
472475
DesiredNumberScheduled: int32(desired),
473476
NumberAvailable: int32(available),
477+
CurrentNumberScheduled: int32(desired),
474478
UpdatedNumberScheduled: int32(updated),
475479
},
476480
}
@@ -638,6 +642,7 @@ func TestSkippingStatusUpdates(t *testing.T) {
638642
Status: appsv1.DaemonSetStatus{
639643
DesiredNumberScheduled: int32(desired),
640644
NumberAvailable: int32(available),
645+
CurrentNumberScheduled: int32(desired),
641646
UpdatedNumberScheduled: int32(updated),
642647
},
643648
}

0 commit comments

Comments
 (0)