Commit ea3e6768 authored by Avesh Agarwal's avatar Avesh Agarwal

Fix DS tests to set their namespaces to empty node selectors

so that they keep working with PodNodeSelector plugin.
parent be74187a
...@@ -53,6 +53,10 @@ const ( ...@@ -53,6 +53,10 @@ const (
daemonsetColorLabel = daemonsetLabelPrefix + "color" daemonsetColorLabel = daemonsetLabelPrefix + "color"
) )
// The annotation key scheduler.alpha.kubernetes.io/node-selector is for assigning
// node selectors labels to namespaces
var NamespaceNodeSelectors = []string{"scheduler.alpha.kubernetes.io/node-selector"}
// This test must be run in serial because it assumes the Daemon Set pods will // This test must be run in serial because it assumes the Daemon Set pods will
// always get scheduled. If we run other tests in parallel, this may not // always get scheduled. If we run other tests in parallel, this may not
// happen. In the future, running in parallel may work if we have an eviction // happen. In the future, running in parallel may work if we have an eviction
...@@ -99,7 +103,13 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { ...@@ -99,7 +103,13 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
ns = f.Namespace.Name ns = f.Namespace.Name
c = f.ClientSet c = f.ClientSet
err := clearDaemonSetNodeLabels(c)
updatedNS, err := updateNamespaceAnnotations(c, ns)
Expect(err).NotTo(HaveOccurred())
ns = updatedNS.Name
err = clearDaemonSetNodeLabels(c)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })
...@@ -494,6 +504,26 @@ func clearDaemonSetNodeLabels(c clientset.Interface) error { ...@@ -494,6 +504,26 @@ func clearDaemonSetNodeLabels(c clientset.Interface) error {
return nil return nil
} }
// updateNamespaceAnnotations sets node selectors related annotations on tests namespaces to empty
func updateNamespaceAnnotations(c clientset.Interface, nsName string) (*v1.Namespace, error) {
nsClient := c.CoreV1().Namespaces()
ns, err := nsClient.Get(nsName, metav1.GetOptions{})
if err != nil {
return nil, err
}
if ns.Annotations == nil {
ns.Annotations = make(map[string]string)
}
for _, n := range NamespaceNodeSelectors {
ns.Annotations[n] = ""
}
return nsClient.Update(ns)
}
func setDaemonSetNodeLabels(c clientset.Interface, nodeName string, labels map[string]string) (*v1.Node, error) { func setDaemonSetNodeLabels(c clientset.Interface, nodeName string, labels map[string]string) (*v1.Node, error) {
nodeClient := c.CoreV1().Nodes() nodeClient := c.CoreV1().Nodes()
var newNode *v1.Node var newNode *v1.Node
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment