mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #87582 from mrueg/ptr
PodTolerationRestriction: Mention Whitelist Scope in Error
This commit is contained in:
commit
71c352dee3
@ -127,6 +127,7 @@ func (p *Plugin) Validate(ctx context.Context, a admission.Attributes, o admissi
|
|||||||
pod := a.GetObject().(*api.Pod)
|
pod := a.GetObject().(*api.Pod)
|
||||||
if len(pod.Spec.Tolerations) > 0 {
|
if len(pod.Spec.Tolerations) > 0 {
|
||||||
whitelist, err := p.getNamespaceTolerationsWhitelist(a.GetNamespace())
|
whitelist, err := p.getNamespaceTolerationsWhitelist(a.GetNamespace())
|
||||||
|
whitelistScope := "namespace"
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -135,12 +136,13 @@ func (p *Plugin) Validate(ctx context.Context, a admission.Attributes, o admissi
|
|||||||
// fall back to cluster's whitelist of tolerations.
|
// fall back to cluster's whitelist of tolerations.
|
||||||
if whitelist == nil {
|
if whitelist == nil {
|
||||||
whitelist = p.pluginConfig.Whitelist
|
whitelist = p.pluginConfig.Whitelist
|
||||||
|
whitelistScope = "cluster"
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(whitelist) > 0 {
|
if len(whitelist) > 0 {
|
||||||
// check if the merged pod tolerations satisfy its namespace whitelist
|
// check if the merged pod tolerations satisfy its namespace whitelist
|
||||||
if !tolerations.VerifyAgainstWhitelist(pod.Spec.Tolerations, whitelist) {
|
if !tolerations.VerifyAgainstWhitelist(pod.Spec.Tolerations, whitelist) {
|
||||||
return fmt.Errorf("pod tolerations (possibly merged with namespace default tolerations) conflict with its namespace whitelist")
|
return fmt.Errorf("pod tolerations (possibly merged with namespace default tolerations) conflict with its %s whitelist", whitelistScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user