Skip to content

Commit

Permalink
fix(nodecontroller) ignore deleted nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
defo89 committed Mar 27, 2024
1 parent 2010d97 commit becaf27
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/node/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/sapcc/go-pmtud/internal/config"
"github.com/sapcc/go-pmtud/internal/metrics"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"strings"
Expand Down Expand Up @@ -39,7 +40,12 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
var node = corev1.Node{}
err := r.Client.Get(ctx, request.NamespacedName, &node)
if err != nil {
log.Error(err, "error getting node")
if errors.IsNotFound(err) {
log.Info("node not found, skip", "node", request.NamespacedName)
// Node could have been deleted
return reconcile.Result{}, nil
}
log.Error(err, "error getting node", "node", request.NamespacedName)
return reconcile.Result{}, err
}
if len(node.Status.Addresses) == 0 {
Expand Down

0 comments on commit becaf27

Please sign in to comment.