mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
AllowExpandedDNSConfig if haveSameExpandedDNSConfig(newPod, oldPod)
This commit is contained in:
@@ -390,6 +390,37 @@ func usesIndivisibleHugePagesValues(podSpec *api.PodSpec) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// haveSameExpandedDNSConfig returns true if the oldPodSpec already had
|
||||
// ExpandedDNSConfig and podSpec has the same DNSConfig
|
||||
func haveSameExpandedDNSConfig(podSpec, oldPodSpec *api.PodSpec) bool {
|
||||
if oldPodSpec == nil || oldPodSpec.DNSConfig == nil {
|
||||
return false
|
||||
}
|
||||
if podSpec == nil || podSpec.DNSConfig == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(oldPodSpec.DNSConfig.Searches) <= apivalidation.MaxDNSSearchPathsLegacy &&
|
||||
len(strings.Join(oldPodSpec.DNSConfig.Searches, " ")) <= apivalidation.MaxDNSSearchListCharsLegacy {
|
||||
// didn't have ExpandedDNSConfig
|
||||
return false
|
||||
}
|
||||
|
||||
if len(oldPodSpec.DNSConfig.Searches) != len(podSpec.DNSConfig.Searches) {
|
||||
// updates DNSConfig
|
||||
return false
|
||||
}
|
||||
|
||||
for i, oldSearch := range oldPodSpec.DNSConfig.Searches {
|
||||
if podSpec.DNSConfig.Searches[i] != oldSearch {
|
||||
// updates DNSConfig
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetValidationOptionsFromPodSpecAndMeta returns validation options based on pod specs and metadata
|
||||
func GetValidationOptionsFromPodSpecAndMeta(podSpec, oldPodSpec *api.PodSpec, podMeta, oldPodMeta *metav1.ObjectMeta) apivalidation.PodValidationOptions {
|
||||
// default pod validation options based on feature gate
|
||||
@@ -403,7 +434,7 @@ func GetValidationOptionsFromPodSpecAndMeta(podSpec, oldPodSpec *api.PodSpec, po
|
||||
AllowIndivisibleHugePagesValues: false,
|
||||
AllowWindowsHostProcessField: utilfeature.DefaultFeatureGate.Enabled(features.WindowsHostProcessContainers),
|
||||
// Allow pod spec with expanded DNS configuration
|
||||
AllowExpandedDNSConfig: utilfeature.DefaultFeatureGate.Enabled(features.ExpandedDNSConfig),
|
||||
AllowExpandedDNSConfig: utilfeature.DefaultFeatureGate.Enabled(features.ExpandedDNSConfig) || haveSameExpandedDNSConfig(podSpec, oldPodSpec),
|
||||
}
|
||||
|
||||
if oldPodSpec != nil {
|
||||
|
||||
Reference in New Issue
Block a user