EvenPodsSpread: api changes

This commit is contained in:
Wei Huang
2019-04-26 10:08:52 -07:00
parent 8d4c49faae
commit 49da505a9a
6 changed files with 333 additions and 1 deletions

View File

@@ -401,6 +401,11 @@ func dropDisabledFields(
// does not specify any values for these fields.
podSpec.PreemptionPolicy = nil
}
if !utilfeature.DefaultFeatureGate.Enabled(features.EvenPodsSpread) && !topologySpreadConstraintsInUse(oldPodSpec) {
// Set TopologySpreadConstraints to nil only if feature is disabled and it is not used
podSpec.TopologySpreadConstraints = nil
}
}
// dropDisabledRunAsGroupField removes disabled fields from PodSpec related
@@ -562,7 +567,14 @@ func overheadInUse(podSpec *api.PodSpec) bool {
return true
}
return false
}
// topologySpreadConstraintsInUse returns true if the pod spec is non-nil and has a TopologySpreadConstraints slice
func topologySpreadConstraintsInUse(podSpec *api.PodSpec) bool {
if podSpec == nil {
return false
}
return len(podSpec.TopologySpreadConstraints) > 0
}
// procMountInUse returns true if the pod spec is non-nil and has a SecurityContext's ProcMount field set to a non-default value