Skip to content

Commit 856fe84

Browse files
committed
Overridden quantity must be below namespace Maximum
The overridden quantity must be below the namespace Maximum specified via LimitRange object. Currently the mutating admission webhook overrides a resource above the namespace maximum and thus fails Pod creation, we see the following error: "pods "croe2e-f7c9h" is forbidden: maximum cpu usage per Container is 1, but limit is 2" Query the Maximum limit for CPU and Memory resource specified in LimitRange and ensure that the overridden resource quantity never exceeds the namespace Maximum.
1 parent 094727e commit 856fe84

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

Diff for: .dockerignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
./bin/*
2-
31
manifests/art.yaml
42
manifests/*/image-references
53

Diff for: artifacts/deploy/200_rbac.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ rules:
9696
- list
9797
- watch
9898

99-
# to grant power to the operand to watch namespace(s)
99+
# to grant power to the operand to watch Namespace(s) and LimitRange(s)
100100
- apiGroups:
101101
- ""
102102
resources:
103103
- namespaces
104+
- limitranges
104105
verbs:
105106
- get
106107
- list

Diff for: manifests/4.4/clusterresourceoverride-operator.v4.4.0.clusterserviceversion.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,12 @@ spec:
223223
- list
224224
- watch
225225

226-
# to grant power to the operand to watch namespace(s)
226+
# to grant power to the operand to watch Namespace(s) and LimitRange(s)
227227
- apiGroups:
228228
- ""
229229
resources:
230230
- namespaces
231+
- limitranges
231232
verbs:
232233
- get
233234
- list

Diff for: pkg/asset/rbac.go

+2
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ func (s *rbac) New() []*RBACItem {
135135
"watch",
136136
},
137137
},
138+
// to give power to the operand to watch Namespace and LimitRange
138139
{
139140
APIGroups: []string{
140141
"",
141142
},
142143
Resources: []string{
143144
"namespaces",
145+
"limitranges",
144146
},
145147
Verbs: []string{
146148
"get",

Diff for: pkg/asset/webhookconfiguration.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (m *mutatingWebhookConfiguration) New() *admissionregistrationv1beta1.Mutat
3232
namespaceMatchLabelKey := fmt.Sprintf("%s.%s/enabled", m.values.AdmissionAPIResource, m.values.AdmissionAPIGroup)
3333
timeoutSeconds := int32(5)
3434
sideEffects := admissionregistrationv1beta1.SideEffectClassNone
35-
35+
reinvoke := admissionregistrationv1beta1.IfNeededReinvocationPolicy
3636
return &admissionregistrationv1beta1.MutatingWebhookConfiguration{
3737
TypeMeta: metav1.TypeMeta{
3838
Kind: "MutatingWebhookConfiguration",
@@ -88,9 +88,10 @@ func (m *mutatingWebhookConfiguration) New() *admissionregistrationv1beta1.Mutat
8888
},
8989
},
9090
},
91-
FailurePolicy: &policy,
92-
TimeoutSeconds: &timeoutSeconds,
93-
SideEffects: &sideEffects,
91+
FailurePolicy: &policy,
92+
TimeoutSeconds: &timeoutSeconds,
93+
SideEffects: &sideEffects,
94+
ReinvocationPolicy: &reinvoke,
9495
},
9596
},
9697
}

0 commit comments

Comments
 (0)