Repository navigation
fix(tests): start the runtime discovery workload after its record exists - #1941
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The `runtime should discover docker workloads` spec was commented out and
its CI job disabled because it failed intermittently. The order the
testenv brings things up explains it, and it is not a race that waiting
longer can win.
`docker compose up` started the labelled container with the rest of the
stack, ten seconds before the daemon. dir-runtime reconciles once at boot
(discovery.go, the only call to reconcile), queues every workload it
finds, and gives each a bounded resolve budget: six attempts, 15s apart,
30s timeout each, so roughly 75s if attempts fail fast and 255s if they
time out. The record that workload references can only be pushed once the
daemon is serving, from the suite's BeforeAll. On a fast runner the
record lands inside the budget and the spec passes. On a slow one the
budget expires first, resolveWorkload persists `{"error": ...}` into the
workload's OASF field, and nothing re-queues it: the only two writers to
the work queue are boot reconciliation and new docker events. The spec's
three-minute Eventually cannot recover from that no matter how long it
waits.
So the container now sits behind a compose profile and the suite starts
it in BeforeAll, after the push. The docker start event is what queues
the workload, and the record is already in the store when the first
attempt runs.
The spec is restored split in two. Registration depends only on the
daemon seeing the start event; resolution depends on the record being
reachable. Separating them means a lost event reads as "the workload
never appeared" within a minute, rather than as a three-minute timeout
that looks like a resolver fault. The resolution half asserts the absence
of the "error" key directly, so an exhausted budget reports itself
instead of surfacing as a missing "cid".
Four things worth stating plainly rather than leaving implicit.
This narrows the window but does not close the hole, and it gives
something up to do it. Registration previously had two independent
triggers, boot reconciliation and the start event; the flake was that
both fired too early. Deferring the container removes the reconciliation
trigger outright, so registration now rests solely on the event stream,
which is lossy: dir-runtime subscribes to docker events without a
`since`, and starts watching only after reconcile returns, so an event
that fires in that gap is gone. The trade is a recoverable-looking flake
for a rarer unrecoverable one. A periodic re-reconcile in dir-runtime
would make the ordering irrelevant and is the real fix.
The mechanism above is reproduced, not just read out of the source.
Running the suite locally with a 90s delay before the record push, to
stand in for a slow runner, fails on the old ordering and passes on this
one. The failing run exhausts all six attempts on `record not found`,
gives up about ten seconds before the record lands, and exits 201, the
code this issue reports. Boot reconciliation logs
`workloads_registered=1` before the change and 0 after.
That reason was "possible schema drift on the runtime side," which is a
separate question this change does not touch: the resolution assertion
compares the resolved record against the fixture with MatchJSON, and a
serialization drift there fails regardless of ordering. The job is
re-enabled anyway, because a disabled job cannot tell us whether either
problem is real, and dir-runtime has moved 1.3.3 to 1.3.4 since. If it
comes back red for drift rather than ordering, that is worth knowing and
belongs in its own change. Happy to drop the re-enable from this PR and
land it separately if you would rather not have it in the matrix yet.
The spec did not compile as commented: `:= discoverResp[0]` had lost its
variable name. It reads `workload := discoverResp[0]` again.
Signed-off-by: Conor Bronsdon <[email protected]>
83f01d9 to
0395eba
Compare
|
One more result worth adding, since it validates a design choice rather than just the fix. Running the old ordering under the 90s handicap, the failure reports itself like this: Two things that were guesses when I opened this are now observed. The The registration spec passes in that same run; only resolution fails. That is the whole reason for splitting one spec into two. The workload was never undiscovered — it was discovered too early to resolve — and the two specs now say which. A single combined spec would have failed at the three-minute mark with no way to tell those apart, which is roughly the position #1780 started from. The suite exits 201 here, matching the code in the issue report. |
paralta
left a comment
There was a problem hiding this comment.
Thanks for the investigation on this bug and for the explanation provided 🚀 Keeping in mind the periodic re-reconcile in dir-runtime as the long term fix for this issue, I believe your PR provides a solid pragmatic solution for now.
…tcy#1941) The `runtime should discover docker workloads` spec was commented out and its CI job disabled because it failed intermittently. The order the testenv brings things up explains it, and it is not a race that waiting longer can win. `docker compose up` started the labelled container with the rest of the stack, ten seconds before the daemon. dir-runtime reconciles once at boot (discovery.go, the only call to reconcile), queues every workload it finds, and gives each a bounded resolve budget: six attempts, 15s apart, 30s timeout each, so roughly 75s if attempts fail fast and 255s if they time out. The record that workload references can only be pushed once the daemon is serving, from the suite's BeforeAll. On a fast runner the record lands inside the budget and the spec passes. On a slow one the budget expires first, resolveWorkload persists `{"error": ...}` into the workload's OASF field, and nothing re-queues it: the only two writers to the work queue are boot reconciliation and new docker events. The spec's three-minute Eventually cannot recover from that no matter how long it waits. So the container now sits behind a compose profile and the suite starts it in BeforeAll, after the push. The docker start event is what queues the workload, and the record is already in the store when the first attempt runs. The spec is restored split in two. Registration depends only on the daemon seeing the start event; resolution depends on the record being reachable. Separating them means a lost event reads as "the workload never appeared" within a minute, rather than as a three-minute timeout that looks like a resolver fault. The resolution half asserts the absence of the "error" key directly, so an exhausted budget reports itself instead of surfacing as a missing "cid". Four things worth stating plainly rather than leaving implicit. This narrows the window but does not close the hole, and it gives something up to do it. Registration previously had two independent triggers, boot reconciliation and the start event; the flake was that both fired too early. Deferring the container removes the reconciliation trigger outright, so registration now rests solely on the event stream, which is lossy: dir-runtime subscribes to docker events without a `since`, and starts watching only after reconcile returns, so an event that fires in that gap is gone. The trade is a recoverable-looking flake for a rarer unrecoverable one. A periodic re-reconcile in dir-runtime would make the ordering irrelevant and is the real fix. The mechanism above is reproduced, not just read out of the source. Running the suite locally with a 90s delay before the record push, to stand in for a slow runner, fails on the old ordering and passes on this one. The failing run exhausts all six attempts on `record not found`, gives up about ten seconds before the record lands, and exits 201, the code this issue reports. Boot reconciliation logs `workloads_registered=1` before the change and 0 after. That reason was "possible schema drift on the runtime side," which is a separate question this change does not touch: the resolution assertion compares the resolved record against the fixture with MatchJSON, and a serialization drift there fails regardless of ordering. The job is re-enabled anyway, because a disabled job cannot tell us whether either problem is real, and dir-runtime has moved 1.3.3 to 1.3.4 since. If it comes back red for drift rather than ordering, that is worth knowing and belongs in its own change. Happy to drop the re-enable from this PR and land it separately if you would rather not have it in the matrix yet. The spec did not compile as commented: `:= discoverResp[0]` had lost its variable name. It reads `workload := discoverResp[0]` again. Signed-off-by: Conor Bronsdon <[email protected]> Signed-off-by: Mark Marton <[email protected]>
…tcy#1941) The `runtime should discover docker workloads` spec was commented out and its CI job disabled because it failed intermittently. The order the testenv brings things up explains it, and it is not a race that waiting longer can win. `docker compose up` started the labelled container with the rest of the stack, ten seconds before the daemon. dir-runtime reconciles once at boot (discovery.go, the only call to reconcile), queues every workload it finds, and gives each a bounded resolve budget: six attempts, 15s apart, 30s timeout each, so roughly 75s if attempts fail fast and 255s if they time out. The record that workload references can only be pushed once the daemon is serving, from the suite's BeforeAll. On a fast runner the record lands inside the budget and the spec passes. On a slow one the budget expires first, resolveWorkload persists `{"error": ...}` into the workload's OASF field, and nothing re-queues it: the only two writers to the work queue are boot reconciliation and new docker events. The spec's three-minute Eventually cannot recover from that no matter how long it waits. So the container now sits behind a compose profile and the suite starts it in BeforeAll, after the push. The docker start event is what queues the workload, and the record is already in the store when the first attempt runs. The spec is restored split in two. Registration depends only on the daemon seeing the start event; resolution depends on the record being reachable. Separating them means a lost event reads as "the workload never appeared" within a minute, rather than as a three-minute timeout that looks like a resolver fault. The resolution half asserts the absence of the "error" key directly, so an exhausted budget reports itself instead of surfacing as a missing "cid". Four things worth stating plainly rather than leaving implicit. This narrows the window but does not close the hole, and it gives something up to do it. Registration previously had two independent triggers, boot reconciliation and the start event; the flake was that both fired too early. Deferring the container removes the reconciliation trigger outright, so registration now rests solely on the event stream, which is lossy: dir-runtime subscribes to docker events without a `since`, and starts watching only after reconcile returns, so an event that fires in that gap is gone. The trade is a recoverable-looking flake for a rarer unrecoverable one. A periodic re-reconcile in dir-runtime would make the ordering irrelevant and is the real fix. The mechanism above is reproduced, not just read out of the source. Running the suite locally with a 90s delay before the record push, to stand in for a slow runner, fails on the old ordering and passes on this one. The failing run exhausts all six attempts on `record not found`, gives up about ten seconds before the record lands, and exits 201, the code this issue reports. Boot reconciliation logs `workloads_registered=1` before the change and 0 after. That reason was "possible schema drift on the runtime side," which is a separate question this change does not touch: the resolution assertion compares the resolved record against the fixture with MatchJSON, and a serialization drift there fails regardless of ordering. The job is re-enabled anyway, because a disabled job cannot tell us whether either problem is real, and dir-runtime has moved 1.3.3 to 1.3.4 since. If it comes back red for drift rather than ordering, that is worth knowing and belongs in its own change. Happy to drop the re-enable from this PR and land it separately if you would rather not have it in the matrix yet. The spec did not compile as commented: `:= discoverResp[0]` had lost its variable name. It reads `workload := discoverResp[0]` again. Signed-off-by: Conor Bronsdon <[email protected]> Signed-off-by: Mark Marton <[email protected]>
) * fix(tests): start the discovery workload after its record exists (#1941) The `runtime should discover docker workloads` spec was commented out and its CI job disabled because it failed intermittently. The order the testenv brings things up explains it, and it is not a race that waiting longer can win. `docker compose up` started the labelled container with the rest of the stack, ten seconds before the daemon. dir-runtime reconciles once at boot (discovery.go, the only call to reconcile), queues every workload it finds, and gives each a bounded resolve budget: six attempts, 15s apart, 30s timeout each, so roughly 75s if attempts fail fast and 255s if they time out. The record that workload references can only be pushed once the daemon is serving, from the suite's BeforeAll. On a fast runner the record lands inside the budget and the spec passes. On a slow one the budget expires first, resolveWorkload persists `{"error": ...}` into the workload's OASF field, and nothing re-queues it: the only two writers to the work queue are boot reconciliation and new docker events. The spec's three-minute Eventually cannot recover from that no matter how long it waits. So the container now sits behind a compose profile and the suite starts it in BeforeAll, after the push. The docker start event is what queues the workload, and the record is already in the store when the first attempt runs. The spec is restored split in two. Registration depends only on the daemon seeing the start event; resolution depends on the record being reachable. Separating them means a lost event reads as "the workload never appeared" within a minute, rather than as a three-minute timeout that looks like a resolver fault. The resolution half asserts the absence of the "error" key directly, so an exhausted budget reports itself instead of surfacing as a missing "cid". Four things worth stating plainly rather than leaving implicit. This narrows the window but does not close the hole, and it gives something up to do it. Registration previously had two independent triggers, boot reconciliation and the start event; the flake was that both fired too early. Deferring the container removes the reconciliation trigger outright, so registration now rests solely on the event stream, which is lossy: dir-runtime subscribes to docker events without a `since`, and starts watching only after reconcile returns, so an event that fires in that gap is gone. The trade is a recoverable-looking flake for a rarer unrecoverable one. A periodic re-reconcile in dir-runtime would make the ordering irrelevant and is the real fix. The mechanism above is reproduced, not just read out of the source. Running the suite locally with a 90s delay before the record push, to stand in for a slow runner, fails on the old ordering and passes on this one. The failing run exhausts all six attempts on `record not found`, gives up about ten seconds before the record lands, and exits 201, the code this issue reports. Boot reconciliation logs `workloads_registered=1` before the change and 0 after. That reason was "possible schema drift on the runtime side," which is a separate question this change does not touch: the resolution assertion compares the resolved record against the fixture with MatchJSON, and a serialization drift there fails regardless of ordering. The job is re-enabled anyway, because a disabled job cannot tell us whether either problem is real, and dir-runtime has moved 1.3.3 to 1.3.4 since. If it comes back red for drift rather than ordering, that is worth knowing and belongs in its own change. Happy to drop the re-enable from this PR and land it separately if you would rather not have it in the matrix yet. The spec did not compile as commented: `:= discoverResp[0]` had lost its variable name. It reads `workload := discoverResp[0]` again. Signed-off-by: Conor Bronsdon <[email protected]> Signed-off-by: Mark Marton <[email protected]> * fix(skill): add reference for mcp-scanner prerequisites Signed-off-by: Mark Marton <[email protected]> --------- Signed-off-by: Conor Bronsdon <[email protected]> Signed-off-by: Mark Marton <[email protected]> Co-authored-by: Conor Bronsdon <[email protected]>
Closes #1780.
docker compose upstarted the labelledservice-a2acontainer with the rest of the stack, ten seconds before the daemon. dir-runtime reconciles once at boot, queues every workload it finds, and gives each a bounded resolve budget: six attempts, 15s apart, 30s timeout each, so roughly 75s if attempts fail fast and 255s if they time out. The OASF record that workload's label references can only be pushed once the daemon is serving, from the suite'sBeforeAll.On a fast runner the record lands inside the budget and the spec passes. On a slow one the budget expires first,
resolveWorkloadpersists{"error": ...}into the workload's OASF field, and nothing re-queues it — the only two writers to the work queue are boot reconciliation and new docker events. The three-minuteEventuallycannot recover from that at any timeout, which fits the intermittency and fits why the earlierBeforeAllreordering reduced the flake without eliminating it.What changed
service-a2amoves behind aruntime-discoverycompose profile, so the testenv no longer starts it. The suite starts it inBeforeAll, after the record push, which makes the docker start event the trigger with the record already in the store. The compose file path comes fromtest-config.yamlrather than being hardcoded, since thedefaultandexternaltestenvs share this Go package and onlyexternalhas such a workload.The spec is restored, split into registration and resolution. Registration depends only on the daemon seeing the start event; resolution depends on the record being reachable. Separating them means a lost event reads as "the workload never appeared" within a minute instead of a three-minute timeout that looks like a resolver fault. The resolution half asserts the absence of the
"error"key directly, so an exhausted budget reports itself rather than surfacing as a missing"cid".It also did not compile as commented —
:= discoverResp[0]had lost its variable name.What this does not fix, and what it costs
Registration previously had two independent triggers: boot reconciliation and the start event. The flake was that both fired too early. Deferring the container removes the reconciliation trigger outright, so registration now rests solely on the event stream, and that path is lossy — dir-runtime subscribes to docker events without a
sinceand only starts watching afterreconcilereturns, so an event landing in that gap is gone. This trades a recoverable-looking flake for a rarer unrecoverable one. A periodic re-reconcile in dir-runtime would make the ordering irrelevant, and is the real fix. I'm happy to open that upstream if you agree it belongs there.The mechanism above is derived from reading dir-runtime v1.3.4, not from logs of a failing run. Every step is in the source, but no failing run is cited.
On re-enabling the CI job
The matrix entry is re-enabled here. Two caveats:
Its TODO gave a different reason from the flake — "possible schema drift on the runtime side." That is a real and separate risk this change does not touch: the resolution assertion compares the resolved record against the fixture with
MatchJSON, and a serialization drift fails that regardless of ordering. I re-enabled it because a disabled job cannot tell us whether either problem is real, and dir-runtime has moved 1.3.3 → 1.3.4 since it was turned off.Also worth knowing: the job has been dark longer than the spec has been commented out, so
push,pull, and the cosign sign/verify specs in this suite have not run in this environment either.If you would rather not have it back in the matrix yet, say so and I will drop that hunk — the ordering fix stands on its own.
Verification
Run locally, not just in CI. The bug is timing-dependent, so a single green run proves nothing; both orderings were given the same handicap, a 90s delay before the record push, standing in for a slow runner. That is longer than the resolver's ~75s minimum budget.
workloads_registered=1workloads_registered=0event_type=added, after the pushrecord not found, exhaustedThe old-ordering run exits 201, the code #1780 reports. The resolver gave up about ten seconds before the record landed, and nothing re-queued it:
The failure also lands exactly where the split puts it: under the old ordering the registration spec still passes, and only resolution fails. The workload was never undiscovered, it was discovered too early to resolve.
Unhandicapped, the suite passes locally as it does in CI: 4 of 6 specs, 0 failed. Two skip for want of cosign.
No schema drift. The
MatchJSONcomparison against the fixture passes at dir-runtime v1.3.4, locally and in CI, which answers the question the disabled job's TODO raised.Environment: Docker 29.1.3, Compose 2.40.3, Go 1.26.5, Ubuntu 24.04.
go vet ./e2e/daemon/...clean. The ordering claims were checked against the dir-runtime v1.3.4 source, then confirmed against its logs.