Avoid race conditions when adding remotes in `configure_buildd_image_remote`
Metadata
Current evaluation
Fixed in merged PR #158 (commit 3069492): remote creation now rechecks after an add failure, avoiding concurrent setup races. The deprecated function was later removed in b9c60b6.
Resolution: closed resolved
Reason: PR #158 was merged as commit 3069492. It suppresses remote_add failures when a concurrent process has already created the remote, while re-raising genuine errors.
Evaluated by: mr-cal-bot
No scores available.
Issue body
The function `configure_buildd_image_remote` in `craft_providers/lxd/remotes.py` should support being executed in parallel.
Currently there are race conditions where the check to see if `BUILDD_REMOTE_NAME in lxc.remote_list()` fails, but then other process creates it, and the `remote_add` call two lines below fails.
We could do something like the following:
```
if BUILDD_REMOTE_NAME in lxc.remote_list():
logger.debug("Remote %r already exists.", BUILDD_REMOTE_NAME)
else:
try:
lxc.remote_add(
remote=BUILDD_REMOTE_NAME,
addr=BUILDD_REMOTE_ADDR,
protocol="simplestreams",
)
logger.debug("Remote %r was successfully added.", BUILDD_REMOTE_NAME)
except Exception:
# re-checking in case the error comes from a creation race condition:
if BUILDD_REMOTE_NAME not in lxc.remote_list():
# nop, expose the problem
raise
return BUILDD_REMOTE_NAME
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed in merged PR #158 (commit 3069492): remote creation now rechecks after an add failure, avoiding concurrent setup races. The deprecated function was later removed in b9c60b6. | |
| qwen/qwen3.6-35b-a3b | — | closed resolved | Fixed race condition in configure_buildd_image_remote by adding retry logic when adding LXD remotes. Resolved in craft-providers#158. Function later deprecated and removed in commit b9c60b6. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
canonical/craft-providers#158
(confidence 100%)
Merged fix for the remote-add race reported in issue #96.
-
Related To:
craft-providers#b9c60b6
(confidence 95%)
Later removed the deprecated configure_buildd_image_remote function after the race fix.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #318 lxd(remotes): fix deprecation warnings | craft-providers | merged | Merged PR #318 corrected the configure_buildd_image_remote deprecation warning so its replacement advice was accurate, resolving #260. |