mirror of https://github.com/k3s-io/k3s
Merge pull request #75985 from ravisantoshgudimetla/fix-pod-toleration
Fix besteffort pods for conflicting tolerationsk3s-v1.15.3
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)
|
||||
}
|
||||
func (p *podTolerationsPlugin) Validate(a admission.Attributes, o admission.ObjectInterfaces) error {
|
||||
|
|
|
@ -201,6 +201,18 @@ func TestPodAdmission(t *testing.T) {
|
|||
admit: true,
|
||||
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,
|
||||
defaultClusterTolerations: []api.Toleration{},
|
||||
|
|
Loading…
Reference in New Issue