Skip to content

Retry creates rejected right after the CRD is created (OwnerReferencesPermissionEnforcement) - #2103

Open
matthewhudsonedb wants to merge 3 commits into
Altinity:0.28.0from
matthewhudsonedb:fix/2094-create-retry
Open

matthewhudsonedb wants to merge 3 commits into
Altinity:0.28.0from
matthewhudsonedb:fix/2094-create-retry

Conversation

@matthewhudsonedb

Copy link
Copy Markdown

Fixes #2094

Right after the CHI or CHK CRD is created, clusters with OwnerReferencesPermissionEnforcement (OpenShift turns it on) reject the operator's creates for a short time with cannot find RESTMapping. Every object the operator creates has an owner reference with blockOwnerDeletion: true, so they all hit it. The rejection clears by itself after about 5-25 seconds, but the operator doesn't try again:

  • The common ConfigMaps fail and the error is only logged. Pods can't start because they mount those ConfigMaps, and nothing creates them until after the 300s StatefulSet wait.
  • If a per-host object fails, the CHI ends up Aborted and stays that way.

This retries the create when it hits that error, the same way GetWithRetry already retries reads. It waits 1s, 2s, 4s, 8s, then 10s between tries, for about 75s in total. Any other Forbidden error still fails straight away. It covers ConfigMap, Service, PDB, Secret and StatefulSet creates for both CHI and CHK. PVCs aren't included because the operator doesn't give them an owner reference.

I tested it on kind with --enable-admission-plugins=NodeRestriction,OwnerReferencesPermissionEnforcement, applying the CRDs, the operator and a 1-node CHI or CHK at the same time. The rejection lasted about 16-19s in each run.

Before After
CHI pod stuck, not Ready after 6 min Completed after 54s
CHK pod stuck, Aborted after about 5.5 min Completed after 61s

In the CHK run the ConfigMap needed 6 tries before it went through, which is why the retry window is about 75s rather than something shorter.

…sionEnforcement

For a short window after the CHI CRD is created (observed 5-23s), the
OwnerReferencesPermissionEnforcement admission plugin rejects creates
carrying a blockOwnerDeletion owner reference with "cannot find
RESTMapping", because its cached RESTMapper does not know the kind yet.
The preliminary common ConfigMaps failed (logged only), leaving pods in
Init until after the 300s StatefulSet wait, and a failed per-host
ConfigMap aborted the reconcile with nothing to requeue it.

Retry ConfigMap, Service, PDB, Secret and StatefulSet creates on that
error and on transient API errors via CreateWithRetry (1s doubling,
capped at 10s, ~35s total), sharing the loop with GetWithRetry. Any
other Forbidden stays terminal.

Fixes Altinity#2094
…rmissionEnforcement

CHK objects get the same blockOwnerDeletion owner reference (Kind
ClickHouseKeeperInstallation), so a CHK applied right after its CRD is
created hits the same admission window. controller-runtime's back-off
does not cover it: reconcileCRAuxObjectsPreliminary only logs common
ConfigMap failures, so nothing is returned to requeue on.

Wrap the CHK ConfigMap, PDB, Secret, Service and StatefulSet creates in
CreateWithRetry, as for CHI.
On kind the CHK fix needed 6 of 7 attempts: the admission window closed
during a 10s back-off. Allow 10 retries (1s, 2s, 4s, 8s, then 10s) so a
slower apiserver does not run out.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant