Skip to content

fix(provisioner): stop rogue config-missing restart loop (#17) - #48

Merged
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/issue-17-rogue-restart-loop
Apr 14, 2026
Merged

fix(provisioner): stop rogue config-missing restart loop (#17)#48
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/issue-17-rogue-restart-loop

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Resolves #17.

Part A — E2E cleanup

  • New scripts/cleanup-rogue-workspaces.sh: deletes workspaces whose id or name starts with known test placeholder prefixes (aaaaaaaa-, bbbbbbbb-, cccccccc-, test-ws-) via the API and force-removes the ws-<id[:12]> container as a belt-and-suspenders fallback.
  • Documented in tests/README.md.
  • No E2E test currently uses the aaaaaaaa- pattern (grep found zero hits in tests/**), so the rogue was from a manual/adhoc run. Nothing to patch in the test scripts.
  • Ran the script locally against localhost:8080 — no rogue workspace currently present on the platform (already cleaned up between issue filing and PR).

Part B — provisioner pre-flight

  • New pure helper provisioner.ValidateConfigSource(templatePath, configFiles) — returns ErrNoConfigSource when neither source supplies config.yaml.
  • New Provisioner.VolumeHasFile(ctx, id, relPath) — probes the workspace's Docker named volume via a throwaway alpine test -f container.
  • provisionWorkspace now calls both: when a restart path passes empty templatePath + configFiles (auto-restart flow in workspace_restart.go:215,335) AND the named volume has no config.yaml, the handler marks the workspace status='failed' with a clear last_sample_error and broadcasts WORKSPACE_PROVISION_FAILED instead of handing the doomed container to Docker's unless-stopped restart policy.
  • Docker restart policy is deliberately unchanged — the happy path still benefits from it.

Test plan

  • go build ./... && go vet ./... clean
  • go test -race ./... all packages pass (provisioner + handlers)
  • New tests: TestValidateConfigSource_* x6 (configFiles present / empty bytes / template has config / template missing / both empty / config.yaml-as-dir)
  • tests/e2e/test_api.sh 62/62 pass
  • Verified cleanup script reaches the live platform (no matching workspaces currently)

🤖 Generated with Claude Code

Resolves #17.

Part A: scripts/cleanup-rogue-workspaces.sh deletes workspaces whose id
or name starts with known test placeholder prefixes (aaaaaaaa-, etc.)
and force-removes the paired Docker container. Documented in
tests/README.md.

Part B: add a pre-flight check in provisionWorkspace() — when neither a
template path nor in-memory configFiles supplies config.yaml, probe the
existing named volume via a throwaway alpine container. If the volume
lacks config.yaml, mark the workspace status='failed' with a clear
last_sample_error instead of handing it to Docker's unless-stopped
restart policy (which otherwise loops forever on FileNotFoundError).

New pure helper provisioner.ValidateConfigSource + unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit marked this pull request as ready for review April 14, 2026 14:33
@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit cc9f181 into main Apr 14, 2026
7 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/issue-17-rogue-restart-loop branch April 14, 2026 15:12
@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor Author

7-gate verification passed; merged. Resolves #17 — rogue config-missing restart loop is now caught by the pre-flight ValidateConfigSource + VolumeHasFile probe, and any such workspace is flipped to status='failed' with a WORKSPACE_PROVISION_FAILED broadcast instead of being handed to Docker's unless-stopped loop. All 6 new TestValidateConfigSource_* tests pass under -race.

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.

Provisioner: rogue test workspace in restart loop — no config.yaml, restarts forever

1 participant