From 31659f6ccfd2c97aa04a4b5f5f5ccb8f29f946ba Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Mon, 30 Mar 2026 15:08:27 +0200 Subject: [PATCH] fix: use grep -w for exact IP matching in cluster node configuration When configuring cluster nodes, the grep command used to find node names by private IP would match IP prefixes as substrings (e.g., 10.0.1.8 matching 10.0.1.81), concatenating multiple node names with a newline. This caused kubectl to fail with "nodes not found" for the combined string. Add -w flag to grep for word-boundary matching, ensuring each IP matches only its exact occurrence in kubectl output. Fixes #756 Signed-off-by: Carlos Eduardo Arango Gutierrez --- pkg/provisioner/cluster.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/provisioner/cluster.go b/pkg/provisioner/cluster.go index 29a481e6..843babea 100644 --- a/pkg/provisioner/cluster.go +++ b/pkg/provisioner/cluster.go @@ -514,7 +514,7 @@ func (cp *ClusterProvisioner) configureNodes(firstCP NodeInfo, nodes []NodeInfo) fmt.Fprintf(&script, "echo 'Configuring control-plane node with IP %s...'\n", node.PrivateIP) // Get the actual node name from private IP - fmt.Fprintf(&script, "CP_NODE=$(sudo -E kubectl get nodes -o wide --no-headers | grep '%s' | awk '{print $1}')\n", node.PrivateIP) + fmt.Fprintf(&script, "CP_NODE=$(sudo -E kubectl get nodes -o wide --no-headers | grep -w '%s' | awk '{print $1}')\n", node.PrivateIP) script.WriteString("if [ -n \"$CP_NODE\" ]; then\n") // Apply control-plane labels @@ -547,7 +547,7 @@ func (cp *ClusterProvisioner) configureNodes(firstCP NodeInfo, nodes []NodeInfo) fmt.Fprintf(&script, "echo 'Configuring worker node with IP %s...'\n", node.PrivateIP) // Get the actual node name from private IP - fmt.Fprintf(&script, "WORKER_NODE=$(sudo -E kubectl get nodes -o wide --no-headers | grep '%s' | awk '{print $1}')\n", node.PrivateIP) + fmt.Fprintf(&script, "WORKER_NODE=$(sudo -E kubectl get nodes -o wide --no-headers | grep -w '%s' | awk '{print $1}')\n", node.PrivateIP) script.WriteString("if [ -n \"$WORKER_NODE\" ]; then\n") // Apply worker role label