Skip to content

Commit 8abae91

Browse files
authored
fix: set topology webhook matchConditions (#1375)
**What problem does this PR solve?**: Recently found a bug #1372 This adds another level of safety and skips unnecessarily calling this webhook for clusters not using topology. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 1ed9a7e commit 8abae91

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

charts/cluster-api-runtime-extensions-nutanix/templates/webhooks.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ webhooks:
2727
resources:
2828
- clusters
2929
sideEffects: None
30+
matchConditions:
31+
- name: has-topology
32+
expression: has(object.spec.topology)
3033
- admissionReviewVersions:
3134
- v1
3235
clientConfig:
@@ -47,6 +50,9 @@ webhooks:
4750
resources:
4851
- clusters
4952
sideEffects: None
53+
matchConditions:
54+
- name: has-topology
55+
expression: has(object.spec.topology)
5056
---
5157
apiVersion: admissionregistration.k8s.io/v1
5258
kind: ValidatingWebhookConfiguration
@@ -75,6 +81,9 @@ webhooks:
7581
resources:
7682
- clusters
7783
sideEffects: None
84+
matchConditions:
85+
- name: has-topology
86+
expression: has(object.spec.topology)
7887
- admissionReviewVersions:
7988
- v1
8089
clientConfig:
@@ -95,3 +104,6 @@ webhooks:
95104
- clusters
96105
sideEffects: None
97106
timeoutSeconds: 30
107+
matchConditions:
108+
- name: has-topology
109+
expression: has(object.spec.topology)

hack/update-webhook-configurations.yq

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77
with(.metadata;
88
.name = "{{ include \"chart.name\" . }}-" + .name,
99
.annotations["cert-manager.io/inject-ca-from"] = "{{ .Release.Namespace}}/{{ template \"chart.name\" . }}-admission-tls"
10-
),
10+
) |
1111
with(.webhooks[].clientConfig.service;
1212
.name = "{{ include \"chart.name\" . }}-admission",
1313
.namespace = "{{ .Release.Namespace }}"
14+
) |
15+
with(.webhooks[];
16+
.matchConditions = [
17+
{
18+
"name": "has-topology",
19+
"expression": "has(object.spec.topology)"
20+
}
21+
]
1422
)

0 commit comments

Comments
 (0)