From 60844be81b4c400a58fb91b7c2a64ca93503dc63 Mon Sep 17 00:00:00 2001 From: Tobias Trabelsi Date: Tue, 7 Oct 2025 10:54:45 +0200 Subject: [PATCH] fix(): catch errors and increase verbosity --- internal/hetzner.go | 12 +++++++++--- internal/k8s.go | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/hetzner.go b/internal/hetzner.go index a61adc9..8e25869 100644 --- a/internal/hetzner.go +++ b/internal/hetzner.go @@ -18,11 +18,17 @@ func GetAllNodes(cfg *Config) ([]*hcloud.Server, error) { return nil, fmt.Errorf("error listing Hetzner Nodes: %s", err.Error()) } - if servers == nil { + if len(servers) == 0 { return nil, fmt.Errorf("no Nodes found with label selector: %s", cfg.LabelSelector) } - return servers, nil + for _, instance := range servers { + log.WithFields(log.Fields{ + "Caller": "GetAllNodes", + }).Info(fmt.Sprintf("Found server: %s", instance.Name)) + } + + return servers, nil } func GetAllIps(servers []*hcloud.Server) ([]string, error) { @@ -33,7 +39,7 @@ func GetAllIps(servers []*hcloud.Server) ([]string, error) { } log.WithFields(log.Fields{ "Caller": "GetAllIps", - }).Info(fmt.Sprintf("Found IP: %s", instance.PrivateNet[0].IP.String())) + }).Info(fmt.Sprintf("Found IP: %s", instance.PublicNet.IPv4.IP.String())) ips[i] = instance.PublicNet.IPv4.IP.String() } return ips, nil diff --git a/internal/k8s.go b/internal/k8s.go index 3001e7a..9973322 100644 --- a/internal/k8s.go +++ b/internal/k8s.go @@ -49,6 +49,11 @@ type CrdConfig struct { } func RecreateIPPoolCrd(cfg *Config, name string, ips []string) error { + + if len(ips) == 0 { + return fmt.Errorf("no IPs provided to create IP Pool CRD") + } + routeclient, err := createRestClient() if err != nil { return fmt.Errorf("error creating REST Client: %v", err.Error())