mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #75985 from ravisantoshgudimetla/fix-pod-toleration
Fix besteffort pods for conflicting tolerations
This commit is contained in:
commit
16db83b257
@ -132,8 +132,9 @@ func (p *podTolerationsPlugin) Admit(a admission.Attributes, o admission.ObjectI
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pod.Spec.Tolerations = finalTolerations
|
// Final merge of tolerations irrespective of pod type, if the user while creating pods gives
|
||||||
|
// conflicting tolerations(with same key+effect), the existing ones should be overwritten by latest one
|
||||||
|
pod.Spec.Tolerations = tolerations.MergeTolerations(finalTolerations, []api.Toleration{})
|
||||||
return p.Validate(a, o)
|
return p.Validate(a, o)
|
||||||
}
|
}
|
||||||
func (p *podTolerationsPlugin) Validate(a admission.Attributes, o admission.ObjectInterfaces) error {
|
func (p *podTolerationsPlugin) Validate(a admission.Attributes, o admission.ObjectInterfaces) error {
|
||||||
|
@ -201,6 +201,18 @@ func TestPodAdmission(t *testing.T) {
|
|||||||
admit: true,
|
admit: true,
|
||||||
testName: "added memoryPressure/DiskPressure for Burstable pod",
|
testName: "added memoryPressure/DiskPressure for Burstable pod",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pod: bestEffortPod,
|
||||||
|
defaultClusterTolerations: []api.Toleration{},
|
||||||
|
namespaceTolerations: []api.Toleration{},
|
||||||
|
whitelist: []api.Toleration{},
|
||||||
|
podTolerations: []api.Toleration{{Key: "testKey", Operator: "Equal", Value: "testValue", Effect: "NoSchedule", TolerationSeconds: nil}, {Key: "testKey", Operator: "Equal", Value: "testValue1", Effect: "NoSchedule", TolerationSeconds: nil}},
|
||||||
|
mergedTolerations: []api.Toleration{
|
||||||
|
{Key: "testKey", Operator: "Equal", Value: "testValue1", Effect: "NoSchedule", TolerationSeconds: nil},
|
||||||
|
},
|
||||||
|
admit: true,
|
||||||
|
testName: "Besteffort pod should overwrite for conflicting tolerations",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
pod: guaranteedPod,
|
pod: guaranteedPod,
|
||||||
defaultClusterTolerations: []api.Toleration{},
|
defaultClusterTolerations: []api.Toleration{},
|
||||||
|
Loading…
Reference in New Issue
Block a user