Skip to content

Commit 90a9f14

Browse files
committed
fixup! fix: let CAPI default Service CIDR
1 parent c97c129 commit 90a9f14

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

api/v1alpha1/constants.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,4 @@ const (
4040
DNSVariableName = "dns"
4141

4242
ClusterUUIDAnnotationKey = APIGroup + "/cluster-uuid"
43-
44-
// DefaultServicesSubnet defines default service subnet range used by kubeadm in CAPI
45-
DefaultServicesSubnet = "10.96.0.0/12"
4643
)

pkg/handlers/generic/lifecycle/registry/utils/ip.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99

1010
netutils "k8s.io/utils/net"
1111
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
12-
13-
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
1412
)
1513

1614
const ipIndex = 20
@@ -29,10 +27,6 @@ func ServiceIPForCluster(cluster *clusterv1.Cluster) (string, error) {
2927
}
3028

3129
func getServiceIP(serviceSubnetStrings []string) (string, error) {
32-
if len(serviceSubnetStrings) == 0 {
33-
serviceSubnetStrings = []string{v1alpha1.DefaultServicesSubnet}
34-
}
35-
3630
serviceSubnets, err := netutils.ParseCIDRs(serviceSubnetStrings)
3731
if err != nil {
3832
return "", fmt.Errorf("unable to parse service Subnets: %w", err)

pkg/handlers/generic/lifecycle/registry/utils/ip_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package utils
55

66
import (
7+
"errors"
78
"testing"
89

910
"github.com/stretchr/testify/assert"
@@ -17,6 +18,7 @@ func Test_ServiceIPForCluster(t *testing.T) {
1718
name string
1819
cluster *clusterv1.Cluster
1920
want string
21+
wantErr error
2022
}{
2123
{
2224
name: "Cluster with nil service CIDR",
@@ -25,7 +27,7 @@ func Test_ServiceIPForCluster(t *testing.T) {
2527
ClusterNetwork: &clusterv1.ClusterNetwork{},
2628
},
2729
},
28-
want: "10.96.0.20",
30+
wantErr: errors.New("error getting a service IP for a cluster: unexpected empty service Subnets"),
2931
},
3032
{
3133
name: "Cluster with empty service CIDR slice",
@@ -38,7 +40,7 @@ func Test_ServiceIPForCluster(t *testing.T) {
3840
},
3941
},
4042
},
41-
want: "10.96.0.20",
43+
wantErr: errors.New("error getting a service IP for a cluster: unexpected empty service Subnets"),
4244
},
4345
{
4446
name: "Cluster with a single service CIDR",
@@ -76,7 +78,11 @@ func Test_ServiceIPForCluster(t *testing.T) {
7678
t.Run(tt.name, func(t *testing.T) {
7779
t.Parallel()
7880
got, err := ServiceIPForCluster(tt.cluster)
79-
require.NoError(t, err)
81+
if tt.wantErr != nil {
82+
require.EqualError(t, err, tt.wantErr.Error())
83+
} else {
84+
require.NoError(t, err)
85+
}
8086
assert.Equal(t, tt.want, got)
8187
})
8288
}

0 commit comments

Comments
 (0)