Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use parameters to select a provisioner #5979

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

Closed
bpmct opened this issue Feb 2, 2023 · 23 comments
Closed

Use parameters to select a provisioner #5979

bpmct opened this issue Feb 2, 2023 · 23 comments
Assignees
Labels
customer-requested Features requested by enterprise customers. Only humans may set this. parameters Area: parameters roadmap https://coder.com/roadmap. Only humans may set this.

Comments

@bpmct
Copy link
Member

bpmct commented Feb 2, 2023

We have a little-known feature that allows someone to run external provisioners outside of the coder server. However, there are some cases where a workspace owner wants to guarantee which "external provisioner/runner" their workspace is built on.

  • Runners in specific clouds/datacenters
  • Runners on a developer's local machine

Templates can tag which runners they are compatible with, but this isn't done done per-workspace (a workspace may be re-built on a different runner with the same tag, leading to data loss or a failed build).

With an immutable, dynamic, runner parameter on the β€œcreate workspace” page, we can do both! Instead of hardcoded values, Coder pulls the list of available runners and perhaps shows latency.

image

We could also consider this for our dogfood template, removing provisioning load from the Coder server and relying on runners on each bare metal instance to provision containers with their respective local docker sockets. This has an added advantage of builds not failing when we redeploy Coder (we constantly update our dogfood environment when a new commit is merged into main)

Note
In most (to all) cases, this parameter should be immutable. I'd actually argue we should not support it being mutable. Migrating a workspace to another datacenter / runtime is risky

@mtojek
Copy link
Member

mtojek commented Feb 3, 2023

TIL, thanks!

If this is a low-hanging fruit, then most likely we should look into this.

We could also consider this for our dogfood template, removing provisioning load from the Coder server and relying on runners on each bare metal instance to provision containers with their respective local docker sockets.

πŸ‘

BTW well described issue, Ben.

@mtojek mtojek added the parameters Area: parameters label Feb 28, 2023
@github-actions
Copy link

This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity.

@github-actions github-actions bot added the stale This issue is like stale bread. label May 30, 2023
@kconley-sq
Copy link
Contributor

Bump to remove the stale label, my team is still wishing for this feature. πŸ™

@github-actions github-actions bot removed the stale This issue is like stale bread. label May 31, 2023
@bpmct
Copy link
Member Author

bpmct commented Jul 24, 2023

