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

Make validate command ignore environment variables in service name #3558

Merged
merged 8 commits into from
Nov 17, 2017
Merged
6 changes: 0 additions & 6 deletions website/source/docs/commands/validate.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ On successful validation, exit code 0 will be returned, otherwise an exit code
of 1 indicates an error.

Service names are validated according to [RFC-1123](https://tools.ietf.org/html/rfc1123).
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove from here and instead add to: https://www.nomadproject.io/docs/job-specification/service.html#name.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a fan of any specific validation details on this page since then we will end up documenting validation details here and on the specific stanzas.

Any environment variables in the name are ignored, because some environment variables can only
be resolved at run time. Invalid characters outside of environment variable names will not pass
validation.
For example, if the service name is set to `my_service${NOMAD_NODE_NAME}` it will fail
validation. However, if a service name is set to `myservice${NOMAD_NODE_NAME}` and the node name
contains an invalid character, it will only be caught at run time and nomad validate will succeed.

## Examples

Expand Down
6 changes: 6 additions & 0 deletions website/source/docs/job-specification/service.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ does not automatically enable service discovery.
- `${GROUP}` - the name of the group
- `${TASK}` - the name of the task
- `${BASE}` - shorthand for `${JOB}-${GROUP}-${TASK}`

Any environment variables in the name are ignored during validation, because some environment variables can only
be resolved at run time. Invalid characters outside of environment variable names will not pass
Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

Validation of the name occurs in two parts. When the job is registered, an initial validation pass checks that the service name adheres to RFC-1123 §2.1 and the length limit, excluding any variables requiring interpolation. Once the client receives the service and all interpretable values are available, the service name will be interpolated and revalidated. This can cause certain service names to pass validation at submit time but fail at runtime.

validation. For example, if the service name is set to `my_service${NOMAD_NODE_NAME}` it will fail
validation. However, if a service name is set to `myservice${NOMAD_NODE_NAME}` and the node name
contains an invalid character, it will only be caught at run time and nomad validate will succeed.

- `port` `(string: <required>)` - Specifies the label of the port on which this
service is running. Note this is the _label_ of the port and not the port
Expand Down