From a76002f3ed71243a94e362193e88f89a098882a8 Mon Sep 17 00:00:00 2001 From: Himanshu Sharma <79965161+himanshu-kun@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:40:19 +0530 Subject: [PATCH] upgraded MCM to v0.50.1 (#104) --- MCM_VERSION | 2 +- go.mod | 2 +- go.sum | 4 ++-- .../pkg/util/provider/app/options/options.go | 2 +- .../provider/machinecontroller/machine_safety.go | 16 ++++++++++++++-- .../machinecontroller/machine_safety_util.go | 5 ++--- .../provider/machinecontroller/machine_util.go | 11 +++++++++-- vendor/modules.txt | 2 +- 8 files changed, 31 insertions(+), 13 deletions(-) diff --git a/MCM_VERSION b/MCM_VERSION index b9951683..341cba06 100644 --- a/MCM_VERSION +++ b/MCM_VERSION @@ -1 +1 @@ -v0.50.0 \ No newline at end of file +v0.50.1 \ No newline at end of file diff --git a/go.mod b/go.mod index 78eb3b9d..2a41fc28 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/ahmetb/gen-crd-api-reference-docs v0.3.0 github.com/gardener/gardener v1.79.0 - github.com/gardener/machine-controller-manager v0.50.0 + github.com/gardener/machine-controller-manager v0.50.1 github.com/gophercloud/gophercloud v1.7.0 github.com/gophercloud/utils v0.0.0-20230523080330-de873b9cf00d github.com/onsi/ginkgo v1.16.5 diff --git a/go.sum b/go.sum index cdc2ceec..17aac1a8 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gardener/gardener v1.79.0 h1:83jrXtTP1qjTLhulMq8loYKBWOls8SVhuFHQB2YHRzc= github.com/gardener/gardener v1.79.0/go.mod h1:lS1fCk8DxH+Lz3Ur26C49/gYu3R/WeJ+JLaIPBsNvls= -github.com/gardener/machine-controller-manager v0.50.0 h1:3dcQjzueFU1TGgprV00adjb3OCR99myTBx8DQGxywks= -github.com/gardener/machine-controller-manager v0.50.0/go.mod h1:RySZ40AgbNV/wMq60G/w49kb+okbj5Xs1A6usz5Pm/I= +github.com/gardener/machine-controller-manager v0.50.1 h1:lL2q0O+K6jkgYzHPz85wIc9MzASZaiDvLYnTxW7P5ws= +github.com/gardener/machine-controller-manager v0.50.1/go.mod h1:RySZ40AgbNV/wMq60G/w49kb+okbj5Xs1A6usz5Pm/I= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/app/options/options.go b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/app/options/options.go index 0a84289e..1f0ace6d 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/app/options/options.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/app/options/options.go @@ -70,7 +70,7 @@ func NewMCServer() *MCServer { MaxEvictRetries: drain.DefaultMaxEvictRetries, PvDetachTimeout: metav1.Duration{Duration: 2 * time.Minute}, PvReattachTimeout: metav1.Duration{Duration: 90 * time.Second}, - MachineSafetyOrphanVMsPeriod: metav1.Duration{Duration: 30 * time.Minute}, + MachineSafetyOrphanVMsPeriod: metav1.Duration{Duration: 15 * time.Minute}, MachineSafetyAPIServerStatusCheckPeriod: metav1.Duration{Duration: 1 * time.Minute}, MachineSafetyAPIServerStatusCheckTimeout: metav1.Duration{Duration: 30 * time.Second}, }, diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety.go b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety.go index d29133a5..23ce2e13 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety.go @@ -170,7 +170,7 @@ func (c *controller) AnnotateNodesUnmanagedByMCM(ctx context.Context) (machineut return machineutils.LongRetry, err } for _, node := range nodes { - _, err := c.getMachineFromNode(node.Name) + machine, err := c.getMachineFromNode(node.Name) if err != nil { if err == errMultipleMachineMatch { klog.Errorf("Couldn't fetch machine, Error: %s", err) @@ -193,11 +193,23 @@ func (c *controller) AnnotateNodesUnmanagedByMCM(ctx context.Context) (machineut machineutils.NotManagedByMCM: "1", } + klog.V(3).Infof("Adding NotManagedByMCM annotation to Node %q", node.Name) // err is returned only when node update fails - if err := c.updateNodeWithAnnotation(ctx, nodeCopy, annotations); err != nil { + if err := c.updateNodeWithAnnotations(ctx, nodeCopy, annotations); err != nil { return machineutils.MediumRetry, err } } + } else { + _, hasAnnot := node.Annotations[machineutils.NotManagedByMCM] + if !hasAnnot { + continue + } + klog.V(3).Infof("Removing NotManagedByMCM annotation from Node %q associated with Machine %q", node.Name, machine.Name) + nodeCopy := node.DeepCopy() + delete(nodeCopy.Annotations, machineutils.NotManagedByMCM) + if err := c.updateNodeWithAnnotations(ctx, nodeCopy, nil); err != nil { + return machineutils.MediumRetry, err + } } } diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety_util.go b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety_util.go index 0ab682f9..eb42593d 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety_util.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_safety_util.go @@ -22,7 +22,7 @@ import ( "k8s.io/klog/v2" ) -func (c *controller) updateNodeWithAnnotation(ctx context.Context, node *v1.Node, annotations map[string]string) error { +func (c *controller) updateNodeWithAnnotations(ctx context.Context, node *v1.Node, annotations map[string]string) error { // Initialize node annotations if empty if node.Annotations == nil { @@ -37,10 +37,9 @@ func (c *controller) updateNodeWithAnnotation(ctx context.Context, node *v1.Node _, err := c.targetCoreClient.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{}) if err != nil { - klog.Errorf("Couldn't patch the node %q , Error: %s", node.Name, err) + klog.Errorf("Failed to update annotations for Node %q due to error: %s", node.Name, err) return err } - klog.V(2).Infof("Annotated node %q was annotated with NotManagedByMCM successfully", node.Name) return nil } diff --git a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_util.go b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_util.go index 22be3ff6..a9b75e75 100644 --- a/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_util.go +++ b/vendor/github.com/gardener/machine-controller-manager/pkg/util/provider/machinecontroller/machine_util.go @@ -1022,7 +1022,13 @@ func (c *controller) drainNode(ctx context.Context, deleteMachineRequest *driver } } - klog.V(3).Infof("(drainNode) For node %q, machine %q, nodeReadyCondition: %s, readOnlyFileSystemCondition: %s", nodeName, machine.Name, nodeReadyCondition, readOnlyFileSystemCondition) + // verify and log node object's existence + if _, err := c.nodeLister.Get(nodeName); err == nil { + klog.V(3).Infof("(drainNode) For node %q, machine %q, nodeReadyCondition: %s, readOnlyFileSystemCondition: %s", nodeName, machine.Name, nodeReadyCondition, readOnlyFileSystemCondition) + } else if apierrors.IsNotFound(err) { + klog.Warningf("(drainNode) Node %q for machine %q doesn't exist, so drain will finish instantly", nodeName, machine.Name) + } + if !isConditionEmpty(nodeReadyCondition) && (nodeReadyCondition.Status != v1.ConditionTrue) && (time.Since(nodeReadyCondition.LastTransitionTime.Time) > nodeNotReadyDuration) { message := "Setting forceDeletePods & forceDeleteMachine to true for drain as machine is NotReady for over 5min" forceDeleteMachine = true @@ -1502,12 +1508,13 @@ func (c *controller) canMarkMachineFailed(machineDeployName, machineName, namesp } } - klog.V(2).Infof("machineDeployName=%q for machine=%q , terminating=%d , failed=%d , pending=%d , noPhase=%d , crashLooping=%d , extraCountedProgress=%d", machineDeployName, machineName, terminating, failed, pending, noPhase, crashLooping, terminating) + klog.V(2).Infof("Performing rate-limit check for machine=%q. Under machineDeployment=%q : terminating=%d , failed=%d , pending=%d , noPhase=%d , crashLooping=%d , extraCountedProgress=%d", machineName, machineDeployName, terminating, failed, pending, noPhase, crashLooping, terminating) if inProgress < maxReplacements { klog.V(2).Infof("Number of goroutines now %d\n", runtime.NumGoroutine()) return true, nil } + klog.V(2).Infof("Cannot mark `Unknown` machine=%q as `Failed` as max rate-limit reached for machineDeployment=%q. maxAllowedReplacements=%d and inProgressReplacements=%d", machineName, machineDeployName, maxReplacements, inProgress) return false, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 5ee2b102..b9f03f71 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -71,7 +71,7 @@ github.com/fsnotify/fsnotify github.com/gardener/gardener/hack github.com/gardener/gardener/hack/.ci github.com/gardener/gardener/hack/api-reference/template -# github.com/gardener/machine-controller-manager v0.50.0 +# github.com/gardener/machine-controller-manager v0.50.1 ## explicit; go 1.20 github.com/gardener/machine-controller-manager/pkg/apis/machine github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1