Skip to content
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

Allow lower / mixed-case port labels #118

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func PopulateEnvironment(ctx *ExecContext, task *structs.Task) []string {

// Named ports for this task
for label, port := range network.MapDynamicPorts() {
env = append(env, fmt.Sprintf("NOMAD_PORT_%s=%d", label, port))
env = append(env, fmt.Sprintf("NOMAD_PORT_%s=%d", strings.ToUpper(label), port))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jobspec/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func parseTasks(result *[]*structs.Task, obj *hclobj.Object) error {
return nil
}

var reDynamicPorts *regexp.Regexp = regexp.MustCompile("^[A-Z0-9_]+$")
var reDynamicPorts *regexp.Regexp = regexp.MustCompile("^[a-zA-Z0-9_]+$")
var errDynamicPorts = fmt.Errorf("DynamicPort label does not conform to naming requirements %s", reDynamicPorts.String())

func parseResources(result *structs.Resources, obj *hclobj.Object) error {
Expand Down
2 changes: 1 addition & 1 deletion website/source/docs/jobspec/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ The `resources` object supports the following keys:
The `network` object supports the following keys:

* `dynamic_ports` - List of port labels which may contain uppercase letters,
numbers and underscores (`^[A-Z0-9_]+$`). Each label will be assigned a
numbers and underscores (`^[a-zA-Z0-9_]+$`). Each label will be assigned a
dynamic port when the task starts. Ports are passed to the task environment as
`NOMAD_PORT_{LABEL}`. Drivers may infer additional semantics from the label.
See the relevant driver docs for details.
Expand Down