From bd8ed8a036bb5eba06ffc0c0d49e85ed1d47e0eb Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Aug 2026 10:27:45 +0200 Subject: [PATCH] fix: handle empty port in HCP LoadBalancer URL causing strconv.Atoi failure (#1134) * fix: handle empty port in HCP mode LoadBalancer URL parsing Assisted-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * fix lint --------- Co-authored-by: Enrico Candino --- pkg/controller/cluster/hcp.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/controller/cluster/hcp.go b/pkg/controller/cluster/hcp.go index 4cbe5679..2f6b157c 100644 --- a/pkg/controller/cluster/hcp.go +++ b/pkg/controller/cluster/hcp.go @@ -1,6 +1,7 @@ package cluster import ( + "cmp" "context" "fmt" "net" @@ -55,7 +56,9 @@ func (c *ClusterReconciler) ensureHCPKubernetesEndpointSlice(ctx context.Context return err } - port, err := strconv.Atoi(url.Port()) + portStr := cmp.Or(url.Port(), "443") + + port, err := strconv.Atoi(portStr) if err != nil { return err } @@ -148,7 +151,9 @@ func (c *ClusterReconciler) ensureHCPKubernetesEndpoints(ctx context.Context, cl }, } - port, err := strconv.Atoi(url.Port()) + portStr := cmp.Or(url.Port(), "443") + + port, err := strconv.Atoi(portStr) if err != nil { return err }