Skip to content

Commit

Permalink
OSSM-3235 Ensure operator can't deadlock because istiod isn't running (
Browse files Browse the repository at this point in the history
…#1155) (#1166)

If istiod isn't running, but the validating webhook configuration resource is in place, the operator may not be able to reconcile the SMCP and reset istiod.

Here, we configure the webhook with an objectSelector that excludes resources with the `maistra-version` label. All resources created by the operator for the SMCP contain this label and thus don't trigger the webhook. This allows the operator to complete the reconciliation even if the webhook is offline.
  • Loading branch information
luksa committed Apr 14, 2023
1 parent c0f6dcd commit 97eccbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions build/patch-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,21 @@ function patchGalley() {
# add namespace selectors
# remove define block
webhookconfig=${HELM_DIR}/istio-control/istio-discovery/templates/validatingwebhookconfiguration.yaml

# remove original objectSelector
sed_wrap -i '/.*objectSelector:/,/.*{{- end }}/d' "${webhookconfig}"

# replace namespaceSelector and insert maistra objectSelector
sed_wrap -i -e 's|\(\(^ *\)rules:\)|\2namespaceSelector:\
\2 matchExpressions:\
\2 - key: maistra.io/member-of\
\2 operator: In\
\2 values:\
\2 - {{ .Release.Namespace }}\
\2objectSelector:\
\2 matchExpressions:\
\2 - key: maistra-version\
\2 operator: DoesNotExist\
\1|' "${webhookconfig}"
sed_wrap -i -e '/rules:/ a\
- operations:\
Expand All @@ -107,8 +116,7 @@ function patchGalley() {
resources:\
- "*"' "${webhookconfig}"

sed_wrap -i '/.*objectSelector:/,/.*{{- end }}/d' "${webhookconfig}"

# ensure resource updates fail if the webhook is offline
sed_wrap -i -e 's/failurePolicy: Ignore/failurePolicy: Fail/' "${webhookconfig}"

# add name to webhook port (XXX: move upstream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ webhooks:
operator: In
values:
- {{ .Release.Namespace }}
objectSelector:
matchExpressions:
- key: maistra-version
operator: DoesNotExist
rules:
- operations:
- CREATE
Expand Down

0 comments on commit 97eccbc

Please sign in to comment.