Skip to content

Commit 71c352d

Browse files
authored
Merge pull request kubernetes#87582 from mrueg/ptr
PodTolerationRestriction: Mention Whitelist Scope in Error
2 parents ec36ff4 + eb6c716 commit 71c352d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

plugin/pkg/admission/podtolerationrestriction/admission.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (p *Plugin) Validate(ctx context.Context, a admission.Attributes, o admissi
127127
pod := a.GetObject().(*api.Pod)
128128
if len(pod.Spec.Tolerations) > 0 {
129129
whitelist, err := p.getNamespaceTolerationsWhitelist(a.GetNamespace())
130+
whitelistScope := "namespace"
130131
if err != nil {
131132
return err
132133
}
@@ -135,12 +136,13 @@ func (p *Plugin) Validate(ctx context.Context, a admission.Attributes, o admissi
135136
// fall back to cluster's whitelist of tolerations.
136137
if whitelist == nil {
137138
whitelist = p.pluginConfig.Whitelist
139+
whitelistScope = "cluster"
138140
}
139141

140142
if len(whitelist) > 0 {
141143
// check if the merged pod tolerations satisfy its namespace whitelist
142144
if !tolerations.VerifyAgainstWhitelist(pod.Spec.Tolerations, whitelist) {
143-
return fmt.Errorf("pod tolerations (possibly merged with namespace default tolerations) conflict with its namespace whitelist")
145+
return fmt.Errorf("pod tolerations (possibly merged with namespace default tolerations) conflict with its %s whitelist", whitelistScope)
144146
}
145147
}
146148
}

0 commit comments

Comments
 (0)