Skip to content

Commit

Permalink
Merge pull request #273 from candita/BZ-1939723
Browse files Browse the repository at this point in the history
Bug 1939723: Don't check node-resolver status for DNS Degraded condition
  • Loading branch information
openshift-merge-robot committed Jun 4, 2021
2 parents a4fb428 + c1df81a commit d87dd22
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func desiredNodeResolverDaemonSet(dns *operatorv1.DNS, clusterIP, clusterDomain,
hostPathFile := corev1.HostPathFile
// TODO: Consider setting maxSurge to a positive value.
maxSurge := intstr.FromInt(0)
maxUnavailable := intstr.FromString("10%")
maxUnavailable := intstr.FromString("33%")
envs := []corev1.EnvVar{{
Name: "SERVICES",
Value: services,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestNodeResolverDaemonsetConfigChanged(t *testing.T) {
daemonset.Spec.UpdateStrategy = appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
RollingUpdate: &appsv1.RollingUpdateDaemonSet{
MaxUnavailable: pointerTo(intstr.FromString("10%")),
MaxUnavailable: pointerTo(intstr.FromString("33%")),
},
}
},
Expand Down
43 changes: 7 additions & 36 deletions pkg/operator/controller/dns_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func computeDNSStatusConditions(dns *operatorv1.DNS, clusterIP string, haveDNSDa
}

conditions := []operatorv1.OperatorCondition{
computeDNSDegradedCondition(oldDegradedCondition, clusterIP, haveDNSDaemonset, dnsDaemonset, haveNodeResolverDaemonset, nodeResolverDaemonset),
computeDNSDegradedCondition(oldDegradedCondition, clusterIP, haveDNSDaemonset, dnsDaemonset),
computeDNSProgressingCondition(oldProgressingCondition, dns, clusterIP, haveDNSDaemonset, dnsDaemonset, haveNodeResolverDaemonset, nodeResolverDaemonset),
computeDNSAvailableCondition(oldAvailableCondition, clusterIP, haveDNSDaemonset, dnsDaemonset),
}
Expand All @@ -60,8 +60,9 @@ func computeDNSStatusConditions(dns *operatorv1.DNS, clusterIP string, haveDNSDa
}

// computeDNSDegradedCondition computes the dns Degraded status condition
// based on the status of clusterIP and the DNS and node-resolver daemonsets.
func computeDNSDegradedCondition(oldCondition *operatorv1.OperatorCondition, clusterIP string, haveDNSDaemonset bool, dnsDaemonset *appsv1.DaemonSet, haveNodeResolverDaemonset bool, nodeResolverDaemonset *appsv1.DaemonSet) operatorv1.OperatorCondition {
// based on the status of clusterIP and the DNS daemonset. The node-resolver
// daemonset is not a part of the calculation of degraded condition.
func computeDNSDegradedCondition(oldCondition *operatorv1.OperatorCondition, clusterIP string, haveDNSDaemonset bool, dnsDaemonset *appsv1.DaemonSet) operatorv1.OperatorCondition {
degradedCondition := &operatorv1.OperatorCondition{
Type: operatorv1.OperatorStatusTypeDegraded,
}
Expand Down Expand Up @@ -104,45 +105,15 @@ func computeDNSDegradedCondition(oldCondition *operatorv1.OperatorCondition, clu
messages = append(messages, fmt.Sprintf("Too many DNS pods are unavailable (%d > %d max unavailable).", numberUnavailable, maxUnavailable))
}
}
if !haveNodeResolverDaemonset {
status = operatorv1.ConditionTrue
degradedReasons = append(degradedReasons, "NoNodeResolverDaemonSet")
messages = append(messages, "The node-resolver daemonset does not exist.")
} else {
want := nodeResolverDaemonset.Status.DesiredNumberScheduled
have := nodeResolverDaemonset.Status.NumberAvailable
numberUnavailable := want - have
maxUnavailableIntStr := intstr.FromInt(1)
if nodeResolverDaemonset.Spec.UpdateStrategy.RollingUpdate != nil && nodeResolverDaemonset.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable != nil {
maxUnavailableIntStr = *nodeResolverDaemonset.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable
}
maxUnavailable, intstrErr := intstr.GetScaledValueFromIntOrPercent(&maxUnavailableIntStr, int(want), true)
switch {
case want == 0:
status = operatorv1.ConditionTrue
degradedReasons = append(degradedReasons, "NoNodeResolverPodsDesired")
messages = append(messages, "No node-resolver pods are desired; this could mean all nodes are tainted or unschedulable.")
case have == 0:
status = operatorv1.ConditionTrue
degradedReasons = append(degradedReasons, "NoNodeResolverPodsAvailable")
messages = append(messages, "No node-resolver pods are available.")
case intstrErr != nil:
degradedReasons = append(degradedReasons, "InvalidNodeResolverMaxUnavailable")
messages = append(messages, fmt.Sprintf("The node-resolver daemonset has an invalid MaxUnavailable value: %v", intstrErr))
case int(numberUnavailable) > maxUnavailable:
status = operatorv1.ConditionTrue
degradedReasons = append(degradedReasons, "MaxUnavailableNodeResolverPodsExceeded")
messages = append(messages, fmt.Sprintf("Too many node-resolver pods are unavailable (%d > %d max unavailable).", numberUnavailable, maxUnavailable))
}
}

if len(degradedReasons) != 0 {
degradedCondition.Status = status
degradedCondition.Reason = strings.Join(degradedReasons, "")
degradedCondition.Message = strings.Join(messages, "\n")
} else {
degradedCondition.Status = operatorv1.ConditionFalse
degradedCondition.Reason = "AsExpected"
degradedCondition.Message = "Enough DNS and node-resolver pods are available, and the DNS service has a cluster IP address."
degradedCondition.Message = "Enough DNS pods are available, and the DNS service has a cluster IP address."
}

return setDNSLastTransitionTime(degradedCondition, oldCondition)
Expand Down Expand Up @@ -202,7 +173,7 @@ func computeDNSProgressingCondition(oldCondition *operatorv1.OperatorCondition,
}

// computeDNSAvailableCondition computes the dns Available status condition
// based on the status of clusterIP and the DNS and node-resolver daemonsets.
// based on the status of clusterIP and the DNS daemonset.
func computeDNSAvailableCondition(oldCondition *operatorv1.OperatorCondition, clusterIP string, haveDNSDaemonset bool, dnsDaemonset *appsv1.DaemonSet) operatorv1.OperatorCondition {
availableCondition := &operatorv1.OperatorCondition{
Type: operatorv1.OperatorStatusTypeAvailable,
Expand Down
Loading

0 comments on commit d87dd22

Please sign in to comment.