diff --git a/extensions/pkg/controller/worker/controller.go b/extensions/pkg/controller/worker/controller.go index b9a472bb9791..8fd8502a1883 100644 --- a/extensions/pkg/controller/worker/controller.go +++ b/extensions/pkg/controller/worker/controller.go @@ -104,7 +104,7 @@ func addStateUpdatingController(mgr manager.Manager, options controller.Options, machinePredicates = []predicate.Predicate{ predicate.Or( - MachineStatusHasChanged(), + MachineNodeInfoHasChanged(), predicate.GenerationChangedPredicate{}, ), } diff --git a/extensions/pkg/controller/worker/predicate.go b/extensions/pkg/controller/worker/predicate.go index 92bb5b50644a..88cee3073cad 100644 --- a/extensions/pkg/controller/worker/predicate.go +++ b/extensions/pkg/controller/worker/predicate.go @@ -21,8 +21,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" ) -// MachineStatusHasChanged is a predicate deciding whether the status of a Machine has been changed. -func MachineStatusHasChanged() predicate.Predicate { +// MachineNodeInfoHasChanged is a predicate deciding whether the information about the backing node of a Machine has +// been changed. +func MachineNodeInfoHasChanged() predicate.Predicate { statusHasChanged := func(oldObj client.Object, newObj client.Object) bool { oldMachine, ok := oldObj.(*machinev1alpha1.Machine) if !ok { @@ -35,7 +36,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 13c3fba20e1d..9d2facb8c3e4 100644 --- a/extensions/pkg/controller/worker/predicate_test.go +++ b/extensions/pkg/controller/worker/predicate_test.go @@ -18,13 +18,14 @@ 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" ) var _ = Describe("Worker Predicates", func() { - Describe("#MachineStatusHasChanged", func() { + Describe("#MachineNodeInfoHasChanged", func() { var ( oldMachine *machinev1alpha1.Machine newMachine *machinev1alpha1.Machine @@ -53,26 +54,35 @@ 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" + It("should notice the change of the provider id", func() { + predicate := worker.MachineNodeInfoHasChanged() + newMachine.Spec.ProviderID = "foo" Expect(predicate.Create(createEvent)).To(BeTrue()) Expect(predicate.Update(updateEvent)).To(BeTrue()) Expect(predicate.Delete(deleteEvent)).To(BeTrue()) Expect(predicate.Generic(genericEvent)).To(BeFalse()) }) - 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" + It("should notice the change of the node label", func() { + predicate := worker.MachineNodeInfoHasChanged() + 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()) + Expect(predicate.Generic(genericEvent)).To(BeFalse()) + }) + + It("should not react when there are no changes of the node label", func() { + predicate := worker.MachineNodeInfoHasChanged() + 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()) Expect(predicate.Generic(genericEvent)).To(BeFalse()) }) - It("should not react when there is not specified Node in the Status", func() { - predicate := worker.MachineStatusHasChanged() + It("should not react when there is not specified node label", func() { + predicate := worker.MachineNodeInfoHasChanged() Expect(predicate.Create(createEvent)).To(BeTrue()) Expect(predicate.Update(updateEvent)).To(BeFalse()) Expect(predicate.Delete(deleteEvent)).To(BeTrue()) diff --git a/go.mod b/go.mod index 98c77159ea23..72ffa92554f7 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gardener/dependency-watchdog v0.7.0 github.com/gardener/etcd-druid v0.15.3 github.com/gardener/hvpa-controller/api v0.5.0 - github.com/gardener/machine-controller-manager v0.45.0 + github.com/gardener/machine-controller-manager v0.48.1 github.com/go-logr/logr v1.2.3 github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 diff --git a/go.sum b/go.sum index 71be407217f3..afb12eef3c20 100644 --- a/go.sum +++ b/go.sum @@ -244,8 +244,8 @@ github.com/gardener/hvpa-controller v0.0.0-20191014062307-fad3bdf06a25/go.mod h1 github.com/gardener/hvpa-controller/api v0.5.0 h1:f4F3O7YUrenwh4S3TgPREPiB287JjjUiUL18OqPLyAA= github.com/gardener/hvpa-controller/api v0.5.0/go.mod h1:QQl3ELkCaki+8RhXl0FZMfvnm0WCGwGJlGmrxJj6lvM= github.com/gardener/machine-controller-manager v0.27.0/go.mod h1:zlIxuLQMtRO+aXOFsG6qtYkBmggbWY82K7MSO051ARU= -github.com/gardener/machine-controller-manager v0.45.0 h1:rpf0PHRXJMGY93oMruNP+tnMawKJXhhzCACyNJsT8Lo= -github.com/gardener/machine-controller-manager v0.45.0/go.mod h1:+4j/6ab3jqbM6tM6FPtlajYgaJHM0xZ44ErOjCBlsP8= +github.com/gardener/machine-controller-manager v0.48.1 h1:Oxr5e6gRm7P40Ds4nGlga/0nmfF7cH4rOfjthR6Mm38= +github.com/gardener/machine-controller-manager v0.48.1/go.mod h1:Axeu1Oh3agySk0oR4T+FUNax41Ni2K8tuksu8KRHuh0= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/types.go b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/types.go index 2b2a817fe0aa..46e1d241b420 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/types.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/types.go @@ -167,9 +167,6 @@ type CurrentStatus struct { // MachineStatus holds the most recently observed status of Machine. type MachineStatus struct { - // Node string - Node string - // Conditions of this machine, same as node Conditions []corev1.NodeCondition diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machine_types.go b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machine_types.go index 4628562eceff..e0eb04f0a48c 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machine_types.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machine_types.go @@ -27,13 +27,20 @@ import ( // IF YOU MODIFY ANY OF THE TYPES HERE COPY THEM TO ../types.go // AND RUN ./hack/generate-code +// NodeLabelKey is the key for node label on machine object +const ( + NodeLabelKey string = "node" +) + // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:shortName="mc" // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.currentStatus.phase`,description="Current status of the machine." // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" // +kubebuilder:printcolumn:name="Node",type=string,JSONPath=`.metadata.labels.node`,description="Node backing the machine object" +// +kubebuilder:printcolumn:name="ProviderID",type=string,JSONPath=`.spec.providerID`,description="ProviderID of the infra instance backing the machine object",priority=1 // Machine is the representation of a physical or virtual machine. type Machine struct { @@ -95,9 +102,6 @@ type NodeTemplateSpec struct { // MachineStatus holds the most recently observed status of Machine. type MachineStatus struct { - // Node string - Node string `json:"node,omitempty"` - // Conditions of this machine, same as node Conditions []corev1.NodeCondition `json:"conditions,omitempty"` diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineclass_types.go b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineclass_types.go index 678175745338..6d525c3384c2 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineclass_types.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineclass_types.go @@ -27,6 +27,7 @@ import ( // +genclient // +genclient:noStatus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:shortName="mcc" // +kubebuilder:object:root=true // MachineClass can be used to templatize and re-use provider configuration diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machinedeployment_types.go b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machinedeployment_types.go index 6f5f49a3fec4..1161e7180ec3 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machinedeployment_types.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machinedeployment_types.go @@ -26,6 +26,7 @@ import ( // +genclient // +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:shortName="mcd" // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas @@ -34,7 +35,8 @@ import ( // +kubebuilder:printcolumn:name="Up-to-date",type=integer,JSONPath=`.status.updatedReplicas`,description="Total number of non-terminated machines targeted by this machine deployment that have the desired template spec." // +kubebuilder:printcolumn:name="Available",type=integer,JSONPath=`.status.availableReplicas`,description="Total number of available machines (ready for at least minReadySeconds) targeted by this machine deployment." // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata" -// Deployment enables declarative updates for machines and MachineSets. + +// MachineDeployment enables declarative updates for machines and MachineSets. type MachineDeployment struct { metav1.TypeMeta `json:",inline"` // Standard object metadata. @@ -96,7 +98,7 @@ type MachineDeploymentSpec struct { // process failed MachineDeployments and a condition with a ProgressDeadlineExceeded // reason will be surfaced in the MachineDeployment status. Note that progress will // not be estimated during the time a MachineDeployment is paused. This is not set - // by default. + // by default, which is treated as infinite deadline. // +optional ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty"` } @@ -217,8 +219,8 @@ const ( // Progressing means the MachineDeployment is progressing. Progress for a MachineDeployment is // considered when a new machine set is created or adopted, and when new machines scale - // up or old machines scale down. Progress is not estimated for paused MachineDeployments or - // when progressDeadlineSeconds is not specified. + // up or old machines scale down. Progress is not estimated for paused MachineDeployments. It is also updated + // if progressDeadlineSeconds is not specified(treated as infinite deadline), in which case it would never be updated to "false". MachineDeploymentProgressing MachineDeploymentConditionType = "Progressing" // ReplicaFailure is added in a MachineDeployment when one of its machines fails to be created diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineset_types.go b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineset_types.go index 6e349ed14a52..d2486e87f999 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineset_types.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/machineset_types.go @@ -23,6 +23,7 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +genclient:method=UpdateScale,verb=update,subresource=scale,input=k8s.io/api/autoscaling/v1.Scale,result=k8s.io/api/autoscaling/v1.Scale +// +kubebuilder:resource:shortName="mcs" // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/zz_generated.conversion.go b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/zz_generated.conversion.go index c7f8746e3e2f..c1d4a9a8aaa3 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/zz_generated.conversion.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1/zz_generated.conversion.go @@ -2547,7 +2547,6 @@ func Convert_machine_MachineSpec_To_v1alpha1_MachineSpec(in *machine.MachineSpec } func autoConvert_v1alpha1_MachineStatus_To_machine_MachineStatus(in *MachineStatus, out *machine.MachineStatus, s conversion.Scope) error { - out.Node = in.Node out.Conditions = *(*[]v1.NodeCondition)(unsafe.Pointer(&in.Conditions)) if err := Convert_v1alpha1_LastOperation_To_machine_LastOperation(&in.LastOperation, &out.LastOperation, s); err != nil { return err @@ -2565,7 +2564,6 @@ func Convert_v1alpha1_MachineStatus_To_machine_MachineStatus(in *MachineStatus, } func autoConvert_machine_MachineStatus_To_v1alpha1_MachineStatus(in *machine.MachineStatus, out *MachineStatus, s conversion.Scope) error { - out.Node = in.Node out.Conditions = *(*[]v1.NodeCondition)(unsafe.Pointer(&in.Conditions)) if err := Convert_machine_LastOperation_To_v1alpha1_LastOperation(&in.LastOperation, &out.LastOperation, s); err != nil { return err diff --git a/vendor/modules.txt b/vendor/modules.txt index 1f317c0d202a..838e9acf91d8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -99,8 +99,8 @@ github.com/gardener/etcd-druid/pkg/utils # github.com/gardener/hvpa-controller/api v0.5.0 ## explicit; go 1.15 github.com/gardener/hvpa-controller/api/v1alpha1 -# github.com/gardener/machine-controller-manager v0.45.0 -## explicit; go 1.17 +# github.com/gardener/machine-controller-manager v0.48.1 +## explicit; go 1.19 github.com/gardener/machine-controller-manager/pkg/apis/machine github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1 # github.com/ghodss/yaml v1.0.0