Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions pkg/operator/controller/dns_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ func computeDNSProgressingCondition(oldCondition *operatorv1.OperatorCondition,
have := dnsDaemonset.Status.UpdatedNumberScheduled // num of nodes running the updated pod.
// It's progressing when have < want. If have >= want, that's okay.
if have < want {
messages = append(messages, fmt.Sprintf("Have %d up-to-date DNS pods, want %d.", have, want))
if isDaemonSetRollingOut(dnsDaemonset) {
messages = append(messages, fmt.Sprintf("Have %d up-to-date DNS pods, want %d.", have, want))
}
}

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

// It's progressing when have < want. If have >= want, that's okay.
if have < want {
messages = append(messages, fmt.Sprintf("Have %d available node-resolver pods, want %d.", have, want))
if isDaemonSetRollingOut(nodeResolverDaemonset) {
messages = append(messages, fmt.Sprintf("Have %d available node-resolver pods, want %d.", have, want))
}
}
}
if len(messages) != 0 {
Expand Down Expand Up @@ -350,3 +354,16 @@ func lastTransitionTimeIsRecent(currTime, prevTime time.Time, toleration time.Du
return elapsed <= toleration
}
}

// isDaemonSetRollingOut determines if the DaemonSet is currently in a rollout state
// (i.e., actively replacing old pods with new ones or applying a new configuration)
// versus simply stabilizing (e.g., waiting for pods to start after a node reboot or scale up).
func isDaemonSetRollingOut(ds *appsv1.DaemonSet) bool {
if ds.Generation != ds.Status.ObservedGeneration {
return true
}
if ds.Status.UpdatedNumberScheduled < ds.Status.CurrentNumberScheduled {
return true
}
return false
}
31 changes: 31 additions & 0 deletions pkg/operator/controller/dns_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestDNSStatusConditions(t *testing.T) {
DesiredNumberScheduled: tc.inputs.desireDNS,
NumberAvailable: tc.inputs.availDNS,
UpdatedNumberScheduled: tc.inputs.updatedDNS,
CurrentNumberScheduled: tc.inputs.desireDNS,
},
}
dnsDaemonset.Spec.Template.Spec.NodeSelector = nodeSelectorForDNS(&operatorv1.DNS{})
Expand All @@ -132,6 +133,7 @@ func TestDNSStatusConditions(t *testing.T) {
DesiredNumberScheduled: tc.inputs.desireNR,
NumberAvailable: tc.inputs.availNR,
UpdatedNumberScheduled: tc.inputs.updatedNR,
CurrentNumberScheduled: tc.inputs.desireNR,
},
}
}
Expand Down Expand Up @@ -240,6 +242,7 @@ func TestComputeDNSDegradedCondition(t *testing.T) {
Status: appsv1.DaemonSetStatus{
DesiredNumberScheduled: int32(desired),
NumberAvailable: int32(available),
CurrentNumberScheduled: int32(desired),
},
}
}
Expand Down Expand Up @@ -471,6 +474,7 @@ func TestComputeDNSProgressingCondition(t *testing.T) {
Status: appsv1.DaemonSetStatus{
DesiredNumberScheduled: int32(desired),
NumberAvailable: int32(available),
CurrentNumberScheduled: int32(desired),
UpdatedNumberScheduled: int32(updated),
},
}
Expand Down Expand Up @@ -591,6 +595,32 @@ func TestComputeDNSProgressingCondition(t *testing.T) {
tolerations: customTolerations,
expected: operatorv1.ConditionTrue,
},
{
name: "DNS daemonset scaling up but not rolling out should not be progressing",
clusterIP: "172.30.0.10",
dnsDaemonset: func() *appsv1.DaemonSet {
ds := makeDaemonSet(6, 5, 5, defaultSelector, defaultTolerations)
ds.Status.CurrentNumberScheduled = 5
return ds
}(),
nrDaemonset: makeDaemonSet(6, 6, 6, defaultSelector, defaultTolerations),
nodeSelector: defaultSelector,
tolerations: defaultTolerations,
expected: operatorv1.ConditionFalse,
},
{
name: "node-resolver daemonset scaling up but not rolling out should not be progressing",
clusterIP: "172.30.0.10",
dnsDaemonset: makeDaemonSet(6, 6, 6, defaultSelector, defaultTolerations),
nrDaemonset: func() *appsv1.DaemonSet {
ds := makeDaemonSet(6, 5, 5, defaultSelector, defaultTolerations)
ds.Status.CurrentNumberScheduled = 5
return ds
}(),
nodeSelector: defaultSelector,
tolerations: defaultTolerations,
expected: operatorv1.ConditionFalse,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -638,6 +668,7 @@ func TestSkippingStatusUpdates(t *testing.T) {
Status: appsv1.DaemonSetStatus{
DesiredNumberScheduled: int32(desired),
NumberAvailable: int32(available),
CurrentNumberScheduled: int32(desired),
UpdatedNumberScheduled: int32(updated),
},
}
Expand Down