diff --git a/controllers/sriovoperatorconfig_controller_test.go b/controllers/sriovoperatorconfig_controller_test.go index ffef04c34..c925324b9 100644 --- a/controllers/sriovoperatorconfig_controller_test.go +++ b/controllers/sriovoperatorconfig_controller_test.go @@ -151,7 +151,7 @@ var _ = Describe("Operator", func() { Expect(err).NotTo(HaveOccurred()) }) - PIt("should be able to update the node selector of sriov-network-config-daemon", func() { + It("should be able to update the node selector of sriov-network-config-daemon", func() { By("specify the configDaemonNodeSelector") config := &sriovnetworkv1.SriovOperatorConfig{} err := util.WaitForNamespacedObject(config, k8sClient, testNamespace, "default", interval, timeout) @@ -171,5 +171,27 @@ var _ = Describe("Operator", func() { }, timeout*10, interval).Should(Equal(config.Spec.ConfigDaemonNodeSelector)) }) + It("should be able to do multiple updates to the node selector of sriov-network-config-daemon", func() { + By("changing the configDaemonNodeSelector") + config := &sriovnetworkv1.SriovOperatorConfig{} + err := util.WaitForNamespacedObject(config, k8sClient, testNamespace, "default", interval, timeout) + Expect(err).NotTo(HaveOccurred()) + config.Spec.ConfigDaemonNodeSelector = map[string]string{"labelA": "", "labelB": "", "labelC": ""} + err = k8sClient.Update(goctx.TODO(), config) + Expect(err).NotTo(HaveOccurred()) + config.Spec.ConfigDaemonNodeSelector = map[string]string{"labelA": "", "labelB": ""} + err = k8sClient.Update(goctx.TODO(), config) + Expect(err).NotTo(HaveOccurred()) + + daemonSet := &appsv1.DaemonSet{} + Eventually(func() map[string]string { + err := k8sClient.Get(goctx.TODO(), types.NamespacedName{Name: "sriov-network-config-daemon", Namespace: testNamespace}, daemonSet) + if err != nil { + return nil + } + return daemonSet.Spec.Template.Spec.NodeSelector + }, timeout*10, interval).Should(Equal(config.Spec.ConfigDaemonNodeSelector)) + }) + }) }) diff --git a/pkg/apply/apply.go b/pkg/apply/apply.go index afebdf405..f5560e993 100644 --- a/pkg/apply/apply.go +++ b/pkg/apply/apply.go @@ -90,11 +90,11 @@ func ApplyObject(ctx context.Context, client k8sclient.Client, obj *uns.Unstruct if err := MergeObjectForUpdate(existing, obj); err != nil { return errors.Wrapf(err, "could not merge object %s with existing", objDesc) } - if !equality.Semantic.DeepDerivative(obj, existing) { + if !equality.Semantic.DeepEqual(existing, obj) { if err := client.Update(ctx, obj); err != nil { return errors.Wrapf(err, "could not update object %s", objDesc) } else { - log.Printf("update was successful") + log.Printf("update was successful %s", objDesc) } }