Skip to content

Commit

Permalink
Merge pull request #421 from dmage/tolerate
Browse files Browse the repository at this point in the history
Bug 1785115: tolerate all NoSchedule taints
  • Loading branch information
openshift-merge-robot committed Jan 6, 2020
2 parents 787250a + b471bcd commit 3138e3a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/resource/nodecadaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ spec:
priorityClassName: system-cluster-critical
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
serviceAccountName: node-ca
containers:
Expand Down
41 changes: 41 additions & 0 deletions pkg/resource/nodecadaemon_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package resource

import (
"testing"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
kfake "k8s.io/client-go/kubernetes/fake"

"github.com/openshift/cluster-image-registry-operator/pkg/parameters"
)

func findToleration(list []corev1.Toleration, cond func(toleration corev1.Toleration) bool) *corev1.Toleration {
for i, t := range list {
if cond(t) {
return &list[i]
}
}
return nil
}

func TestNodeCADaemon(t *testing.T) {
params := &parameters.Globals{}
params.Deployment.Namespace = "openshift-image-registry"

clientset := kfake.NewSimpleClientset()

g := newGeneratorNodeCADaemonSet(nil, nil, clientset.AppsV1(), params)
obj, err := g.Create()
if err != nil {
t.Fatal(err)
}

ds := obj.(*appsv1.DaemonSet)
noScheduleToleration := findToleration(ds.Spec.Template.Spec.Tolerations, func(tol corev1.Toleration) bool {
return tol.Key == "" && tol.Operator == "Exists" && tol.Value == "" && tol.Effect == "NoSchedule"
})
if noScheduleToleration == nil {
t.Errorf("unable to find toleration for all NoSchedule taints, %#+v", ds.Spec.Template.Spec.Tolerations)
}
}

0 comments on commit 3138e3a

Please sign in to comment.