Skip to content

feat: plumb Terraform resource address for script sync unit names#27154

Draft
SasSwart wants to merge 1 commit into
sas/script-units-on-timelinefrom
sas/script-resource-address-on-timeline
Draft

feat: plumb Terraform resource address for script sync unit names#27154
SasSwart wants to merge 1 commit into
sas/script-units-on-timelinefrom
sas/script-resource-address-on-timeline

Conversation

@SasSwart

Copy link
Copy Markdown
Contributor

Revives #26463 (closed as stale) and rebases it onto the top of the Script Coordination timing stack, directly on top of #27153. This makes agent scripts actually show up in coder exp sync timeline / --watch.

Stacked on: #27153#27152#27150#27149. Base is sas/script-units-on-timeline (the #27153 branch), not main.

Why this is needed

#27153 registers each agent script as a sync unit keyed on its name, but on the current stack a script's DisplayName never reaches the agent: dbAgentScriptToProto in coderd/agentapi/manifest.go dropped it when building the manifest. Every script therefore arrived with an empty name and was skipped at registration, so nothing (e.g. the code-server module's coder_script) appeared in the timeline. This PR fixes that propagation and adds a unique, human-friendly unit name.

Changes

Plumbs resource_address (the Terraform resource address, e.g. module.code-server.coder_script.code-server) end to end, and fixes the manifest bug:

Layer File Change
Provisioner proto provisionersdk/proto/provisioner.proto Add resource_address (field 10) to Script
Terraform provisioner/terraform/resources.go Populate from resource.Address
Database migration 000543 Add resource_address column to workspace_agent_scripts; plumb through the insert
Provisioner server coderd/provisionerdserver Carry resource_address into insert params
Agent proto agent/proto/agent.proto Add resource_address (field 11) to WorkspaceAgentScript
Manifest coderd/agentapi/manifest.go Fix: add missing DisplayName mapping (pre-existing bug) + add ResourceAddress
SDK codersdk/workspaceagents.go, agentsdk/convert.go Add field to the type and both conversions
Script runner agent/agentscripts/agentscripts.go scriptUnitName() prefers ResourceAddress, falls back to DisplayName

Generated artifacts (*.pb.go, queries.sql.go, models.go, dump.sql, apidoc/swagger, TS types, terraform goldens) were regenerated with make gen.

Rebase notes

Testing

  • make gen (regenerates DB/proto/docs/TS; applies the migration against Postgres to produce dump.sql)
  • go build ./...
  • go test ./agent/agentscripts/ ./provisioner/terraform/ ./coderd/agentapi/ (script-unit, resource conversion, and manifest tests)
  • gofmt and emdash checks clean

After this, code-server (and every other module script) registers under its resource address and appears in coder exp sync timeline.


Generated by Coder Agents on behalf of @SasSwart.

Follow-up to the script-unit registration. Plumbs the Terraform resource
address through the full pipeline so the script runner can use it as a
unique, human-friendly sync unit identifier, and fixes a pre-existing bug
where a script's DisplayName was never propagated into the agent manifest.

- provisionersdk/proto: add resource_address to Script.
- provisioner/terraform: populate ResourceAddress from resource.Address.
- database: migration 000543 adds resource_address to workspace_agent_scripts;
  plumb through InsertWorkspaceAgentScripts.
- coderd/provisionerdserver: carry resource_address into the insert params.
- coderd/agentapi/manifest: fix missing DisplayName mapping and add
  ResourceAddress to dbAgentScriptToProto.
- agent/proto + SDK: add resource_address to WorkspaceAgentScript and both
  conversions.
- agent/agentscripts: scriptUnitName() prefers ResourceAddress, falls back
  to DisplayName. Registration and status updates key on it.

Rebased onto the sync-timeline-watch stack: revives #26463 without
re-introducing its NewServer signature change (the stack already exposes a
WithUnitManager option). Migration renumbered 000526 -> 000543.
@github-actions

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/reference/api/agents.md

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