Skip to content

fix(k3s): order coder.service after coder-k3s-namespace#24

Open
bpmct wants to merge 2 commits into
mainfrom
fix/coder-workspaces-namespace-race
Open

fix(k3s): order coder.service after coder-k3s-namespace#24
bpmct wants to merge 2 commits into
mainfrom
fix/coder-workspaces-namespace-race

Conversation

@bpmct

@bpmct bpmct commented Jun 15, 2026

Copy link
Copy Markdown
Member

On a cold boot, Coder could start provisioning before the coder-k3s-namespace oneshot had created the coder-workspaces namespace, so the first workspace build failed with:

Error: namespaces "coder-workspaces" not found

The namespace then appeared seconds later (the oneshot is only wantedBy = multi-user.target, with no ordering vs. coder.service), leaving the workspace stuck in a failed state until a manual rebuild/retry.

Observed live on a box: a k3s-podman workspace build failed at 20:20:33; coder-workspaces was created at 20:21:08 — 35 s too late. Re-running the build then succeeded with no other change.

Fix

Add to the systemd.services.coder overlay in both nixos/k3s-podman.nix and nixos/k3s-sysbox.nix:

after    = [ "coder-k3s-namespace.service" ];
requires = [ "coder-k3s-namespace.service" ];

coder-k3s-namespace already orders itself after k3s + the kubeconfig fix, so this guarantees the namespace exists before Coder runs its first coder-init-admin template deploy / workspace build.

Validation

  • nixos-rebuild dry-build --flake /etc/nixos-repo — evaluates clean.

bpmct added 2 commits June 15, 2026 22:06
On a cold boot Coder could start provisioning before the
coder-k3s-namespace oneshot had created the coder-workspaces namespace,
so the first workspace build failed with:

    Error: namespaces "coder-workspaces" not found

(the namespace then appeared seconds later, leaving the workspace stuck
in a failed state until a manual rebuild).

Add after + requires = [ "coder-k3s-namespace.service" ] to the
coder.service overlay in both k3s-podman.nix and k3s-sysbox.nix so the
namespace is guaranteed to exist before Coder runs its first
template-sync / workspace build.
@bpmct bpmct requested a review from phorcys420 June 15, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant