Skip to content

Commit

Permalink
Merge pull request #366 from openshift-cherrypick-robot/cherry-pick-3…
Browse files Browse the repository at this point in the history
…58-to-release-4.13

[release-4.13] OCPBUGS-11449: Set DNS DaemonSet's maxSurge value to 10%
  • Loading branch information
openshift-merge-bot[bot] committed Dec 8, 2023
2 parents 807ae60 + 08a8f34 commit 759791e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
17 changes: 11 additions & 6 deletions assets/dns/daemonset.yaml
Expand Up @@ -2,6 +2,8 @@ kind: DaemonSet
apiVersion: apps/v1
# name, namespace and labels are set at runtime
spec:
# minReadySeconds should be 3x the readiness probe's polling interval (i.e. periodSeconds).
minReadySeconds: 9
template:
metadata:
annotations:
Expand Down Expand Up @@ -33,7 +35,7 @@ spec:
port: 8181
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 3
periodSeconds: 3 # Update the daemonset's spec.minReadySeconds above if you change this value!
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
Expand Down Expand Up @@ -85,8 +87,11 @@ spec:
updateStrategy:
type: RollingUpdate
rollingUpdate:
# TODO: Consider setting maxSurge to a positive value.
maxSurge: 0
# Note: The daemon controller rounds the percentage up
# (unlike the deployment controller, which rounds down).
maxUnavailable: 10%
# Set maxSurge to a positive value so that each node that has a pod
# continues to have a local ready pod during a rolling update. This is
# important for topology-aware hints as well as for similar logic in
# openshift-sdn and ovn-kubernetes that prefers to use a local ready DNS
# pod whenever one exists.
maxSurge: 10%
# maxUnavailable must be zero when maxSurge is nonzero.
maxUnavailable: 0
8 changes: 4 additions & 4 deletions pkg/manifests/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/operator/controller/controller_dns_daemonset.go
Expand Up @@ -337,6 +337,11 @@ func daemonsetConfigChanged(current, expected *appsv1.DaemonSet) (bool, *appsv1.
changed := false
updated := current.DeepCopy()

if current.Spec.MinReadySeconds != expected.Spec.MinReadySeconds {
updated.Spec.MinReadySeconds = expected.Spec.MinReadySeconds
changed = true
}

if !cmp.Equal(current.Spec.UpdateStrategy, expected.Spec.UpdateStrategy, cmpopts.EquateEmpty()) {
updated.Spec.UpdateStrategy = expected.Spec.UpdateStrategy
changed = true
Expand Down
35 changes: 28 additions & 7 deletions pkg/operator/controller/controller_dns_daemonset_test.go
Expand Up @@ -27,6 +27,18 @@ func TestDesiredDNSDaemonset(t *testing.T) {
t.Errorf("invalid dns daemonset: %v", err)
} else {
// Validate the daemonset
pointerTo := func(ios intstr.IntOrString) *intstr.IntOrString { return &ios }
expectedUpdateStrategy := appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
RollingUpdate: &appsv1.RollingUpdateDaemonSet{
MaxSurge: pointerTo(intstr.FromString("10%")),
MaxUnavailable: pointerTo(intstr.FromInt(0)),
},
}
actualUpdateStrategy := ds.Spec.UpdateStrategy
if !reflect.DeepEqual(actualUpdateStrategy, expectedUpdateStrategy) {
t.Errorf("unexpected update strategy: expected %#v, got %#v", expectedUpdateStrategy, actualUpdateStrategy)
}
expectedPodAnnotations := map[string]string{
"cluster-autoscaler.kubernetes.io/enable-ds-eviction": "true",
"target.workload.openshift.io/management": "{\"effect\": \"PreferredDuringScheduling\"}",
Expand Down Expand Up @@ -469,14 +481,23 @@ func TestDaemonsetConfigChanged(t *testing.T) {
expect: true,
},
{
description: "if the update strategy changes",
description: "if the update strategy's max unavailable parameter changes",
mutate: func(daemonset *appsv1.DaemonSet) {
daemonset.Spec.UpdateStrategy = appsv1.DaemonSetUpdateStrategy{
Type: appsv1.RollingUpdateDaemonSetStrategyType,
RollingUpdate: &appsv1.RollingUpdateDaemonSet{
MaxUnavailable: pointerTo(intstr.FromString("10%")),
},
}
daemonset.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable = pointerTo(intstr.FromString("10%"))
},
expect: true,
},
{
description: "if the update strategy's max surge parameter changes",
mutate: func(daemonset *appsv1.DaemonSet) {
daemonset.Spec.UpdateStrategy.RollingUpdate.MaxSurge = pointerTo(intstr.FromString("10%"))
},
expect: true,
},
{
description: "if spec.minReadySeconds changes",
mutate: func(daemonset *appsv1.DaemonSet) {
daemonset.Spec.MinReadySeconds = 9
},
expect: true,
},
Expand Down

0 comments on commit 759791e

Please sign in to comment.