Adjust Host Lease phases so that it is not Ready until after its template is complete#8
Conversation
|
Warning Review limit reached
More reviews will be available in 37 minutes and 15 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository: osac-project/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (1)
WalkthroughThe reconciler's update path now sets HostLease.Status.Phase explicitly at finalizer update (Failed/Progressing), when provisioning returns a non-zero result (Progressing), when a provisioning template is present but not True (Failed and early return), and before returning for power-state requeue (Progressing). ChangesHostLease Phase Reconciliation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
Security & Stability Note: Risk - Moderate. These changes alter state-machine progression and early-return behavior; mis-set phases could obscure error conditions or allow requeues to mask transient failures. Verify observers and downstream consumers rely on the same phase semantics. 🚥 Pre-merge checks | ✅ 10 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (10 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if hostLease.Status.Phase == "" { | ||
| hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing | ||
| } | ||
| hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing |
There was a problem hiding this comment.
Is this change needed? It feels odd to always unconditionally set the Phase to Progressing without knowing if anything actually needs updating. Or is the idea that we know that something has changed if reconciliation is triggered?
There was a problem hiding this comment.
I think the idea is something has changed if reconciliation is triggered. So if provisioning/power controll fails, it's overwritten to Failed and if everything succeeds, it's overwritten to Ready. On a no-op reconcile that nothing changed, this sets the phase to Progressing and then immediately to Ready.
Do we want to set Progressing only at the points where work is actually happening?
There was a problem hiding this comment.
@larsks do you know what the standard k8s pattern is here?
There was a problem hiding this comment.
I think the common pattern is, for a resource that has previously reached status.Phase = "Ready", to only set status.Phase to "Progressing" if the reconciliation loop is going to exit before the resource has reached the desired state (e.g., because you are waiting for some other activity to complete before the resource is ready).
This avoids short-lived user-visible changes on every reconcile call. Eg., if you are watching the resource for changes, you don't necessarily want to know every time the reconcile loop gets called -- you only want to know when actual work needs to happen.
There was a problem hiding this comment.
Update: set the phase to Ready at template provisioning/power control/adding finalizer. And at the end of reconcile, check if the v1alpha1.HostConditionProvisionTemplateComplete is true, if not, set phase to failed. This prevents from reaching Ready when a previous provisioning template failed and a second reconcile only does power control without re-triggering provisioning - the phase still keeps failed.
bc84452 to
8e726fa
Compare
|
|
||
| if hostLease.Status.Phase == "" { | ||
| hostLease.Status.Phase = v1alpha1.HostLeasePhaseProgressing | ||
| } |
There was a problem hiding this comment.
I think we still want to keep this - if the Phase is empty, it seems reasonable to assume that it's Progressing
Closes osac-project/issues#396
Summary
Progressingat the start of each reconcile. This ensures a HostLease that was previouslyReadytransitions back toProgressingwhen a new provisioning job is triggered (e.g., after aspecchange).handleUpdate()when the provisioningOnFailed()callback sets the phase toFailed, preventing line 174 from overwriting it withReady.Problem
Two bugs in the
phasetransition logic:hostLease.Status.Phasewas only set toProgressingwhen empty (""). If a HostLease was alreadyReadyand a new provisioning job was triggered, the phase stayedReadywhile theProvisionTemplateCompletecondition showedProgressing.PollJobinRunProvisioningLifecyclecalledOnFailed()(which set the phase toFailed) but returned (ctrl.Result{}, nil). Both guards inhandleUpdate(provErr != niland!result.IsZero()) passed, so execution fell through tohostLease.Status.Phase = HostLeasePhaseReady, overwritingFailedwithReady.Summary by CodeRabbit