Merge pull request #1712 from MaxRink/fix/fix-annotations-nodelist

fix(manager): handle empty node list in annotations watcher
This commit is contained in:
Daniel Finneran
2026-09-02 17:26:22 +01:00
committed by GitHub
2 changed files with 24 additions and 0 deletions

View File

@@ -41,6 +41,9 @@ func annotationsWatcher(ctx context.Context, clientSet,
if err != nil {
return err
}
if len(nodeList.Items) == 0 {
return fmt.Errorf("no node found with hostname %q", config.NodeName)
}
// We'll assume there's only one node with the hostname annotation. If that's not true,
// there's probably bigger problems

View File

@@ -0,0 +1,21 @@
package manager
import (
"context"
"testing"
"github.com/kube-vip/kube-vip/pkg/kubevip"
"k8s.io/client-go/kubernetes/fake"
)
func TestAnnotationsWatcherHandlesEmptyNodeList(t *testing.T) {
client := fake.NewSimpleClientset()
config := &kubevip.Config{
NodeName: "node-a",
Annotations: "kube-vip.io",
}
if err := annotationsWatcher(context.Background(), client, client, config); err == nil {
t.Fatal("annotationsWatcher() error = nil, want empty node-list error")
}
}