Repository navigation
Read MachineOperations from the API server before running them - #374
Merged
Philip Lombardi (plombardi89) merged 1 commit intoOct 20, 2026
Merged
Conversation
The daemon checked whether a MachineOperation was still to run through the manager's cached client. Marking the operation in progress updates its status, which queues another reconcile of it, and that reconcile runs as soon as the handler returns. The cache can then still have the operation in progress, though the handler has just finished it, and MarkInProgress, reading the same cache, returns without an error for an operation it would have found finished. So the handler ran again: one NodeReboot rebooted the node twice, the second time after the operation had reported Complete. Now the reconciler reads operations through the manager's API reader, as unbounded's NewMachinaMachineOperationReconcilerWithReader allows, so a finished operation is seen as finished. Status updates still go through the manager's client.
Philip Lombardi (plombardi89)
deployed
to
e2e-testing
October 20, 2026 00:32 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused reader wiring addresses stale operation reads, includes regression coverage, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
Prevents duplicate MachineOperation execution caused by stale cache reads, including repeated node reboots.
Changes:
- Uses the manager’s API reader for operation reads while retaining the client for status updates.
- Adds regression coverage for completed operations with stale cached status and pending operations.
| File | Description |
|---|---|
| pkg/daemon/machineoperation_reconciler.go | Accepts a reader and uses the reader-aware constructor. |
| pkg/daemon/machineoperation_reconciler_test.go | Tests stale-cache and pending-operation behavior. |
| pkg/daemon/daemon.go | Supplies the manager’s API reader. |
Review effort: Balanced
hbc (bcho)
approved these changes
Oct 20, 2026
Member
|
(can keep to another pr) we can also prompt the agent to update https://github.com/Azure/AKSFlexNode/blob/main/CHANGELOG.md for tracking the changes |
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 20, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 20, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 20, 2026
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 20, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 20, 2026
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 21, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 21, 2026
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 22, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 22, 2026
Philip Lombardi (plombardi89)
deleted the
phlombar/machineoperation-api-reader
branch
October 23, 2026 16:52
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 23, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 23, 2026
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 24, 2026
This branch carries #374's commit, which keeps a MachineOperation from running twice, until it merges and the branch is rebased.
Philip Lombardi (plombardi89)
added a commit
that referenced
this pull request
Oct 24, 2026
This branch was successfully deployed
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.
Problem
A
NodeRebootMachineOperation sometimes reboots the node twice. The daemon's log shows a complete second soft reboot,stop-nodethen a full start, beginning one second after the first one finished and after the operation reportedComplete.The daemon builds its MachineOperation reconciler with
daemon.NewMachinaMachineOperationReconciler(mgr.GetClient(), ...), so it checks whether an operation is still to run through the manager's cache:Complete.Completeupdate yet, and sees it in progress.MarkInProgressreads the same cache. For an operation it would have found finished, it returns nil, not an error, so the handler runs again and reboots the node a second time.Whether it happens depends on whether the watch event for the
Completeupdate reaches the cache before the queued reconcile reads it.Fix
The reconciler now reads operations through the manager's API reader, using unbounded's
NewMachinaMachineOperationReconcilerWithReader. The queued reconcile then sees the operation as finished and does nothing. Status updates still go through the manager's client.Testing
NodeRebootin progress, and an API server that has itComplete. It expects no reboot, and that a pendingNodeRebootstill reboots once. Going back to the cached client alone makes it fail: the finished operation reboots again.NodeRebootrepeatedly on an Azure Container Linux host running the agent from Run the agent as a privileged container on Azure Container Linux #370, which uses this same code path, and countedstop-nodetasks per operation:golangci-lintpass.