kubestellar / kubeflex

A flexible and scalable platform for running Kubernetes control plane APIs.
Apache License 2.0
48 stars 13 forks source link

bug: wait for condition not working as expected with control plane conditions #300

Open pdettori opened 3 weeks ago

pdettori commented 3 weeks ago

Describe the bug

(from @MikeSpreitzer )

These two are supposed to do the same thing. How do they not?

mspreitz@mjs13 kubestellar % kubectl --context kind-kubeflex wait controlplane/its1 --for 'jsonpath={.status.conditions[?(@.type=="Synced")].status}=True'
controlplane.tenancy.kflex.kubestellar.org/its1 condition met

mspreitz@mjs13 kubestellar % kubectl --context kind-kubeflex wait controlplane/its1 --for condition=Synced
error: timed out waiting for the condition on controlplanes/its1

Steps To Reproduce

  1. Setup a KS installation
  2. Run above commands

Expected Behavior

The "wait for" should return with condition met

Additional Context

No response

pdettori commented 3 weeks ago

I think I found an explanation - if the generation field and the observedGeneration do not match, it suggests that the controller might not have fully synchronized with the desired state specified in the resource. This discrepancy can cause the kubectl wait command to time out because the system sees this as an indication that syncing isn't complete. Indeed:

$ k -n default wait cps/its1 --for condition=Ready

times out. But if I do:

$ kubectl patch controlplane its1 --subresource='status' --type=merge -p '{"status": {"observedGeneration": 1}}'
controlplane.tenancy.kflex.kubestellar.org/its1 patched

(where "1" is the generation value in the spec) then it works:

$ k -n default wait cps/its1 --for condition=Ready
controlplane.tenancy.kflex.kubestellar.org/its1 condition met
MikeSpreitzer commented 3 weeks ago

So the root cause is .status.observedGeneration being stuck at 0.