-
Notifications
You must be signed in to change notification settings - Fork 881
feat: allow execution ordering for coder_script
#10352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'd actually call this a bug. We don't know a priori that scripts are safe to run concurrently. In particular, I use dotfiles to install software on startup, and this fails if other scripts are also doing dpkg stuff
|
It could be done in multiple ways,
resource "coder_script" "dotfiles" {
agent_id = coder_agent.main.id
...
}
resource "coder_script" "personalize" {
agent_id = coder_agent.main.id
...
run_after = coder_script.dotfiles
}
resource "coder_script" "dotfiles" {
agent_id = coder_agent.main.id
...
order = "1"
}
resource "coder_script" "personalize" {
agent_id = coder_agent.main.id
...
order = "2"
}
resource "coder_script" "dotfiles" {
agent_id = coder_agent.main.id
...
}
resource "coder_script" "personalize" {
agent_id = coder_agent.main.id
...
depends_on = ["coder_script.dotfiles"]
} I am not very sure how we can expose this on module level and how the |
I think it'd be neat if |
I strongly prefer a |
This is a prerequisite for coder/registry#82 |
We had a chat with @kylecarbs on this yesterday. Here are some conclusions.
|
This is getting complex enough that we should have an RFC, IMO. But, since I'm thinking about it right now, I'll add some comments directly to the issue.
One big downside of Another related issue is that a module author might know what it is dependent on, but not which module provides it. Some dependencies might not be provided by any modules and instead are baked in. For example, my module might require Therefore, I think we need to be able to define module dependencies in the template, so that the template author has flexibility to control dependencies, rather than forcing the module author to. One last comment is that modules generally don't expose their scripts as outputs, so we need to handle all combinations of module and script dependencies. Then, in the terraform provisioner, we can resolve the DAG of scripts & modules into a DAG of just scripts.
|
I agree with @spikecurtis reservation and on having an RFC on this. My thoughts:
|
WorkaroundFor those looking for this behavior today, you can use a bash |
This kind of works, but there are many other cases, like |
We are using more than 16 scripts at startup. Some of them has to wait until git cloned has finished. Other has to wait for other scripts or at least part of it. We are providing 2 simple bash scripts to realize the sendSignal and waitFor. This creates a file under /tmp and the other waits in a while loop until it is created. This way we can build our own DAG. NOTE: Sending signals should be possible at any time or any place. Not just at the edges of entry and exit points! This works pretty stable. But it would be nice if there was something similar as build in function without needing to store files in a temporary filesystem. For me I could think of storing signals at workspace level. coder signal git-cloned # This sends the signal to coder server
coder waitfor git-cloned # wait until signal "git-clond" has been send to coder server @michaelbrewer I can say this works as expected |
Oh thanks. I need to add this to my going list of notes. |
If you are running into dpkg locks you can use |
I would like to add support for coder signals for some of the common coder terraform modules like git-clone etc. |
I like this.
But I would add I'd also like to add that this is inherently prevalent with the new KasmVNC module. |
I noticed that most of the solutions here seem to focus on running something after another script has finished. This is probably the most common use case. But I think it's equally important to be able to define the inverse dependency, which means telling a coder module or script to wait for my script to finish. Simple use-case: Modify apt mirrors before other scripts install tools for better performance. The I think it would be great if we could create an RFC on this. |
My high level view is that the Coder agent is essentially playing the role of an init system, especially in containerized deployments (VMs can use the init system that comes with the OS in many cases). As such, we should pay attention to prior art in designing what we are going to do. Let's try to avoid redesigning the wheel, or designing it piecemeal without the long term view of what it is. |
That's exactly right, @spikecurtis and so far we've implemented a very basic init for start, shutdown and cron. Even running services is currently just a hack on top of "start" and we don't support service restart or stop either. I agree it would be great if we didn't have to redesign the wheel, but we may have to recreate it. As a hypothetical, let's say we make Portability is a big concern though, and a reason we can't use |
Overview
Currently, when building a workspace with multiple instances of
coder_script
, all are run concurrently, preventing any sequencing logic. To remedy this, some serialization should be implemented allowing users to either define the sequence manually or through a dependency graph.The text was updated successfully, but these errors were encountered: