Skip to content

fix(tests): start the runtime discovery workload after its record exists - #1941

Merged
paralta merged 1 commit into
agntcy:mainfrom
conorbronsdon:fix/runtime-discovery-ordering
Jul 31, 2026
Merged

paralta merged 1 commit into
agntcy:mainfrom
conorbronsdon:fix/runtime-discovery-ordering

Conversation

@conorbronsdon

@conorbronsdon conorbronsdon commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Closes #1780.

docker compose up started the labelled service-a2a container 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'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 three-minute Eventually cannot recover from that at any timeout, which fits the intermittency and fits why the earlier BeforeAll reordering reduced the flake without eliminating it.

What changed

service-a2a moves behind a runtime-discovery compose profile, so the testenv no longer starts it. The suite starts it in BeforeAll, after the record push, which makes the docker start event the trigger with the record already in the store. The compose file path comes from test-config.yaml rather than being hardcoded, since the default and external testenvs share this Go package and only external has 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 since and only starts watching after reconcile returns, 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.

old ordering with this change
boot reconcile workloads_registered=1 workloads_registered=0
registration at boot, before the record can exist event_type=added, after the push
resolver attempts 1→6, every one record not found, exhausted resolves first try
suite FAIL — 3 passed, 1 failed PASS — 4 passed, 0 failed
exit code 201 0

The 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:

attempt=6 max_attempts=6 error="failed to pull OASF record baeareiabbog2...:
  rpc error: code = NotFound desc = failed to pull record: record not found"

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 MatchJSON comparison 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.

@github-actions github-actions Bot added the size/S Denotes a PR that changes 50-199 lines label Jul 30, 2026
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

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]>
@conorbronsdon
conorbronsdon force-pushed the fix/runtime-discovery-ordering branch from 83f01d9 to 0395eba Compare July 31, 2026 00:20
@conorbronsdon

Copy link
Copy Markdown
Member Author

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:

Summarizing 1 Failure:
  [FAIL] Daemon e2e runtime workflow [It] runtime should resolve the workload's OASF record

  [FAILED] Timed out after 180.004s.
  resolver gave up before the record was reachable: failed to pull OASF record
  baeareiabbog2umgduqhlcb64fzt6adn34kblzvru3fdzkl75hjhwt6h3da: rpc error:
  code = NotFound desc = failed to pull record: record not found

Two things that were guesses when I opened this are now observed.

The NotTo(HaveKey("error")) assertion is what fires, so the diagnostic names the cause outright. Without it the same run fails on a missing cid key, which reads as "the resolver produced the wrong record" when what actually happened is that it gave up minutes earlier. That was the argument for asserting the error key directly, and this is it working.

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.

@conorbronsdon
conorbronsdon marked this pull request as ready for review July 31, 2026 01:00
@conorbronsdon
conorbronsdon requested a review from a team as a code owner July 31, 2026 01:00

@paralta paralta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@paralta
paralta merged commit a3bf90e into agntcy:main Jul 31, 2026
32 checks passed
markpmarton pushed a commit to markpmarton/dir that referenced this pull request Aug 3, 2026
…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]>
markpmarton pushed a commit to markpmarton/dir that referenced this pull request Aug 3, 2026
…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]>
paralta pushed a commit that referenced this pull request Aug 3, 2026
)

* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 50-199 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Test / E2E / Daemon External fails intermittently

2 participants