diff --git a/extensions/pkg/controller/worker/predicate.go b/extensions/pkg/controller/worker/predicate.go index 92bb5b50644..a6dc58b01b6 100644 --- a/extensions/pkg/controller/worker/predicate.go +++ b/extensions/pkg/controller/worker/predicate.go @@ -35,7 +35,7 @@ func MachineStatusHasChanged() predicate.Predicate { } return oldMachine.Spec.ProviderID != newMachine.Spec.ProviderID || - oldMachine.Status.Node != newMachine.Status.Node + oldMachine.Labels[machinev1alpha1.NodeLabelKey] != newMachine.Labels[machinev1alpha1.NodeLabelKey] } return predicate.Funcs{ diff --git a/extensions/pkg/controller/worker/predicate_test.go b/extensions/pkg/controller/worker/predicate_test.go index 13c3fba20e1..83c1e506365 100644 --- a/extensions/pkg/controller/worker/predicate_test.go +++ b/extensions/pkg/controller/worker/predicate_test.go @@ -18,6 +18,7 @@ import ( machinev1alpha1 "github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/event" "github.com/gardener/gardener/extensions/pkg/controller/worker" @@ -55,7 +56,7 @@ var _ = Describe("Worker Predicates", func() { It("should notice the change of the Node in the Status", func() { predicate := worker.MachineStatusHasChanged() - newMachine.Status.Node = "ip.10-256-18-291.cluster.node" + metav1.SetMetaDataLabel(&newMachine.ObjectMeta, "node", "ip.10-256-18-291.cluster.node") Expect(predicate.Create(createEvent)).To(BeTrue()) Expect(predicate.Update(updateEvent)).To(BeTrue()) Expect(predicate.Delete(deleteEvent)).To(BeTrue()) @@ -64,8 +65,8 @@ var _ = Describe("Worker Predicates", func() { It("should not react when there are no changes of the Node in the Status", func() { predicate := worker.MachineStatusHasChanged() - oldMachine.Status.Node = "ip.10-256-18-291.cluster.node" - newMachine.Status.Node = "ip.10-256-18-291.cluster.node" + metav1.SetMetaDataLabel(&oldMachine.ObjectMeta, "node", "ip.10-256-18-291.cluster.node") + metav1.SetMetaDataLabel(&newMachine.ObjectMeta, "node", "ip.10-256-18-291.cluster.node") Expect(predicate.Create(createEvent)).To(BeTrue()) Expect(predicate.Update(updateEvent)).To(BeFalse()) Expect(predicate.Delete(deleteEvent)).To(BeTrue())