Skip to content

Commit fc81236

Browse files
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
1 parent 1c7e352 commit fc81236

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

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

+7-21
Original file line numberDiff line numberDiff line change
@@ -392,31 +392,17 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
392392
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
393393
return err
394394
}
395-
if len(in.DeprecatedClusterNetworkCIDR) > 0 || in.DeprecatedHostSubnetLength > 0 {
396-
if len(out.ClusterNetworks) > 0 {
397-
out.ClusterNetworks[0].CIDR = in.DeprecatedClusterNetworkCIDR
398-
out.ClusterNetworks[0].HostSubnetLength = in.DeprecatedHostSubnetLength
399-
} else {
400-
out.ClusterNetworks = []internal.ClusterNetworkEntry{
401-
{
402-
CIDR: in.DeprecatedClusterNetworkCIDR,
403-
HostSubnetLength: in.DeprecatedHostSubnetLength,
404-
},
405-
}
395+
396+
if len(out.ClusterNetworks) == 0 {
397+
out.ClusterNetworks = []internal.ClusterNetworkEntry{
398+
{
399+
CIDR: in.DeprecatedClusterNetworkCIDR,
400+
HostSubnetLength: in.DeprecatedHostSubnetLength,
401+
},
406402
}
407403
}
408404
return nil
409405
},
410-
func(in *internal.MasterNetworkConfig, out *MasterNetworkConfig, s conversion.Scope) error {
411-
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
412-
return err
413-
}
414-
if len(in.ClusterNetworks) > 0 {
415-
out.DeprecatedHostSubnetLength = in.ClusterNetworks[0].HostSubnetLength
416-
out.DeprecatedClusterNetworkCIDR = in.ClusterNetworks[0].CIDR
417-
}
418-
return nil
419-
},
420406

421407
metav1.Convert_resource_Quantity_To_resource_Quantity,
422408
metav1.Convert_bool_To_Pointer_bool,

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

+19-5
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,25 @@ func ValidateIngressIPNetworkCIDR(config *configapi.MasterConfig, fldPath *field
719719
func ValidateDeprecatedClusterNetworkConfig(config *configapi.MasterConfig, fldPath *field.Path) ValidationResults {
720720
validationResults := ValidationResults{}
721721

722-
if len(config.NetworkConfig.ClusterNetworks) > 0 && config.NetworkConfig.DeprecatedHostSubnetLength != config.NetworkConfig.ClusterNetworks[0].HostSubnetLength {
723-
validationResults.AddErrors(field.Invalid(fldPath.Child("hostSubnetLength"), config.NetworkConfig.DeprecatedHostSubnetLength, "cannot set hostSubnetLength and clusterNetworks, please use clusterNetworks"))
724-
}
725-
if len(config.NetworkConfig.ClusterNetworks) > 0 && config.NetworkConfig.DeprecatedClusterNetworkCIDR != config.NetworkConfig.ClusterNetworks[0].CIDR {
726-
validationResults.AddErrors(field.Invalid(fldPath.Child("clusterNetworkCIDR"), config.NetworkConfig.DeprecatedClusterNetworkCIDR, "cannot set clusterNetworkCIDR and clusterNetworks, please use clusterNetworks"))
722+
fmt.Printf("KEYWORD: len(config.NetworkConfig.ClusterNetworks)=%d\n", len(config.NetworkConfig.ClusterNetworks))
723+
if len(config.NetworkConfig.ClusterNetworks) > 1 {
724+
if config.NetworkConfig.DeprecatedHostSubnetLength != 0 {
725+
validationResults.AddErrors(field.Invalid(fldPath.Child("hostSubnetLength"), config.NetworkConfig.DeprecatedHostSubnetLength, "cannot set hostSubnetLength and clusterNetworks, please use clusterNetworks"))
726+
}
727+
if len(config.NetworkConfig.DeprecatedClusterNetworkCIDR) != 0 {
728+
validationResults.AddErrors(field.Invalid(fldPath.Child("clusterNetworkCIDR"), config.NetworkConfig.DeprecatedClusterNetworkCIDR, "cannot set clusterNetworkCIDR and clusterNetworks, please use clusterNetworks"))
729+
}
730+
731+
} else if len(config.NetworkConfig.ClusterNetworks) == 1 {
732+
fmt.Printf("KEYWORD: I THINK YOU ARE HERE!\n")
733+
if config.NetworkConfig.DeprecatedHostSubnetLength != config.NetworkConfig.ClusterNetworks[0].HostSubnetLength && config.NetworkConfig.DeprecatedHostSubnetLength != 0 {
734+
fmt.Printf("\tKEYWORD: condif.NetworkConfig.DeprecatedHostsubnetLength: %d\n\tKEYWORD:config.NetworkConfig.ClusterNEtworks[0].HostSubnetLength:%d\n", config.NetworkConfig.DeprecatedHostSubnetLength, config.NetworkConfig.ClusterNetworks[0].HostSubnetLength)
735+
validationResults.AddErrors(field.Invalid(fldPath.Child("hostSubnetLength"), config.NetworkConfig.DeprecatedHostSubnetLength, "cannot set hostSubnetLength and clusterNetworks, please use clusterNetworks"))
736+
}
737+
if config.NetworkConfig.DeprecatedClusterNetworkCIDR != config.NetworkConfig.ClusterNetworks[0].CIDR && len(config.NetworkConfig.DeprecatedClusterNetworkCIDR) != 0 {
738+
validationResults.AddErrors(field.Invalid(fldPath.Child("clusterNetworkCIDR"), config.NetworkConfig.DeprecatedClusterNetworkCIDR, "cannot set clusterNetworkCIDR and clusterNetworks, please use clusterNetworks"))
739+
}
727740
}
741+
728742
return validationResults
729743
}

0 commit comments

Comments
 (0)