Skip to content

Commit 3f14b50

Browse files
committed
fix: do not error out if control plane endpoint is hostname
1 parent cbd2591 commit 3f14b50

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

pkg/webhook/cluster/nutanix_validator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ func checkIfPrismCentralAndControlPlaneIPSame(
153153
controlPlaneEndpointSpec.ControlPlaneEndpointIP(),
154154
)
155155
if err != nil {
156-
// controlPlaneEndpointIP is strictly accepted as an IP address from user so
157-
// if it is not an IP address, it is invalid.
158-
return fmt.Errorf("invalid Nutanix control plane endpoint IP: %w", err)
156+
// If controlPlaneEndpointIP is a hostname, we cannot compare it with PC IP
157+
// so return directly.
158+
return nil
159159
}
160160

161161
pcHostname, _, err := pcEndpoint.ParseURL()

pkg/webhook/cluster/nutanix_validator_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,14 @@ func TestCheckIfPrismCentralAndControlPlaneIPSame(t *testing.T) {
144144
),
145145
},
146146
{
147-
name: "Invalid Control Plane IP",
147+
name: "Control Plane IP specified as hostname",
148148
pcEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{
149149
URL: "https://192.168.1.1:9440",
150150
},
151151
controlPlaneEndpointSpec: v1alpha1.ControlPlaneEndpointSpec{
152-
Host: "invalid-ip",
152+
Host: "dummy-hostname",
153153
},
154-
expectedErr: fmt.Errorf(
155-
"invalid Nutanix control plane endpoint IP: ParseAddr(%q): unable to parse IP",
156-
"invalid-ip",
157-
),
154+
expectedErr: nil,
158155
},
159156
{
160157
name: "Invalid Prism Central URL",
@@ -199,7 +196,7 @@ func TestCheckIfPrismCentralAndControlPlaneIPSame(t *testing.T) {
199196
),
200197
},
201198
{
202-
name: "With KubeVIP ovveride and different PC and Control Plane IPs",
199+
name: "With KubeVIP override and different PC and Control Plane IPs",
203200
pcEndpoint: v1alpha1.NutanixPrismCentralEndpointSpec{
204201
URL: "https://192.168.1.2:9440",
205202
},

0 commit comments

Comments
 (0)