Commit b52aa96
Fix Codespaces prebuild k3d startup (#189)
## Summary
- keep `onCreateCommand` prebuild-safe by moving k3d cluster creation
out of it
- create the k3d cluster lazily from `postStartCommand` for real
codespaces
- make the `postStartCommand` environment setup idempotent across
restarts
## Why
Recent Codespaces prebuilds for `.devcontainer/devcontainer.json` have
been intermittently failing after the devcontainer setup completes,
during GitHub's template/snapshot phase:
```text
Jobs failed, exiting the agent. Job 'ShrinkExt4' did not succeed.
```
The prebuild logs show `onCreateCommand` successfully creating a k3d
cluster before GitHub tries to snapshot/shrink the filesystem.
Codespaces prebuilds run `onCreateCommand`, so leaving nested Docker/k3d
state around during the snapshot step is risky and appears to be the
source of the flake.
GitHub docs confirm prebuilds run setup through `onCreateCommand` before
taking the snapshot:
https://docs.github.com/en/codespaces/prebuilding-your-codespaces/about-github-codespaces-prebuilds#the-prebuild-process
## Validation
- `bash -n .devcontainer/onCreateCommand.sh`
- `bash -n .devcontainer/postStartCommand.sh`
- Ran `postStartCommand.sh` twice with `SKIP_K3D_CLUSTER_CREATE=1` and a
temp home to verify `.bashrc` updates are idempotent.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent 0072eb6 commit b52aa96
2 files changed
Lines changed: 50 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
4 | 2 | | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments