mirror of
https://github.com/cozystack/cozystack.git
synced 2026-10-31 17:17:26 +09:00
A restarted capi-operator v0.19.0 drops the create events for the provider Deployments it finds already running (kubernetes-sigs/cluster-api-operator#1031). A provider whose Ready condition went False while the operator was down therefore keeps it until that Deployment changes or the informer resyncs, and the first resync after a restart lands two periods later because the handler registers after the informer has listed. With the 10m default that is about 20 minutes, during which capi-providers-core times out on the CoreProvider and everything depending on it waits; every further operator restart starts the clock again. With a one-minute period the same repro recovered 2m02s after the operator took its lease, against no recovery within 4m26s with the default on the same cluster. A resync replays the cache and, with providers in sync, ends in "No changes detected" and an unchanged condition, so it writes nothing to the API server; the operator logged about 15 lines a minute and used 2m CPU and 26Mi of memory. The upstream chart has no value for the flag, so a package patch that make update reapplies adds one, and a bats test holds the rendered argument. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
26 lines
1.3 KiB
Bash
26 lines
1.3 KiB
Bash
#!/usr/bin/env bats
|
|
# The operator's resync period is what bounds the stale-Ready window after an
|
|
# operator restart (kubernetes-sigs/cluster-api-operator#1031): about two
|
|
# periods. It reaches the manager only through patches/sync-period.diff, which
|
|
# `make update` has to reapply on every re-vendor, and through the value in
|
|
# values.yaml. Losing either silently returns the window to about 20 minutes,
|
|
# so this checks the argument the rendered Deployment actually carries.
|
|
|
|
load test_helper
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
|
|
OPERATOR="$REPO_ROOT/packages/system/capi-operator"
|
|
|
|
@test "the operator manager runs with a one-minute resync period" {
|
|
local rendered args
|
|
rendered="$BATS_TEST_TMPDIR/operator.yaml"
|
|
helm template capi-operator "$OPERATOR" --namespace cozy-cluster-api > "$rendered"
|
|
args="$(yq -N 'select(.kind == "Deployment") | .spec.template.spec.containers[] | select(.name == "manager") | .args[]' "$rendered")"
|
|
[ -n "$args" ] || { echo "no manager container args rendered from $OPERATOR" >&2; return 1; }
|
|
case "$(printf '%s\n' "$args" | grep -c '^--sync-period=')" in
|
|
1) ;;
|
|
*) echo "expected exactly one --sync-period in the manager args, got:" >&2; echo "$args" >&2; return 1 ;;
|
|
esac
|
|
printf '%s\n' "$args" | grep -qx -- '--sync-period=1m' || { echo "manager args: $args" >&2; return 1; }
|
|
}
|