Skip to content

Commit

Permalink
[dhctl] Converge. Skip remove labels if node was not found (#10658)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Mitrofanov <[email protected]>
  • Loading branch information
name212 authored Nov 14, 2024
1 parent a1ea398 commit 8041efa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dhctl/pkg/kubernetes/actions/converge/converge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 8041efa

Please sign in to comment.