Skip to content

investigate coder_script ordering methods #759

@stirby

Description

@stirby

Problem

We want to tackle execution ordering for coder_script in H2 2025. As discussed with the mango team, we need an engineer to investigate two potential options before committing to an RFC and timeline.

The outcome of this investigation should tell us for each approach:

  • How long it would take a single engineer to ship a working MVP (above all else)
  • Any existing tools that may be used to achieve the MVP
  • Potential (major) technical hurdles associated in implementation

Then, it is the responsibility of product to:

  • Identify potential limitations on the resulting user experience
  • Reach out to customers on whether the proposed solutions solve their trouble
  • investigate usage in telemetry

Option 1 optimizes for delivery while satisfying most use cases, and option 2 focuses on elegance and permanence.

Option 1: Grouped execution ordering

In a coder_script, you may define an execution_group that determines the sequence in which scripts will be run. You may guarantee the s scripts in execution group n>m will run after others in group m. All scripts in a given group will run in parallel as they do today. The default group is 0(?) for backward compatibility. This allows most scripts to be run in parallel, but still provides rudimentary ordering.

resource "coder_script" "first_script" {
    ...
    exec_group = 1
}

resource "coder_script" "second_script" {
    ...
    exec_group = 2
}

resource "coder_script" "third_script" {
    ...
    exec_group = 5     # gaps allowed
}

Option 2: Signal based

We introduce new command line tools for sending or waiting on signals in bash like so:

coder script waitfor "mysignal"
coder script signal "mysignal"

Thus, the execution ordering is defined in the bash script, and signals can be hit/waited upon arbitrarily in the scripts. One drawback is that we can't parse the script ordering from Terraform easily. There is potential to use this outside of the agent context, but for the sake of this investigation we're only focused on coder_script utilization

Metadata

Metadata

Assignees

Labels

spikeShort investigation task

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions