feat(agent): plumb Terraform resource address for script unit names#26463
Draft
SasSwart wants to merge 1 commit into
Draft
feat(agent): plumb Terraform resource address for script unit names#26463SasSwart wants to merge 1 commit into
SasSwart wants to merge 1 commit into
Conversation
The script runner now registers each script as a sync unit during Init() so all scripts are immediately visible via 'coder exp sync list'. As each script executes, its unit status transitions from pending to started, then to completed. Changes: - agent/agentsocket/server.go: NewServer takes *unit.Manager as a required parameter instead of creating its own internally. - agent/agentscripts/agentscripts.go: Options gains a UnitManager field. Init() registers scripts using DisplayName as the unit ID. run() sets unit status to started before execution and completed after. - agent/agent.go: Creates a shared unit.Manager and passes it to both the script runner and the socket server. - Tests: Updated NewServer call sites; added TestScriptUnitsRegistered and TestScriptUnitsLifecycle.
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.
Follow-up to #26459. Plumbs the Terraform resource address through the full pipeline so the script runner can use it as a unique, human-friendly sync unit identifier.
Problem
#26459 used
DisplayNameas the sync unit name, which is not guaranteed unique and was also not being set in the agent manifest (pre-existing bug indbAgentScriptToProto).Changes
Adds
resource_addressacross every layer:provisionersdk/proto/provisioner.protoresource_addressfield 10 toScriptprovisioner/terraform/resources.goresource.Address(e.g.module.dev.coder_script.install_tools)resource_addresscolumn toworkspace_agent_scriptscoderd/provisionerdserver/agentScriptsParamsand INSERTagent/proto/agent.protoresource_addressfield 11 toWorkspaceAgentScriptcoderd/agentapi/manifest.goDisplayNamemapping (pre-existing bug) + addResourceAddresscodersdk/workspaceagents.go,agentsdk/convert.gocoderd/database/db2sdk/agent/agentscripts/agentscripts.goscriptUnitName()prefersResourceAddress, falls back toDisplayNameThe Terraform resource address is available from
tfjson.StateResource.Addresswithout any Terraform provider changes. For multi-module setups, addresses look likemodule.dev_setup.coder_script.install_tools, providing both uniqueness and readability.