Files
nvke/controller/hack/chart-controller-config-assertions.sh
Eric Staples d61d8a3c92 feat(controller): move a pending control-plane node out of a full failure domain (#2280)
* feat(controller): move a pending control-plane node out of a full failure domain

When CAPNICo reports FailureDomainUnavailable for a control-plane node's
requested domain past a grace period, patch the Machine's failure domain to
the least-used eligible domain the node has not tried, cycling once every
domain has been tried. Gated by controlPlaneFailureDomainFallback in
nvke-controller-config, off by default.

Failure-domain discovery and the allocator move to internal/failuredomains so
the provisioning activity can reuse them. nico-sim gains a configurable
failure-domain layout, and a nico-containers e2e spec covers the move.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* feat(controller): keep the failure-domain fallback and stuck-pending re-placement from overlapping

With the fallback enabled, the stuck-pending reconciler leaves domain-pinned
pending control-plane nodes to the provisioning activity, which moves them in
place. Both acted on the same FailureDomainUnavailable signal on different
clocks, so a moved node could be deleted after one CAPNICo retry.

The rotation now stamps the domain it leaves in the cluster's
UnplaceableFailureDomains, so scale-up, remediation, rollout and rebalance
stop choosing the emptied, still-full domain for the next 3 hours. When
picking the next domain it tries marked domains only after every unmarked
one.

The rotation skips rebalance surges. A surge is placed in the domain of the
node it replaces; moving it can leave two members in one domain after the
shed, and rebalance already abandons a surge that cannot get capacity.

The unplaceable-domain helpers move to the failuredomains package so the
reconciler and the activity share them.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* feat(controller): replace stuck-pending delete with the failure-domain move

Moving a pending control-plane node to another failure domain is now the
only way the controller handles a domain CAPNICo reports out of capacity.
The stuck-pending reconciler, which deleted such a node after 15 minutes
and recreated it elsewhere, is removed along with the
controlPlaneFailureDomainFallback.enabled setting that chose between them.

The move now also leaves a node with a delete in flight alone.
controlPlaneFailureDomainFallback.gracePeriod stays; unset, it defaults to
10 minutes, and a non-positive value is refused at startup and by the chart.

FailureDomainUnavailable leaves the MachineMaterialization interface, since
only the stuck-pending path called it.

The e2e spec gains a scale-up case: with every domain but one out of
capacity, scaling the control plane to three moves the stuck Machine in
place and fails if any control-plane Machine is deleted.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* feat(controller): Surge releases the domain of the first rollout target without a delete in flight

Signed-off-by: Eric Staples <estaples@nvidia.com>

* feat(controller): mark the domain unavailable and update the node in the same transaction

Signed-off-by: Eric Staples <estaples@nvidia.com>

* feat(controller): make the failure domain check more readable

Signed-off-by: Eric Staples <estaples@nvidia.com>

* fix(controller): retry a failure-domain move on Machine patch conflict

A conflict on the optimistic-lock Machine patch now waits for the next
poll instead of failing the activity. Cover the surge-domain release by
driving reconcileNodesNeedingRollout, and document the gracePeriod
positivity constraint in the chart README.

Signed-off-by: Eric Staples <estaples@nvidia.com>

* fix(controller): finish an interrupted failure-domain move once the node has an IP

When the Machine patch of a failure-domain move succeeds and the row
update fails, the next poll records the move. That repair ran only from
the rotation path, which waitForCAPIMachineReady reaches only while the
Machine has no IP, so a node that got an address in the new domain kept
the old domain in its row. The repair now runs on every poll, before the
IP check.

A repaired wrap-around move rebuilt the tried list by appending the
departed domain to the old history instead of restarting it. When the
Machine's domain is already in the tried list the move was a restart,
so only the departed domain is kept.

Signed-off-by: Eric Staples <estaples@nvidia.com>

---------

Signed-off-by: Eric Staples <estaples@nvidia.com>
2026-12-01 09:43:04 -05:00

439 lines
20 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Renders the chart under value sets that reach each conditional key of
# nvke-controller-config, then runs TestRenderedChart over the renders.
# RENDERS_DIR keeps the renders; GO_TEST_FLAGS is passed to go test.
set -euo pipefail
controller="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CHART="${CHART:-"${controller}/deploy/charts/controller"}"
[[ -d "${CHART}" ]] || { echo "chart not found at ${CHART}" >&2; exit 2; }
# Absolute, since the script later changes into the controller module.
CHART="$(cd "${CHART}" && pwd)"
# Values files live apart from the renders, every one of which the test loads.
values="$(mktemp -d)"
if [[ -n "${RENDERS_DIR:-}" ]]; then
mkdir -p "${RENDERS_DIR}"
# Absolute, since go test reads it after the cd into the controller module.
renders="$(cd "${RENDERS_DIR}" && pwd)"
trap 'rm -rf "${values}"' EXIT
else
renders="$(mktemp -d)"
trap 'rm -rf "${renders}" "${values}"' EXIT
fi
render() {
local name="$1"
shift
helm template cwe "${CHART}" "$@" > "${renders}/${name}.yaml"
}
checksum="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
render defaults
render kube-vip-custom \
--set kubeVip.localASN=64512 \
--set kubeVip.staticPeerASN=4200000000
render kube-vip-empty \
--set-string kubeVip.localASN= --set-string kubeVip.staticPeerASN=
render kube-vip-null --set kubeVip.localASN=null --set kubeVip.staticPeerASN=null
render kube-vip-null-section --set kubeVip=null
render dev-without-vip --set allowControlPlaneWithoutVIP=true
render readiness-custom \
--set nodeAgent.readiness.workers=4 \
--set-string nodeAgent.readiness.timeout=10s \
--set-string nodeAgent.readiness.interval=90s \
--set nodeAgent.readiness.jitter=0
render legacy-calico \
--set cni.allowLegacyCalicoClusterCreation=true
# Monitoring stays independent of renewal and both config surfaces agree.
render monitoring-without-renewal \
--set scheduledMaintenance.certRenewal.enabled=false \
--set-string credentialMonitoring.inspectionInterval=2h \
--set-string credentialMonitoring.observationMaxAge=6h \
--set credentialMonitoring.warningDays=60
render monitoring-disabled --set credentialMonitoring.enabled=false
render failure-domain-fallback-grace-period \
--set-string controlPlaneFailureDomainFallback.gracePeriod=15m
# A disabled feature's bounds do not apply, at render or at startup.
render renewal-disabled-out-of-range \
--set scheduledMaintenance.certRenewal.enabled=false \
--set-string scheduledMaintenance.certRenewal.interval=30m \
--set scheduledMaintenance.certRenewal.thresholdDays=120
render monitoring-disabled-out-of-range \
--set credentialMonitoring.enabled=false \
--set-string credentialMonitoring.inspectionInterval=1m \
--set-string credentialMonitoring.observationMaxAge=48h \
--set credentialMonitoring.warningDays=200
# Sub-second durations count, as they do for the controller's time.Duration.
render monitoring-disabled-subsecond-max-age \
--set credentialMonitoring.enabled=false \
--set-string credentialMonitoring.observationMaxAge=500ms
# The chart refuses what the controller would refuse at startup, so a bad value
# fails the upgrade instead of crash-looping the new pod. Collector inputs are
# checked even with monitoring disabled; the other bounds only while enabled.
refuse() {
local want="$1"
shift
local refusal
if refusal="$(helm template cwe "${CHART}" "$@" 2>&1)"; then
echo "rendered with $*; the chart must refuse it with: ${want}" >&2
exit 1
fi
[[ "${refusal}" == *"${want}"* ]] || { echo "$* failed for another reason: ${refusal}" >&2; exit 1; }
}
for field in localASN staticPeerASN; do
for invalid in 0 -1 4294967296 1.5 invalid true; do
refuse "kubeVip.${field} must be an integer between 1 and 4294967295" \
--set "kubeVip.${field}=${invalid}"
done
done
refuse "credentialMonitoring.warningDays must be positive" --set credentialMonitoring.warningDays=0
refuse "credentialMonitoring.warningDays must be positive" \
--set credentialMonitoring.enabled=false --set scheduledMaintenance.certRenewal.enabled=false \
--set credentialMonitoring.warningDays=-1
refuse "credentialMonitoring.observationMaxAge must be positive" \
--set credentialMonitoring.enabled=false --set-string credentialMonitoring.observationMaxAge=0s
refuse 'invalid duration "soon"' --set-string credentialMonitoring.observationMaxAge=soon
refuse "scheduledMaintenance.certRenewal.interval must be between 1h and 24h" \
--set-string scheduledMaintenance.certRenewal.interval=30m
refuse "scheduledMaintenance.certRenewal.interval must be between 1h and 24h" \
--set-string scheduledMaintenance.certRenewal.interval=25h
refuse "scheduledMaintenance.certRenewal.thresholdDays must be between 7 and 90" \
--set scheduledMaintenance.certRenewal.thresholdDays=6
refuse "scheduledMaintenance.certRenewal.thresholdDays must be between 7 and 90" \
--set scheduledMaintenance.certRenewal.thresholdDays=91
refuse "credentialMonitoring.inspectionInterval must be between 5m and 12h" \
--set-string credentialMonitoring.inspectionInterval=1m
refuse "credentialMonitoring.inspectionInterval must be between 5m and 12h" \
--set-string credentialMonitoring.inspectionInterval=13h \
--set-string credentialMonitoring.observationMaxAge=24h
refuse "credentialMonitoring.observationMaxAge must be at least twice" \
--set-string credentialMonitoring.observationMaxAge=1h
refuse "credentialMonitoring.observationMaxAge must be at least twice" \
--set-string credentialMonitoring.observationMaxAge=25h
refuse "scheduledMaintenance.certRenewal.interval must be between 1h and 24h" \
--set-string scheduledMaintenance.certRenewal.interval=24h500ms
refuse "credentialMonitoring.inspectionInterval must be between 5m and 12h" \
--set-string credentialMonitoring.inspectionInterval=12h500ms \
--set-string credentialMonitoring.observationMaxAge=24h
refuse "credentialMonitoring.observationMaxAge must be at least twice" \
--set-string credentialMonitoring.inspectionInterval=5m500ms \
--set-string credentialMonitoring.observationMaxAge=10m
refuse "credentialMonitoring.warningDays must be between 9 and 120" --set credentialMonitoring.warningDays=8
refuse "credentialMonitoring.warningDays must be between 9 and 120" --set credentialMonitoring.warningDays=121
refuse "credentialMonitoring.warningDays must exceed scheduledMaintenance.certRenewal.thresholdDays" \
--set scheduledMaintenance.certRenewal.thresholdDays=60
refuse "controlPlaneFailureDomainFallback.gracePeriod must be greater than 0" \
--set-string controlPlaneFailureDomainFallback.gracePeriod=0s
printf ' credential settings the controller would refuse are refused at render\n'
refuse "nodeAgent.spireAttestationMethod must be dsxImds when supportedInfraProviders includes launchLayer and spiffe.enabled is true" \
--set spiffe.enabled=true --set-string 'supportedInfraProviders=nico\, launchLayer'
# Padded on purpose: the template must trim these.
render dsx-imds \
--set spiffe.enabled=true \
--set-string 'supportedInfraProviders=nico\, launchLayer' \
--set-string nodeAgent.spireAttestationMethod=dsxImds \
--set-string 'nodeAgent.dsxImds.operatorTenant= operator-1 ' \
--set-string 'nodeAgent.dsxImds.endpoint= https://metadata.example.test ' \
--set-string "nodeAgent.dsxImds.pluginChecksum=${checksum}"
render join-token \
--set spiffe.enabled=true \
--set-string nodeAgent.spireAttestationMethod=joinToken
render tls-jwt \
--set spiffe.enabled=true \
--set nodeAgent.tlsJwt.enabled=true \
--set-string nodeAgent.tlsJwt.issuer=https://issuer.example.test \
--set-string nodeAgent.tlsJwt.jwksURI=https://issuer.example.test/keys \
--set 'nodeAgent.tlsJwt.algorithms={RS256,ES256}' \
--set-string nodeAgent.tlsJwt.subjectTrustDomain=example.test \
--set-string 'nodeAgent.tlsJwt.dsxIdentityExchangeURL= https://exchange.example.test ' \
--set-string 'nodeAgent.tlsJwt.subjectTenant= operator-1 ' \
--set-string nodeAgent.tlsJwt.subjectService=nke-node-agent
render external-mtls \
--set nodeAgent.externalMTLS.enabled=true \
--set-string nodeAgent.externalMTLS.secret.name=node-agent-client-tls
render tracing-to-endpoint \
--set tracing.enabled=true \
--set-string tracing.endpoint=otel-collector:4317 \
--set tracing.insecure=false \
--set-string tracing.serviceName=cwe-test
# Neither sets the exporter variables, so both run on Go defaults.
render tracing-without-endpoint --set tracing.enabled=true
render tracing-without-service-name \
--set tracing.enabled=true \
--set-string tracing.endpoint=otel-collector:4317 \
--set-string tracing.serviceName=
render temporal-mtls \
--set temporal.mtls.enabled=true \
--set-string temporal.mtls.secretName=temporal-client \
--set-string temporal.mtls.serverName=temporal.example.test
render teleport \
--set teleport.enabled=true \
--set-string teleport.proxyAddress=teleport.example.test:443 \
--set-string teleport.environment=prod
render profiles-image \
--set profiles.image.enabled=true \
--set-string profiles.image.tag=test \
--set-string profiles.path=/opt/nke/profiles
render infra-providers --set-string 'supportedInfraProviders=nico\, infra'
# Padded on purpose: the template must trim these.
render node-label-allowlist \
--set 'nodeMetadata.allowlistedLabelKeys={ node.kubernetes.io/custom ,k8s.io/custom}'
render machine-metadata-allowlists \
--set 'machineMetadata.allowlistedLabelKeys={cluster.x-k8s.io/custom}' \
--set 'machineMetadata.allowlistedAnnotationKeys={nke.nvidia.com/profile}'
render oidc \
--set nvkeOIDCAuth.enabled=true \
--set spiffe.enabled=true \
--set-string spiffe.trustDomain=example.test \
--set-string nvkeOIDCAuth.issuerURL=https://oidc.example.test \
--set-string nvkeOIDCAuth.discoveryURL=https://oidc.example.test/.well-known/openid-configuration \
--set-string nvkeOIDCAuth.caBundleSecret.namespace=nke-system \
--set-string nvkeOIDCAuth.caBundleSecret.name=oidc-ca \
--set-string nvkeOIDCAuth.caBundleSecret.key=ca.crt
# apiAuth rendered by the chart, which the controller reads from config.yaml.
cat > "${values}/api-auth-inline.yaml" <<'YAML'
apiAuth:
enabled: true
config:
audiences: ["https://nke.example.internal"]
issuers:
- name: local-kubernetes
issuer: "https://kubernetes.default.svc.cluster.local"
jwks:
uri: "https://kubernetes.default.svc/openid/v1/jwks"
caBundlePath: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearerTokenPath: /var/run/secrets/kubernetes.io/serviceaccount/token
algorithms: [RS256]
admit:
serviceAccounts:
- namespace: nke-clients
YAML
render api-auth-inline -f "${values}/api-auth-inline.yaml"
render api-auth-permissive -f "${values}/api-auth-inline.yaml" \
--set apiAuth.permissive=true
# apiAuthz with the chart's bundle, which TestRenderedChart loads.
cat > "${values}/api-authz.yaml" <<'YAML'
apiAuthz:
enabled: true
authorizer:
localBundle:
config:
issuers:
local-kubernetes:
serviceAccounts:
- {namespace: nke-clients, grants: [admin]}
YAML
render api-authz -f "${values}/api-auth-inline.yaml" -f "${values}/api-authz.yaml"
# apiAuthz permissive behind permissive apiAuth.
render api-authz-permissive -f "${values}/api-auth-inline.yaml" -f "${values}/api-authz.yaml" \
--set apiAuth.permissive=true \
--set apiAuthz.permissive=true
# Empty strings fall back to Go defaults, which the template must render.
render empty-strings \
--set-string identity.fieldManagerName= \
--set-string identity.managedByLabelValue= \
--set-string metrics.listenAddress= \
--set-string supportedInfraProviders= \
--set-string kubeadm.imageRepository= \
--set-string scheduledMaintenance.certRenewal.interval= \
--set-string credentialMonitoring.inspectionInterval= \
--set-string credentialMonitoring.observationMaxAge= \
--set-string spiffe.endpointSocket= \
--set-string spiffe.spire.serverNamespace= \
--set-string spiffe.spire.serverPort= \
--set-string spiffe.spire.joinTokenTTL= \
--set-string temporal.cloudWorkflow.namespace= \
--set-string teleport.managedByLabelValue= \
--set-string teleport.tokenNamePrefix=
# Bool and int keys whose Go default is not zero: null and empty fall back to it,
# an explicit false or 0 does not.
render empty-nonzero-defaults \
--set-string credentialMonitoring.enabled= \
--set-string credentialMonitoring.warningDays= \
--set-string scheduledMaintenance.certRenewal.enabled= \
--set-string scheduledMaintenance.certRenewal.thresholdDays= \
--set-string controllers.nico.enabled= \
--set tracing.enabled=true \
--set-string tracing.endpoint=otel-collector:4317 \
--set-string tracing.insecure=
render null-nonzero-defaults \
--set credentialMonitoring.enabled=null \
--set credentialMonitoring.warningDays=null \
--set scheduledMaintenance.certRenewal.enabled=null \
--set scheduledMaintenance.certRenewal.thresholdDays=null \
--set controllers.nico.enabled=null \
--set tracing.enabled=true \
--set-string tracing.endpoint=otel-collector:4317 \
--set tracing.insecure=null
render explicit-false-and-zero \
--set scheduledMaintenance.certRenewal.enabled=false \
--set scheduledMaintenance.certRenewal.thresholdDays=0 \
--set controllers.nico.enabled=false
# oidc.providers with only the required fields, with every field, and at the cap.
cat > "${values}/oidc-providers-required.yaml" <<'YAML'
oidc:
providers:
- name: corp
issuerURL: https://login.example.test
audiences: [nke]
usernameClaim: sub
usernamePrefix: ""
caBundle: |
-----BEGIN CERTIFICATE-----
MIIBexample
-----END CERTIFICATE-----
YAML
cat > "${values}/oidc-providers-full.yaml" <<'YAML'
oidc:
providers:
- name: corp
issuerURL: https://login.example.test
audiences: [nke, kubectl]
usernameClaim: email
usernamePrefix: "corp:"
groupsClaim: groups
groupsPrefix: "corp:"
requiredClaims:
hd: example.test
tenant: "1"
discoveryURL: https://login.internal.example.test/.well-known/openid-configuration
caBundle: |
-----BEGIN CERTIFICATE-----
MIIBexample
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIBintermediate
-----END CERTIFICATE-----
- name: partner
issuerURL: https://idp.partner.example.test/realms/nke
audiences: [nke]
usernameClaim: preferred_username
usernamePrefix: "partner:"
caBundle: "-----BEGIN CERTIFICATE-----\nMIIBpartner\n-----END CERTIFICATE-----"
YAML
providers() {
printf 'oidc:\n providers:\n'
for ((i = 1; i <= $1; i++)); do
printf ' - {name: p%d, issuerURL: "https://p%d.example.test", audiences: [nke], usernameClaim: sub, usernamePrefix: "p%d:", caBundle: pem}\n' "${i}" "${i}" "${i}"
done
}
providers 5 > "${values}/oidc-providers-at-cap.yaml"
providers 6 > "${values}/oidc-providers-over-cap.yaml"
for name in oidc-providers-required oidc-providers-full oidc-providers-at-cap; do
render "${name}" -f "${values}/${name}.yaml"
done
# The providers reach config.yaml as given, down to the CA bundle's newlines.
for name in oidc-providers-required oidc-providers-full oidc-providers-at-cap; do
want="$(yq -o=json -I=0 '.oidc.providers | sort_keys(..)' "${values}/${name}.yaml")"
got="$(yq 'select(.kind == "ConfigMap" and .metadata.name == "nvke-controller-config") | .data["config.yaml"]' "${renders}/${name}.yaml" |
yq -o=json -I=0 '.oidc.providers | sort_keys(..)')"
[[ "${got}" == "${want}" ]] || { echo "${name}: config.yaml has oidc.providers ${got}, values gave ${want}" >&2; exit 1; }
done
if refusal="$(helm template cwe "${CHART}" -f "${values}/oidc-providers-over-cap.yaml" 2>&1)"; then
echo "six oidc.providers rendered; the chart must refuse more than five" >&2
exit 1
fi
[[ "${refusal}" == *"oidc.providers has 6 entries"* ]] || { echo "six oidc.providers failed for another reason: ${refusal}" >&2; exit 1; }
printf ' oidc.providers render as given, and more than five are refused\n'
# A separate hooks directory, with and without the profiles image.
render runbooks-path --set-string profiles.runbooksPath=/opt/nke/hooks
render runbooks-path-with-profiles-image \
--set profiles.image.enabled=true \
--set-string profiles.image.tag=test \
--set-string profiles.path=/opt/nke/profiles \
--set-string profiles.runbooksPath=/opt/nke/hooks
# env stays open to what nvke-controller-config does not carry, such as what
# Tilt and nvkectl bootstrap pass, and refuses what it does.
render env-passthrough \
--set-string 'env[0].name=LOG_LEVEL' --set-string 'env[0].value=debug' \
--set-string 'env[1].name=NODE_AGENT_PORT' --set-string 'env[1].value=50051'
if refusal="$(helm template cwe "${CHART}" \
--set nvkeOIDCAuth.enabled=true --set spiffe.enabled=true --set-string spiffe.trustDomain=example.test \
--set-string 'env[0].name=NKE_OIDC_AUTH_ISSUER_URL' --set-string 'env[0].value=https://oidc.example.test' 2>&1)"; then
echo "env set NKE_OIDC_AUTH_ISSUER_URL and rendered; the chart must refuse a variable nvke-controller-config carries" >&2
exit 1
fi
[[ "${refusal}" == *"env sets NKE_OIDC_AUTH_ISSUER_URL, which nvke-controller-config carries as oidc.managementOIDCAuth.issuerURL"* ]] ||
{ echo "env override of NKE_OIDC_AUTH_ISSUER_URL failed for another reason: ${refusal}" >&2; exit 1; }
if refusal="$(helm template cwe "${CHART}" --set-string 'env[0].name=CONTROLLER_CONFIG_PATH' --set-string 'env[0].value=' 2>&1)"; then
echo "env set CONTROLLER_CONFIG_PATH and rendered; the chart must refuse it" >&2
exit 1
fi
[[ "${refusal}" == *"env sets CONTROLLER_CONFIG_PATH"* ]] ||
{ echo "env override of CONTROLLER_CONFIG_PATH failed for another reason: ${refusal}" >&2; exit 1; }
for key in WORKERS TIMEOUT INTERVAL JITTER; do
variable="NODE_AGENT_READINESS_${key}"
if refusal="$(helm template cwe "${CHART}" --set-string "env[0].name=${variable}" --set-string 'env[0].value=1' 2>&1)"; then
echo "env set ${variable} and rendered; the chart must refuse it" >&2
exit 1
fi
[[ "${refusal}" == *"env sets ${variable}, which nvke-controller-config carries as agentReadiness."* ]] ||
{ echo "env override of ${variable} failed for another reason: ${refusal}" >&2; exit 1; }
done
printf ' env overrides of nvke-controller-config settings and its path are refused\n'
# A renamed values key must fail the render naming its replacement, not fall
# back to the chart defaults, which is what Helm does with an unknown key.
for pair in nkeOIDCAuth.enabled=true:nvkeOIDCAuth nkeSystemNamespace.create=false:nvkeSystemNamespace; do
old="${pair%%:*}" new="${pair##*:}"
if refusal="$(helm template cwe "${CHART}" --set "${old}" 2>&1)"; then
echo "values set ${old} and rendered; the chart must refuse a renamed key" >&2
exit 1
fi
[[ "${refusal}" == *"was renamed to ${new}"* ]] ||
{ echo "setting ${old} failed for another reason: ${refusal}" >&2; exit 1; }
done
# An explicitly empty old key is false in a Helm condition, so the guard keys
# off presence instead. Assert that, or the rename is bypassable with --set-json.
for new in nvkeOIDCAuth nvkeSystemNamespace; do
old="nke${new#nvke}"
if refusal="$(helm template cwe "${CHART}" --set-json "${old}={}" 2>&1)"; then
echo "values set ${old} to {} and rendered; the chart must refuse a renamed key" >&2
exit 1
fi
[[ "${refusal}" == *"was renamed to ${new}"* ]] ||
{ echo "setting ${old} to {} failed for another reason: ${refusal}" >&2; exit 1; }
done
printf ' renamed values keys are refused, naming their replacement\n'
# The values files the Tilt and nvkectl bootstrap deployments install with.
render tilt -f "${controller}/hack/tilt-controller-chart-values.yaml"
render nvkectl-bootstrap -f "${controller}/../cli/internal/bootstrap/controllerdeploy/manifests/controller-values.yaml"
printf ' rendered %s value sets\n' "$(find "${renders}" -name '*.yaml' | wc -l | tr -d ' ')"
cd "${controller}"
# shellcheck disable=SC2086 # GO_TEST_FLAGS is a list of flags.
NKE_RENDERED_CHART_DIR="${renders}" go test ./internal/controllerconfig/ -run '^TestRenderedChart$' -count=1 ${GO_TEST_FLAGS:-}