Conversation
…dated Three loops in the application and microservice update paths iterated with `forEach(async ...)`, so the ChangeTrackingService updates inside them were started and never awaited. The endpoint returned before they had been written, and a node could poll in the gap and see no pending change: the update was stored in the Controller and never reached the agent. Observed on Controller 3.8.2 with Edgelet v1.0.3-rc.1: PUT /api/v3/application and PUT /api/v3/application/yaml stored a changed microservice and no node ever applied it; PATCH /api/v3/microservices/<uuid> did apply, in about 33 s. The difference is the awaited change tracking, not the payload. Replaces the three `forEach(async ...)` loops with `for ... of`, so every ChangeTrackingService.update is awaited inside the transaction that made the change. No API change. Signed-off-by: Nilson.Henao <nilsonfh@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What this fixes
Three loops in the application and microservice update paths iterate with
forEach(async ...), so theChangeTrackingServiceupdates inside them are startedand never awaited. The endpoint can return before they are written, and an agent
polling in that gap sees no pending change: the update is stored in the Controller
and never reaches the node.
src/services/application-service.js(two loops) andsrc/services/microservices-service.js(one loop) becomefor ... of, so everyChangeTrackingService.updateis awaited inside the transaction that made the change.How it was found
Measured on Controller 3.8.2 with Edgelet v1.0.3-rc.1, ten agent nodes, while
building an emulated lab for a grid-edge platform:
PUT /api/v3/applicationandPUT /api/v3/application/yamlstored a changedmicroservice image, and no node ever applied it — the change sat in the Controller
indefinitely.
PATCH /api/v3/microservices/<uuid>(includingiofogUuidin the body) applied thesame change in about 33 s.
The difference between the two is the awaited change tracking, not the payload.
Scope and risk
No API change, no schema change, no behaviour change other than the ordering the code
already intended.
for ... ofinside anasyncfunction preserves the existingsequential semantics that
forEach(async ...)only appeared to have.Verification
npx standard@17clean on both changed files (same version as the repo'sdevDependency).
updates reach nodes, and a cohort rollout of 10 nodes driven through the
application API behaves like one driven through the per-microservice endpoint.
Note:
npm cifails ondevelopfor an unrelated reason (ERESOLVE:sinon-chai@3.7.0wantschai@">=2.1.2 <6", the tree haschai@5.1.1viachai-as-promised), so the test suite was not run here.🤖 Generated with Claude Code