Skip to content

Fix races by implementing our own incus client fork - #132

Merged
jochumdev merged 9 commits into
lxc:mainfrom
jochumdev:fix/races
Aug 10, 2026
Merged

Fix races by implementing our own incus client fork#132
jochumdev merged 9 commits into
lxc:mainfrom
jochumdev:fix/races

Conversation

@jochumdev

Copy link
Copy Markdown
Member

No description provided.

The upstream client shares state between a connection, its event
listeners and the operations running on it, so one InstanceServer cannot
be driven from several goroutines. A second GetEvents joins the first
caller's listener and inherits its type filter, so an operation waiting
on a type=operation event never sees it; skipEvents races on top.

iclient holds nothing mutable, gives every listener a socket of its own,
takes a context per call and reports operations as channels. Nothing
uses it yet.

Signed-off-by: René Jochum <rene@jochum.dev>
Every worker drove one shared Incus client, whose event-listener state
cannot be used from more than one goroutine. They now share an
iclient.Connection, which is safe to share, and the per-resource
connection copies that worked around it are gone.

The races that sat on top of it go with it: two workers setting up the
image lock volume at once, simultaneous starts resolving which
ic-healthd watches the project, and a wait for an instance's addresses
that trusted a lifecycle event.

A registry is now somewhere the server is pointed at rather than
something we dial, so --pull always re-downloads instead of comparing
digests. A busy instance is matched on a sentinel, not on the wording of
the error, and the retry that waits for a cached image respects its
context and the five minutes it claims.

Signed-off-by: René Jochum <rene@jochum.dev>
It picked the newest log with `ls -t | head -1`, which leaves ls writing
into a closed pipe; under pipefail that SIGPIPE failed the recipe before
it printed anything. The no-pattern branch had the same problem one
level up, so `just test-log | head` failed too.

Also runs the tests with -race and checks formatting in lint.

Signed-off-by: René Jochum <rene@jochum.dev>
Signed-off-by: René Jochum <rene@jochum.dev>
Signed-off-by: René Jochum <rene@jochum.dev>
Signed-off-by: René Jochum <rene@jochum.dev>
Signed-off-by: René Jochum <rene@jochum.dev>
Signed-off-by: René Jochum <rene@jochum.dev>
@jochumdev
jochumdev merged commit 9536a0f into lxc:main Aug 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant