fix: break infinite status reconciliation loop in notebook controller - #1341
Open
Raakshass wants to merge 2 commits into
Open
fix: break infinite status reconciliation loop in notebook controller#1341Raakshass wants to merge 2 commits into
Raakshass wants to merge 2 commits into
Conversation
PodCondToNotebookCond defaulted LastProbeTime to metav1.Now() when
kubelet left it unset, producing a different timestamp on every
reconcile. updateNotebookStatus wrote unconditionally with no
DeepEqual guard. Combined with For(&Notebook{}) having no
GenerationChangedPredicate, this created an infinite loop.
- Reorder PodCondToNotebookCond to resolve LastTransitionTime first
- Fall back LastProbeTime to LastTransitionTime instead of metav1.Now()
- Add reflect.DeepEqual guard in updateNotebookStatus to skip no-op writes
Signed-off-by: Siddhant Jain <siddhantjainofficial26@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Adds a test case where LastProbeTime is intentionally omitted (zero value) to simulate kubelet behavior. Asserts that PodCondToNotebookCond falls back to LastTransitionTime instead of metav1.Now(). This test fails if the LastProbeTime fix is reverted, proving the guard is load-bearing. Signed-off-by: Siddhant Jain <siddhantjainofficial26@gmail.com>
Author
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the infinite reconciliation loop in the notebook controller where
updateNotebookStatusissues aStatus().Update()PUT on every reconcile even when nothing has changed.Root Cause
Three-link causal chain:
PodCondToNotebookCond(line 330) — kubelet never setsLastProbeTimeon pod conditions, so the else branch injectsmetav1.Now()on every reconcile, producing a different timestamp each time.updateNotebookStatus(line 238-240) — unconditionalr.Status().Update(ctx, nb)with no comparison guard.SetupWithManager(line 713-714) —For(&v1beta1.Notebook{})with noGenerationChangedPredicate, so the status write bumpsresourceVersion, emits a watch event, and re-enqueues.Changes
controllers/notebook_controller.goPodCondToNotebookCondto resolveLastTransitionTimefirst, fall backLastProbeTimetocondition.LastTransitionTimeinstead ofmetav1.Now(), addreflect.DeepEqualguard inupdateNotebookStatusDesign Decisions
LastProbeTimefalls back toLastTransitionTime, not zero — the CRD schema declareslastProbeTimeastype: string, format: date-timewithoutnullable: true, andomitemptyonmetav1.Time(a struct) does not suppress the zero value.LastTransitionTimeresolved first soLastProbeTimecan reference it without a secondmetav1.Now()call.DeepEqualguard alone does not break the loop becausemetav1.Now()makes it return false every time. The timestamp fix makes the status deterministic; the guard eliminates the residual no-op PUT.reflectalready used at line 257.Test Results
All 5
TestCreateNotebookStatussubtests pass.go vetandgo buildclean.Follow-up
LastProbeTimeomitted asserting fallback equalsLastTransitionTimeCopyStatefulSetFieldssecondary loop is a separate concernContributor Checklist
go vetcleango buildclean