It seems like this should both support targeting specific provisioners (e.g. single runner running on a VM) or tags/groups of provisioners (e.g. cluster 1 (100 daemons running)

@spikecurtis
Copy link
Contributor

One thing we could do fairly straightforwardly is to allow rich parameters to set tags on the build job, which then can restrict which provisionerds are able to build the workspace. For simplicity, we should require the parameter to be immutable.

Work items:

  1. Enhance the Coder Terraform Provider to allow coder_parameter to accept an argument marking it as a tag.
  2. Database migration that adds the tag information to the rich parameter in the database
  3. Enhance the workspace Builder to set tags based on rich parameters so marked.

This gets us a basic working version, but falls short of

Instead of hardcoded values, Coder pulls the list of available runners and perhaps shows latency.

We'd have to depend on hardcoded values in the template, so there would have to be out-of-band coordination between the operators who set up the provisionerds with tags and the template authors who want to allow end users to tag their jobs. (This is basically the situation today, with tags set at the template version.)

The difficulty in pulling a list of available provisioners is that Coder doesn't presently track the lifecycle of provisionerds. They get added to the database when they connect, but then are never updated when they disconnect.

I also think latency isn't very sensible. Latency from what to what? Presumably users are interested in minimizing the latency from their computer to their workspace, but we can't measure that prior to building the workspace. Provisionerds don't respond to latency pings from end users, and adding that is difficult because there is no requirement for them to be externally reachable. While you might expect that provisionerds are often located near where the workspaces will be created, this is far from universal. Consider the case of public clouds like AWS: a provisioner job talking to the AWS APIs can create a workspace in any zone across the whole world.

@bpmct
Copy link
Member Author

bpmct commented Aug 18, 2023

Yeah latency was a bit of a silly idea, we don't need to do that :)

@mtojek
Copy link
Member

mtojek commented Aug 25, 2023

As this is part of this sprint, let's list changes in the terraform-provider.

Enhance the Coder Terraform Provider to allow coder_parameter to accept an argument marking it as a tag.

@spikecurtis I'd like to follow up on your vision. Did you mean something like this:

data "coder_parameter" "ci_provisioner" {
  name        = "ci_provisioner"
  type        = "string"
  description = "Select a runner"

  option {
    name  = "Ben's Macbook"
    value = "bens-macbook"
  }
  option {
    name  = "US Pittsburgh"
    value = "us-pittsburgh"
  }
  option {
    name  = "Sydney"
    value = "sydney"
  }
  option {
    name  = "Ben's Thinkpad"
    value = "bens-thinkpad"
  }

  role = "select_provisioner"
}

In this case, option values would be tags: bens-macbook, us-pittsburgh, sydney, and bens-thinkpad.
Coderd/UI could determine the role of coder_parameter to be a provisioner selector based on the role property.

  1. Should we support default property for the provisioner selector?
  2. Maybe the provisioner selector should be a new rich parameter type?
  3. I presume that we don't allow to specify more than 1 selector per template?

Side note:

Maybe we could just introduce another TF resource like coder_provisioner, which is not a rich parameter,
but can provide a list of allowed provisioner tags.

@kconley-sq
Copy link
Contributor

Hey all, my team is one of the teams asking for this feature. We strictly need this aspect:

Instead of hardcoded values, Coder pulls the list of available runners

to support arbitrary developers spinning up workspaces on personal/local provisioners running on their laptops (see #909) that we can't pre-bake as hard-coded template parameter options.

We're trying to improve the experience today where:

  1. If a developer has no local/personal provisioner daemons running, currently nothing prevents them from trying to create a workspace from a template that only targets their local/personal provisioner daemon(s), but that workspace build will be stuck as pending seemingly forever and the developer won't have much feedback to understand that the problem is their personal/local provisioner daemon isn't running. To avoid that, we're hoping we could show them the list of provisioner daemons that are available for them to target on the workspace creation webpage and require one to be selected for the creation process to proceed. This blocking requirement on the workspace creation page may also give us an opportunity to show some documentation (e.g. in the parameter help/description text) explaining what they may need to do to get their local/personal provisioner daemon running again.
  2. In the rare-but-possible case that a developer has multiple laptops/computers that are each running personal/local provisioner daemons, it's not clear which of those machines would be targeted to host a workspace the developer starts up from a template that only targets the user's local/personal provisioner daemons, but the developer has a specific machine they are wanting to target. That's also why we're hoping the selected/targeted provisioner could become an immutable property of the workspace, so that when the workspace is restarted it always targets the same provisioner daemon. Since we use Docker containers on the same host where the provisioner daemon is running in our workspace template, it would be invalid for a workspace to unexpectedly move from one host to another if the provisioner daemon isn't constant because the workspace's persisted Docker resources would not be present on a different host.

@bpmct
Copy link
Member Author

bpmct commented Aug 29, 2023

I think this is a good opportunity for us to have "magic parameters" where the options and validation are not defined Terraform but instead by coderd: for example:

  • which provisioners does the template (and user) have permissions have access to (a just-in-time API call right before the create workspace UI/CLI)
  • which git repositories does the template (and user) have access to clone (uses the users' git access token + coderd to curate api responses for parameter values)?
  • perhaps a bit crazier: which VPCs does this template (and user) have access to?

I suppose this could be a "pre-create-workspace-page plan" πŸ˜… but these kind of these things could be better solved without Terraform (good ol' REST APIs).

I imagine this may cause some heavy refactors if we try to implement this in parameters and there is another risk in duplication if we introduce a different data source:

data "coder_magic_parameter" "provisioner" {
  options: "available provisioners"
}
data "coder_magic_parameter" "pick_a_repo" {
  options: "repos"
}

This kind of reminds me how we do gitauth in Coder. https://coder.com/docs/v2/latest/admin/git-providers#require-git-authentication-in-templates

I guess the parameter picker should be its own data source ❓

@mtojek

This comment was marked as outdated.

@bpmct
Copy link
Member Author

bpmct commented Aug 29, 2023

Nice! I like this

@bpmct
Copy link
Member Author

bpmct commented Oct 29, 2023

Would also like to suggest we add "provisioner metadata," which is very similar to agent metadata but can be used to display dynamic info about a provisioner. This does not have to be in the first version, but can easily inform users details about each provisioner (OS, number of GPUs on node, etc). Perhaps we provide some defaults but then the rest can be sent with an REST API request (no CLI definition or anything).

Edit: made an issue for this: #10412

@bpmct bpmct added the must-do Issues that must be completed by the end of the Sprint. Or else. Only humans may set this. label Nov 14, 2023
@bpmct
Copy link
Member Author

bpmct commented Nov 17, 2023

From a chat with @mtojek - we need to agree on whether this is a special rich parameter or done via a UI form control. I am leaning towards a parameter.

I'll bring this up during our call with Kyle next week

@bpmct bpmct removed the must-do Issues that must be completed by the end of the Sprint. Or else. Only humans may set this. label Nov 17, 2023
@spikecurtis spikecurtis added the customer-requested Features requested by enterprise customers. Only humans may set this. label Jan 5, 2024
@mtojek mtojek self-assigned this Apr 24, 2024
@matifali

This comment was marked as outdated.

@mtojek
Copy link
Member

mtojek commented Apr 24, 2024

FYI I'm working on the RFC right now, and will come up with the design by the end of this week.

@kylecarbs kylecarbs changed the title rich parameters: select a provisioner Use parameters to select a provisioner Apr 26, 2024
@mtojek
Copy link
Member

mtojek commented May 10, 2024

@matifali

This comment was marked as outdated.

@mtojek
Copy link
Member

mtojek commented May 10, 2024

The RFC does not discuss dynamic provisioner tags, so the short answer is: no, not yet. We can focus on the dynamic list of active tags later.

@matifali
Copy link
Member

matifali commented May 10, 2024

@mtojek I agree, and I am writing down this idea for future reference.

@matifali
Copy link
Member

What will be the behavior when the provided tags do not match any provisioner? What is the plan to evict these build jobs from the build queue? As currently, the behavior is that they always stay stuck in a pending state.

@mtojek
Copy link
Member

mtojek commented May 21, 2024

What will be the behavior when the provided tags do not match any provisioner? What is the plan to evict these build jobs from the build queue? As currently, the behavior is that they always #12331.

Stuck as it is now. We will need a separate RFC to describe a concept of "dead letter queue". It was mentioned in the RFC.

@matifali
Copy link
Member

Stuck as it is now. We will need a separate RFC to describe a concept of "dead letter queue". It was mentioned in the RFC.

@mtojek Thanks for the update.

@mtojek
Copy link
Member

mtojek commented May 23, 2024

As all items have been implemented according to the RFC, I'm closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-requested Features requested by enterprise customers. Only humans may set this. parameters Area: parameters roadmap https://coder.com/roadmap. Only humans may set this.
Projects
None yet
Development

No branches or pull requests

5 participants