Skip to content

feat(cli): allow specifying name of provisioner daemon#11077

Merged
johnstcn merged 8 commits into
mainfrom
cj/provisioner-daemon-name
Dec 7, 2023
Merged

feat(cli): allow specifying name of provisioner daemon#11077
johnstcn merged 8 commits into
mainfrom
cj/provisioner-daemon-name

Conversation

@johnstcn
Copy link
Copy Markdown
Member

@johnstcn johnstcn commented Dec 7, 2023

Part of #10676

  • Adds a --name argument to provisionerd start
  • Plumbs through name to integrated and external provisioners
  • Defaults to hostname if not specified for external, hostname-N for integrated
  • Adds cliutil.Hostname

@johnstcn johnstcn self-assigned this Dec 7, 2023
@johnstcn johnstcn marked this pull request as ready for review December 7, 2023 12:32
Copy link
Copy Markdown
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick look

Comment thread codersdk/provisionerdaemons.go Outdated
Comment thread enterprise/cli/provisionerdaemons.go
Comment thread enterprise/coderd/provisionerdaemons.go Outdated
Comment thread enterprise/coderd/provisionerdaemons.go Outdated
Comment thread enterprise/cli/provisionerdaemons_test.go Outdated
}
query := serverURL.Query()
query.Add("id", req.ID.String())
query.Add("name", req.Name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious: is it required to pass ID and name now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm going to end up ignoring the ID parameter and just upserting based on name in a follow-up PR.

Comment thread cli/cliutil/hostname.go Outdated
Comment thread cli/server.go
if len(hostname+suffix) > 62 {
hostname = hostname[:62-len(suffix)]
}
name := fmt.Sprintf("%s-%s", hostname, suffix)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hostname could include e.g. _, /, --, etc. I believe validation would fail in this case.. should we sanitize (strip/replace/allowlist)?

Copy link
Copy Markdown
Member Author

@johnstcn johnstcn Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not, but it turns out that you can write whatever you want to /proc/sys/kernel/hostname. The hostname command will validate its input, but it looks like docker will happily accept whatever you give it.

If we trim, we run the risk of collisions between machines named foo/bar, foo~bar, and foo!"£$%^&*()_+{}~@:?,bar. I'm leaning towards not sanitizing this.

Comment thread cli/cliutil/hostname.go
Comment thread enterprise/coderd/provisionerdaemons.go Outdated
Comment thread enterprise/coderd/provisionerdaemons.go Outdated
@johnstcn johnstcn requested review from mafredri and mtojek December 7, 2023 15:57
@johnstcn johnstcn merged commit 1e349f0 into main Dec 7, 2023
@johnstcn johnstcn deleted the cj/provisioner-daemon-name branch December 7, 2023 16:59
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants