Add state machine for image switch (milestone 4c)#50
Conversation
|
@jlebon I skipped the e2e test since we still need to define how to test the upgrade. The state machine is only checked by the env tests for now |
|
|
||
| mu sync.Mutex | ||
| switchImage string | ||
| switchApply bool |
There was a problem hiding this comment.
I think we discussed this at some point. My inclination is to not try to optimize this. I.e. let's not support an --apply special-case at all. We just do the bootc switch and then use the GenericEvent to immediately do another reconcile if desiredImageState is booted.
There was a problem hiding this comment.
To clarify, --apply is not used during staging, we always stage with plain bootc switch . The
--apply is only used in the reboot step: when the image is already staged and desiredImageState is Booted, we run bootc switch --apply to boot into it.
Are you suggesting we should decouple this further and trigger the reboot through a different mechanism (e.g. systemctl reboot) instead of bootc switch --apply?
There was a problem hiding this comment.
Sorry, this is wrong bootc switch --apply doesn't reboot, but it is instead bootc upgrade --apply, the right command
7e1ff20 to
2afd447
Compare
|
There are still some issue with this PR... investigating. |
56119dc to
ba87f0d
Compare
|
I think we should prioritize #57 and implement at least the happy path test for the reboot |
e4557ce to
413cf0d
Compare
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Alice Frosi <afrosi@redhat.com>
Rewrite the reconciler to detect image mismatches between spec.desiredImage and the booted image, stage via bootc switch in a background goroutine. Once, it finished to staged the image, the termination of the goroutine triggers once more the reconciliation loop which will detect that the system requires a reboot. The reconciliation function ensures that the bootc node transitions from Staging to Staged, and then to Rebooting. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Alice Frosi <afrosi@redhat.com>
Replace raw JSON bytes with a bootc.Status struct in the test fake. Status() serializes the struct via json.Marshal, and Switch() auto-mutates the status (staging sets Staged). Upgrade() records the call for test assertions. Add newBootcStatus() and newBootEntry() helpers to build test state without verbose JSON constants. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Alice Frosi <afrosi@redhat.com>
Add envtest cases for the daemon reconciler state machine: - TestStagingTriggered: image mismatch triggers bootc switch - TestStagingError: switch failure sets Degraded condition - TestAlreadyStaged: skip switch when image already staged - TestRebootingSet: reboot triggered when desiredImageState is Booted - TestRollback: restage when desired image changes - TestCancelInflightSwitch: spec change cancels in-flight switch Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Alice Frosi <afrosi@redhat.com>
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the daemon-side state machine that detects image mismatches between spec.desiredImage and the booted image,
stages updates via bootc switch in a background goroutine, and triggers reboot when desiredImageState == Booted.
one path