Skip to content

Commit 5fbfe32

Browse files
Merge pull request #18669 from JacobTanenbaum/BZ1534779
Automatic merge from submit-queue. Remove requirement of having deprecated clusterNetworkCIDR/hostSubnetLength in master.networkConfig Currently in order for openshift to start the first entry in clusterNetworks and the old clusterNetworkCIDR/hostSubnetLength have to match. Change it so the older clusterNetworkCIDR/hostSubnetLength fields are no longer required. Bug [1534779](https://bugzilla.redhat.com/show_bug.cgi?id=1534779)
2 parents 3c4eb72 + e5b0d93 commit 5fbfe32

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

pkg/cmd/server/apis/config/serialization_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,15 @@ func fuzzInternalObject(t *testing.T, forVersion schema.GroupVersion, item runti
133133
obj.NetworkConfig.DeprecatedClusterNetworkCIDR = obj.NetworkConfig.ClusterNetworks[0].CIDR
134134
obj.NetworkConfig.DeprecatedHostSubnetLength = obj.NetworkConfig.ClusterNetworks[0].HostSubnetLength
135135
} else {
136-
obj.NetworkConfig.ClusterNetworks = nil
137136
obj.NetworkConfig.DeprecatedClusterNetworkCIDR = ""
138137
obj.NetworkConfig.DeprecatedHostSubnetLength = 0
138+
clusterNetwork := []configapi.ClusterNetworkEntry{
139+
{
140+
CIDR: obj.NetworkConfig.DeprecatedClusterNetworkCIDR,
141+
HostSubnetLength: obj.NetworkConfig.DeprecatedHostSubnetLength,
142+
},
143+
}
144+
obj.NetworkConfig.ClusterNetworks = clusterNetwork
139145
}
140146

141147
// TODO stop duplicating the conversion in the test.

pkg/cmd/server/apis/config/v1/conversions.go

+7-21
Original file line numberDiff line numberDiff line change
@@ -399,31 +399,17 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
399399
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
400400
return err
401401
}
402-
if len(in.DeprecatedClusterNetworkCIDR) > 0 || in.DeprecatedHostSubnetLength > 0 {
403-
if len(out.ClusterNetworks) > 0 {
404-
out.ClusterNetworks[0].CIDR = in.DeprecatedClusterNetworkCIDR
405-
out.ClusterNetworks[0].HostSubnetLength = in.DeprecatedHostSubnetLength
406-
} else {
407-
out.ClusterNetworks = []internal.ClusterNetworkEntry{
408-
{
409-
CIDR: in.DeprecatedClusterNetworkCIDR,
410-
HostSubnetLength: in.DeprecatedHostSubnetLength,
411-
},
412-
}
402+
403+
if len(out.ClusterNetworks) == 0 {
404+
out.ClusterNetworks = []internal.ClusterNetworkEntry{
405+
{
406+
CIDR: in.DeprecatedClusterNetworkCIDR,
407+
HostSubnetLength: in.DeprecatedHostSubnetLength,
408+
},
413409
}
414410
}
415411
return nil
416412
},
417-
func(in *internal.MasterNetworkConfig, out *MasterNetworkConfig, s conversion.Scope) error {
418-
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
419-
return err
420-
}
421-
if len(in.ClusterNetworks) > 0 {
422-
out.DeprecatedHostSubnetLength = in.ClusterNetworks[0].HostSubnetLength
423-
out.DeprecatedClusterNetworkCIDR = in.ClusterNetworks[0].CIDR
424-
}
425-
return nil
426-
},
427413
func(in *AuditConfig, out *internal.AuditConfig, s conversion.Scope) error {
428414
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
429415
return err

pkg/cmd/server/apis/config/v1/testdata/master-config.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ masterClients:
132132
openshiftLoopbackKubeConfig: ""
133133
masterPublicURL: ""
134134
networkConfig:
135-
clusterNetworks: null
135+
clusterNetworks:
136+
- cidr: ""
137+
hostSubnetLength: 0
136138
externalIPNetworkCIDRs: null
137139
ingressIPNetworkCIDR: 172.29.0.0/16
138140
networkPluginName: ""

pkg/cmd/server/apis/config/validation/master.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,22 @@ func ValidateIngressIPNetworkCIDR(config *configapi.MasterConfig, fldPath *field
740740
func ValidateDeprecatedClusterNetworkConfig(config *configapi.MasterConfig, fldPath *field.Path) ValidationResults {
741741
validationResults := ValidationResults{}
742742

743-
if len(config.NetworkConfig.ClusterNetworks) > 0 && config.NetworkConfig.DeprecatedHostSubnetLength != config.NetworkConfig.ClusterNetworks[0].HostSubnetLength {
744-
validationResults.AddErrors(field.Invalid(fldPath.Child("hostSubnetLength"), config.NetworkConfig.DeprecatedHostSubnetLength, "cannot set hostSubnetLength and clusterNetworks, please use clusterNetworks"))
745-
}
746-
if len(config.NetworkConfig.ClusterNetworks) > 0 && config.NetworkConfig.DeprecatedClusterNetworkCIDR != config.NetworkConfig.ClusterNetworks[0].CIDR {
747-
validationResults.AddErrors(field.Invalid(fldPath.Child("clusterNetworkCIDR"), config.NetworkConfig.DeprecatedClusterNetworkCIDR, "cannot set clusterNetworkCIDR and clusterNetworks, please use clusterNetworks"))
743+
if len(config.NetworkConfig.ClusterNetworks) > 1 {
744+
if config.NetworkConfig.DeprecatedHostSubnetLength != 0 {
745+
validationResults.AddErrors(field.Invalid(fldPath.Child("hostSubnetLength"), config.NetworkConfig.DeprecatedHostSubnetLength, "cannot set hostSubnetLength and clusterNetworks, please use clusterNetworks"))
746+
}
747+
if len(config.NetworkConfig.DeprecatedClusterNetworkCIDR) != 0 {
748+
validationResults.AddErrors(field.Invalid(fldPath.Child("clusterNetworkCIDR"), config.NetworkConfig.DeprecatedClusterNetworkCIDR, "cannot set clusterNetworkCIDR and clusterNetworks, please use clusterNetworks"))
749+
}
750+
751+
} else if len(config.NetworkConfig.ClusterNetworks) == 1 {
752+
if config.NetworkConfig.DeprecatedHostSubnetLength != config.NetworkConfig.ClusterNetworks[0].HostSubnetLength && config.NetworkConfig.DeprecatedHostSubnetLength != 0 {
753+
validationResults.AddErrors(field.Invalid(fldPath.Child("hostSubnetLength"), config.NetworkConfig.DeprecatedHostSubnetLength, "cannot set hostSubnetLength and clusterNetworks, please use clusterNetworks"))
754+
}
755+
if config.NetworkConfig.DeprecatedClusterNetworkCIDR != config.NetworkConfig.ClusterNetworks[0].CIDR && len(config.NetworkConfig.DeprecatedClusterNetworkCIDR) != 0 {
756+
validationResults.AddErrors(field.Invalid(fldPath.Child("clusterNetworkCIDR"), config.NetworkConfig.DeprecatedClusterNetworkCIDR, "cannot set clusterNetworkCIDR and clusterNetworks, please use clusterNetworks"))
757+
}
748758
}
759+
749760
return validationResults
750761
}

0 commit comments

Comments
 (0)