Skip to content

Commit

Permalink
Revert "Forbid multiple machine networks in single-stack clusters"
Browse files Browse the repository at this point in the history
Allow users to specify multiple machine networks of the same address
family. This is a documented and supported feature of OpenShift.

This reverts commit 873dd81.
  • Loading branch information
zaneb committed Sep 3, 2024
1 parent c559bcb commit f4fcd28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 32 deletions.
46 changes: 19 additions & 27 deletions internal/bminventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4819,9 +4819,9 @@ var _ = Describe("cluster", func() {

Context("Networks", func() {
var (
clusterNetworks = common.TestIPv4Networking.ClusterNetworks
serviceNetworks = common.TestIPv4Networking.ServiceNetworks
machineNetworks = common.TestIPv4Networking.MachineNetworks
clusterNetworks = []*models.ClusterNetwork{{Cidr: "1.1.0.0/24", HostPrefix: 24}, {Cidr: "2.2.0.0/24", HostPrefix: 24}}
serviceNetworks = []*models.ServiceNetwork{{Cidr: "3.3.0.0/24"}, {Cidr: "4.4.0.0/24"}}
machineNetworks = []*models.MachineNetwork{{Cidr: "5.5.0.0/24"}, {Cidr: "6.6.0.0/24"}}
)

setNetworksClusterID := func(clusterID strfmt.UUID,
Expand Down Expand Up @@ -5010,22 +5010,16 @@ var _ = Describe("cluster", func() {
verifyApiErrorString(reply, http.StatusBadRequest, "Machine network CIDR '': Failed to parse CIDR '': invalid CIDR address: ")
})

It("Multiple machine networks illegal for single-stack", func() {
reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{
ClusterID: clusterID,
ClusterUpdateParams: &models.V2ClusterUpdateParams{
MachineNetworks: []*models.MachineNetwork{{Cidr: "15.15.0.0/21"}, {Cidr: "16.16.0.0/21"}},
},
})
verifyApiErrorString(reply, http.StatusBadRequest, "Single-stack cluster cannot contain multiple Machine Networks")
})
It("Override networks - additional subnet", func() {
clusterNetworks = []*models.ClusterNetwork{{Cidr: "11.11.0.0/21", HostPrefix: 24}, {Cidr: "12.12.0.0/21", HostPrefix: 24}}
serviceNetworks = []*models.ServiceNetwork{{Cidr: "13.13.0.0/21"}, {Cidr: "14.14.0.0/21"}}
machineNetworks = []*models.MachineNetwork{{Cidr: "15.15.0.0/21"}, {Cidr: "16.16.0.0/21"}}

It("Override networks - additional cluster subnet", func() {
mockSuccess(1)
reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{
ClusterID: clusterID,
ClusterUpdateParams: &models.V2ClusterUpdateParams{
ClusterNetworks: []*models.ClusterNetwork{{Cidr: "11.11.0.0/21", HostPrefix: 24}, {Cidr: "12.12.0.0/21", HostPrefix: 24}},
ClusterNetworks: clusterNetworks,
ServiceNetworks: serviceNetworks,
MachineNetworks: machineNetworks,
VipDhcpAllocation: swag.Bool(true),
Expand All @@ -5034,19 +5028,20 @@ var _ = Describe("cluster", func() {
Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated()))
actual := reply.(*installer.V2UpdateClusterCreated)

validateNetworkConfiguration(actual.Payload,
&[]*models.ClusterNetwork{{Cidr: "11.11.0.0/21", HostPrefix: 24}, {Cidr: "12.12.0.0/21", HostPrefix: 24}},
&serviceNetworks,
&machineNetworks)
validateNetworkConfiguration(actual.Payload, &clusterNetworks, &serviceNetworks, &machineNetworks)
validateHostsRequestedHostname(actual.Payload)
})

It("Override networks - 2 additional cluster subnets", func() {
It("Override networks - 2 additional subnets", func() {
clusterNetworks = []*models.ClusterNetwork{{Cidr: "10.10.0.0/21", HostPrefix: 24}, {Cidr: "11.11.0.0/21", HostPrefix: 24}, {Cidr: "12.12.0.0/21", HostPrefix: 24}}
serviceNetworks = []*models.ServiceNetwork{{Cidr: "13.13.0.0/21"}, {Cidr: "14.14.0.0/21"}}
machineNetworks = []*models.MachineNetwork{{Cidr: "15.15.0.0/21"}, {Cidr: "16.16.0.0/21"}}

mockSuccess(1)
reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{
ClusterID: clusterID,
ClusterUpdateParams: &models.V2ClusterUpdateParams{
ClusterNetworks: []*models.ClusterNetwork{{Cidr: "10.10.0.0/21", HostPrefix: 24}, {Cidr: "11.11.0.0/21", HostPrefix: 24}, {Cidr: "12.12.0.0/21", HostPrefix: 24}},
ClusterNetworks: clusterNetworks,
ServiceNetworks: serviceNetworks,
MachineNetworks: machineNetworks,
VipDhcpAllocation: swag.Bool(true),
Expand All @@ -5055,10 +5050,7 @@ var _ = Describe("cluster", func() {
Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated()))
actual := reply.(*installer.V2UpdateClusterCreated)

validateNetworkConfiguration(actual.Payload,
&[]*models.ClusterNetwork{{Cidr: "10.10.0.0/21", HostPrefix: 24}, {Cidr: "11.11.0.0/21", HostPrefix: 24}, {Cidr: "12.12.0.0/21", HostPrefix: 24}},
&serviceNetworks,
&machineNetworks)
validateNetworkConfiguration(actual.Payload, &clusterNetworks, &serviceNetworks, &machineNetworks)
validateHostsRequestedHostname(actual.Payload)
})

Expand Down Expand Up @@ -14922,9 +14914,9 @@ var _ = Describe("TestRegisterCluster", func() {

Context("Networking", func() {
var (
clusterNetworks = common.TestIPv4Networking.ClusterNetworks
serviceNetworks = common.TestIPv4Networking.ServiceNetworks
machineNetworks = common.TestIPv4Networking.MachineNetworks
clusterNetworks = []*models.ClusterNetwork{{Cidr: "1.1.1.0/24", HostPrefix: 24}, {Cidr: "2.2.2.0/24", HostPrefix: 24}}
serviceNetworks = []*models.ServiceNetwork{{Cidr: "3.3.3.0/24"}, {Cidr: "4.4.4.0/24"}}
machineNetworks = []*models.MachineNetwork{{Cidr: "5.5.5.0/24"}, {Cidr: "6.6.6.0/24"}, {Cidr: "7.7.7.0/24"}}
)

registerCluster := func() *models.Cluster {
Expand Down
5 changes: 0 additions & 5 deletions internal/cluster/validations/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,6 @@ func ValidateDualStackNetworks(clusterParams interface{}, alreadyDualStack bool)
return err
}
}
} else {
if len(machineNetworks) > 1 {
err := errors.Errorf("Single-stack cluster cannot contain multiple Machine Networks")
return err
}
}
return nil
}
Expand Down

0 comments on commit f4fcd28

Please sign in to comment.