Repository navigation
refactor(template): key resources by Dev Container instance (plan 004 Phase A) - #65
Closed
alexanderilyin wants to merge 1 commit into
Closed
alexanderilyin wants to merge 1 commit into
alexanderilyin wants to merge 1 commit into
Conversation
Plan 004 Phase A: a list of one, with no behavior change. The agent, its scripts, apps and env, the vscode modules, the PVC, the Deployment and the devcontainer data source are for_each over local.instances, which is `main` built from devcontainerbuilder_build.workspace's image and resolved_* attributes. The runtime-mapping locals are maps keyed by instance, read through local.rt[each.key]; their logic is unchanged. The agent stays coder_agent.main: Coder names an agent after its Terraform resource name, so renaming it would rename existing agents. `main` keeps its Kubernetes names, labels and selector. moved blocks map every old address to ["main"]; with mock providers, origin/main's state plans as moves only, for a running and a stopped workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Member
Author
|
Abandoned: multiple Dev Container configurations are dropped before 1.0 (see the revert of #60). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan 004 Phase A: the template becomes per-instance, as a list of one (
main), with no behavior change.What changed
local.instances = { main = { image, registry, name, tag } }, built fromdevcontainerbuilder_build.workspace(image,resolved_registry,resolved_name,resolved_tag). Phase B swaps this fordevcontainerbuilder_build.workspace.images, which has the same fields.local.started_instancesis the start_count-gated subset.for_eachover instances:data.devcontainerbuilder_devcontainer.workspace,coder_agent.main, the 3coder_scripts, the 7coder_envs,coder_app.forwarded_port(keyed"<instance>/<slot>"),module.vscode_web,module.vscode_desktop,kubernetes_persistent_volume_claim_v1.data,kubernetes_deployment_v1.main.local.xbecomeslocal.x[inst]). Resources read them throughlocal.rt[each.key]. The checks aggregate across instances, and their messages are identical formain.mainkeepscoder-<ws>andcoder-<ws>-data, and all of its labels and its selector (unchanged, because selectors are immutable). Any other instance gets-<id>in its names and inapp.kubernetes.io/instance, pluscom.deepspacecartel.devcontainer-builder/instance=<id>. Without theapp.kubernetes.io/instancechange,main's selector would also match their pods. The Deployment's labels, selector and pod labels share onelocal.deployment_labels.mainkeepsport-<n>, and other instances get<id>-port-<n>(Coder requires slugs to be unique across agents).movedblocks for every old address. Terraform >= 1.1 is needed; the template already requires >= 1.5.Deviation: the agent is not renamed to
devCoder names an agent after its Terraform resource name, not a
nameargument or the for_each key:provisioner/terraform/resources.goConvertStatesetsName: tfResource.Nameand errorsduplicate agent namewhen two share it. Renaming the resource tocoder_agent.devwould rename every existing workspace's agent to "dev". It stayscoder_agent.main.This blocks Phase B as planned: a
for_eachovercoder_agentwith two or more keys fails in Coder withduplicate agent name: main. Running one agent per image needs a different shape, such as statically declared agent slots orcoder_devcontainersub-agents. The per-instance PVC, Deployment, scripts and apps carry over to either shape. The vscode-web and vscode-desktop module slugs would also collide across agents. This is written up in plan 004's status.Verification (offline, mock providers)
I used a scratch
terraform testharness, not committed. It hasmock_providerblocks for coder, kubernetes and devcontainerbuilder, and a richdevcontainerbuilder_devcontainerfixture with mounts (including one that collides), ports,customizations.kubernetes, hostRequirements, capAdd and a missing localEnv. For each scenario:origin/main'smain.tf.state_key).0 to add, 0 to change, 0 to destroy0/0/0The plan has no value changes and no sensitivity-mark changes:
local.dckeepsone(...), so marks collapse as before. With no value diff, a real provider can't plan a replacement either. Mock providers never reportRequiresReplacethemselves, which is why the zero-change result is the meaningful one.A second scratch run with a hypothetical extra
backendinstance applied cleanly. It gotcoder-<ws>-backendandcoder-<ws>-backend-data, the instance label on its selector only, slugsbackend-port-N, and the image…/app-backend:<tag>.terraform fmt -checkandterraform validatepass.Live check still needed
coder templates push <scratch-template> -d templates/coder-kubernetes, with your usual-vars.has moved to …["main"](…["main/N"]for ports).Plan: 0 to add, 0 to change, 0 to destroy.must be replaced, and nowill be destroyed.kubectl -n <ns> get pvc coder-<ws-id>-datakeeps its age. The pod is not recreated, unless Coder's update does stop then start itself; even then the PVC must stay.mainand connects. The apps work: VS Code Web, VS Code Desktop, and forwarded ports.If the template's
max_forwarded_portsis above 10, slots 10 and up are recreated rather than moved. That only re-registers the apps in Coder.🤖 Generated with Claude Code