Skip to content

refactor(templates): DRY the two remaining byte-identical startup blocks - #195

Merged
rfay merged 2 commits into
mainfrom
20260806_dry_startup_common
Aug 8, 2026
Merged

refactor(templates): DRY the two remaining byte-identical startup blocks#195
rfay merged 2 commits into
mainfrom
20260806_dry_startup_common

Conversation

@rfay

@rfay rfay commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Follow-up to fix(startup): self-heal nested Docker daemon after in-place container restart #194: two more sections of the per-template startup_script were duplicated byte-for-byte identically across all three templates (confirmed via diff, unlike other similar-looking sections that have already drifted in small ways) — the Docker registry-mirror configuration and the ~/.bashrc symlink-safety guard.
  • Registry-mirror config now lives in modules/docker-daemon (it configures /etc/docker/daemon.json right before the daemon starts, so it belongs with the rest of the Docker lifecycle logic already there); the module gained a docker_registry_mirror input variable that each template passes through from its own variable of the same name.
  • The bashrc-symlink guard needs no variables and creates no resource, so it's vendored as a plain shared/bashrc-symlink-guard.sh (same vendoring technique as shared/vscode-extensions.tf) and pulled into each startup_script via file("${path.module}/bashrc-symlink-guard.sh").
  • Net: 16 files touched, -144/+228 (the extra insertions are the vendored per-template copies + module scaffolding; the net duplication removed from the three template.tf files themselves is ~140 lines).

Depends on #194 (this branch is stacked on 20260806_docker_survival since it extends the docker-daemon module that PR introduces) — will need a rebase once that merges, but the two PRs don't touch overlapping lines so there's no actual conflict.

Test plan

  • terraform fmt -recursive clean
  • make validate — all three templates valid
  • make test-templates — all Terraform mock tests pass
  • Pushed to staging-coder.ddev.com and updated workspace d12-1: registry mirror still auto-detected/configured (Detected registry mirror on Coder host: ...), Docker daemon started cleanly, all DDEV containers came up healthy

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-08 02:32 UTC

rfay and others added 2 commits August 7, 2026 18:30
Registry-mirror configuration and the ~/.bashrc symlink-safety guard
were duplicated verbatim across all three templates' startup scripts
(the docker-daemon logic was already extracted in a prior commit).
Unlike other similar-looking sections of these scripts, these two were
confirmed byte-for-byte identical across all three, so extracting them
changes nothing behaviorally.

- Registry-mirror config folds into the existing modules/docker-daemon
  module (it configures /etc/docker/daemon.json right before the
  daemon starts, so it belongs with the rest of the Docker lifecycle
  logic); the module gains a docker_registry_mirror input variable
  that each template now passes through from its own variable of the
  same name.
- The bashrc-symlink guard needs no variables and creates no resource,
  so it's vendored as a plain shared/bashrc-symlink-guard.sh (same
  vendoring technique as shared/vscode-extensions.tf) and pulled into
  each startup_script via file("${path.module}/bashrc-symlink-guard.sh").

Verified on staging-coder.ddev.com (d12-1): registry mirror still
auto-detected and configured, Docker daemon still starts cleanly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rfay
rfay force-pushed the 20260806_dry_startup_common branch from 033a07c to 8ed27fb Compare August 8, 2026 00:31
@rfay
rfay merged commit 1e3b00e into main Aug 8, 2026
19 of 20 checks passed
@rfay
rfay deleted the 20260806_dry_startup_common branch August 8, 2026 02:32
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