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

Fix Config Daemon node selector #483

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion controllers/sriovoperatorconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
})

})
})
4 changes: 2 additions & 2 deletions pkg/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
wizhaoredhat marked this conversation as resolved.
Show resolved Hide resolved
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)
}
}

Expand Down
Loading