Skip to content

Commit

Permalink
Adapt code to removed .status.node field
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranzke committed Mar 6, 2023
1 parent 3dc5bbc commit 8c3036b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extensions/pkg/controller/worker/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
7 changes: 4 additions & 3 deletions extensions/pkg/controller/worker/predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit 8c3036b

Please sign in to comment.