feat: plumb Terraform resource address for script sync unit names#27154
Draft
SasSwart wants to merge 1 commit into
Draft
feat: plumb Terraform resource address for script sync unit names#27154SasSwart wants to merge 1 commit into
SasSwart wants to merge 1 commit into
Conversation
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.
Docs preview📖 View docs preview for |
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.
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), notmain.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
DisplayNamenever reaches the agent:dbAgentScriptToProtoincoderd/agentapi/manifest.godropped it when building the manifest. Every script therefore arrived with an empty name and was skipped at registration, so nothing (e.g. thecode-servermodule'scoder_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:provisionersdk/proto/provisioner.protoresource_address(field 10) toScriptprovisioner/terraform/resources.goresource.Address000543resource_addresscolumn toworkspace_agent_scripts; plumb through the insertcoderd/provisionerdserverresource_addressinto insert paramsagent/proto/agent.protoresource_address(field 11) toWorkspaceAgentScriptcoderd/agentapi/manifest.goDisplayNamemapping (pre-existing bug) + addResourceAddresscodersdk/workspaceagents.go,agentsdk/convert.goagent/agentscripts/agentscripts.goscriptUnitName()prefersResourceAddress, falls back toDisplayNameGenerated artifacts (
*.pb.go,queries.sql.go,models.go,dump.sql, apidoc/swagger, TS types, terraform goldens) were regenerated withmake gen.Rebase notes
agentsocket.NewServerto take*unit.Manageras a required positional parameter (and touched the socket test call sites). The stack already introduces that composition root via aWithUnitManageroption, so those edits are dropped here.agentscriptsregistration from feat(agent): register scripts as sync units for lifecycle tracking #27153 is refactored in place to usescriptUnitName().000526→000543(next free number on the current tree).Testing
make gen(regenerates DB/proto/docs/TS; applies the migration against Postgres to producedump.sql)go build ./...go test ./agent/agentscripts/ ./provisioner/terraform/ ./coderd/agentapi/(script-unit, resource conversion, and manifest tests)gofmtand emdash checks cleanAfter this,
code-server(and every other module script) registers under its resource address and appears incoder exp sync timeline.Generated by Coder Agents on behalf of @SasSwart.