updated job validate to refute job/group/task IDs containing null characters

updated CHANGELOG and upgrade guide
This commit is contained in:
Chris Baker 2020-10-03 22:07:18 +00:00
parent c8fd9428d4
commit 23ea7cd27c
4 changed files with 14 additions and 1 deletions

View file

@ -11,6 +11,7 @@ IMPROVEMENTS:
* jobspec: Lowered minimum CPU allowed from 10 to 1. [[GH-8996](https://github.com/hashicorp/nomad/issues/8996)]
__BACKWARDS INCOMPATIBILITIES:__
* core: job IDs, task group names, and task names are not allowed to contain null characters [[GH-9020](https://github.com/hashicorp/nomad/issues/9020)]
* driver/docker: Tasks are now issued SIGTERM instead of SIGINT when stopping [[GH-8932](https://github.com/hashicorp/nomad/issues/8932)]
BUG FIXES:

View file

@ -3943,6 +3943,8 @@ func (j *Job) Validate() error {
mErr.Errors = append(mErr.Errors, errors.New("Missing job ID"))
} else if strings.Contains(j.ID, " ") {
mErr.Errors = append(mErr.Errors, errors.New("Job ID contains a space"))
} else if strings.Contains(j.ID, "\000") {
mErr.Errors = append(mErr.Errors, errors.New("Job ID contains a null chararacter"))
}
if j.Name == "" {
mErr.Errors = append(mErr.Errors, errors.New("Missing job name"))
@ -5740,6 +5742,8 @@ func (tg *TaskGroup) Validate(j *Job) error {
var mErr multierror.Error
if tg.Name == "" {
mErr.Errors = append(mErr.Errors, errors.New("Missing task group name"))
} else if strings.Contains(tg.Name, "\000") {
mErr.Errors = append(mErr.Errors, errors.New("Task group name contains null character"))
}
if tg.Count < 0 {
mErr.Errors = append(mErr.Errors, errors.New("Task group count can't be negative"))
@ -6462,6 +6466,8 @@ func (t *Task) Validate(ephemeralDisk *EphemeralDisk, jobType string, tgServices
// We enforce this so that when creating the directory on disk it will
// not have any slashes.
mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include slashes"))
} else if strings.Contains(t.Name, "\000") {
mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include null characters"))
}
if t.Driver == "" {
mErr.Errors = append(mErr.Errors, errors.New("Missing task driver"))

View file

@ -185,7 +185,7 @@ func TestJob_ValidateNullChar(t *testing.T) {
// task name should not allow null characters
job.TaskGroups[0].Name = "so_much_better"
job.TaskGroups[0].Tasks[0].Name = "what_is_with_these_\000_chars"
job.TaskGroups[0].Tasks[0].Name = "ive_had_it_with_these_\000_chars_in_these_names"
assert.Error(job.Validate(), "null character in task name should not validate")
}

View file

@ -24,6 +24,12 @@ When stopping tasks running with the Docker task driver, Nomad documents that a
versions of Nomad would issue `SIGINT` instead. Starting again with Nomad v0.13.0
`SIGTERM` will be sent by default when stopping Docker tasks.
### Null characters in job, task group, and task IDs
Starting with Nomad v0.13.0, job will fail validation if any of the following
contain null character: the job ID, the task group name, or the task name. Any
jobs meeting this requirement should be modified before an update to v0.13.0.
## Nomad 0.12.0
### `mbits` and Task Network Resource deprecation