From 8041efa066fdfa9d79d38189202fa11ff204a5d4 Mon Sep 17 00:00:00 2001 From: Nikolay Mitrofanov <30695496+name212@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:37:28 +0300 Subject: [PATCH] [dhctl] Converge. Skip remove labels if node was not found (#10658) Signed-off-by: Nikolay Mitrofanov --- dhctl/pkg/kubernetes/actions/converge/converge.go | 2 ++ .../pkg/operations/converge/infra/hook/controlplane/drain.go | 1 + .../infra/hook/controlplane/hook_for_destroy_pipeline.go | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/dhctl/pkg/kubernetes/actions/converge/converge.go b/dhctl/pkg/kubernetes/actions/converge/converge.go index 70a6cf3e69..f5b2f1a8fe 100644 --- a/dhctl/pkg/kubernetes/actions/converge/converge.go +++ b/dhctl/pkg/kubernetes/actions/converge/converge.go @@ -144,6 +144,8 @@ func (r *Runner) RunConverge() error { if err != nil { return fmt.Errorf("failed to start lock runner: %w", err) } + + return nil } return r.converge() diff --git a/dhctl/pkg/operations/converge/infra/hook/controlplane/drain.go b/dhctl/pkg/operations/converge/infra/hook/controlplane/drain.go index 267576f458..1700bb790d 100644 --- a/dhctl/pkg/operations/converge/infra/hook/controlplane/drain.go +++ b/dhctl/pkg/operations/converge/infra/hook/controlplane/drain.go @@ -40,6 +40,7 @@ func drainNode(kubeCl *client.KubernetesClient, nodeName string) error { node, err := kubeCl.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{}) if err != nil { if errors.IsNotFound(err) { + log.InfoF("Node '%s' has been deleted. Skip\n", nodeName) return nil } diff --git a/dhctl/pkg/operations/converge/infra/hook/controlplane/hook_for_destroy_pipeline.go b/dhctl/pkg/operations/converge/infra/hook/controlplane/hook_for_destroy_pipeline.go index 3d30e2c87f..16c715b206 100644 --- a/dhctl/pkg/operations/converge/infra/hook/controlplane/hook_for_destroy_pipeline.go +++ b/dhctl/pkg/operations/converge/infra/hook/controlplane/hook_for_destroy_pipeline.go @@ -22,6 +22,7 @@ import ( "time" flantkubeclient "github.com/flant/kube-client/client" + "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -102,6 +103,10 @@ func removeLabelsFromNode(kubeCl *client.KubernetesClient, nodeName string, labe return retry.NewLoop(fmt.Sprintf("Remove labels from node %s", nodeName), 45, 5*time.Second).Run(func() error { node, err := kubeCl.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{}) if err != nil { + if errors.IsNotFound(err) { + log.InfoF("Node '%s' has been deleted. Skip\n", nodeName) + return nil + } return err }