Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1785115: tolerate all NoSchedule taints #421

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}
}