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

Add extra Docker labels ( job name, task and task group name) #9885

Merged
merged 14 commits into from
Mar 8, 2021
Merged
Prev Previous commit
Next Next commit
fix tests around Docker labels
  • Loading branch information
sofixa committed Jan 25, 2021
commit b61ae091cccc188515bf9101d7836ab7f7b64a32
9 changes: 6 additions & 3 deletions drivers/docker/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@ func TestDockerDriver_Labels(t *testing.T) {
t.Fatalf("err: %v", err)
}

// expect to see 1 additional standard labels
require.Equal(t, len(cfg.Labels)+1, len(container.Config.Labels))
// expect to see 4 additional standard labels (allocID, jobName, TaskGroupName and TaskName)
require.Equal(t, len(cfg.Labels)+4, len(container.Config.Labels))
for k, v := range cfg.Labels {
require.Equal(t, v, container.Config.Labels[k])
}
Expand Down Expand Up @@ -1066,7 +1066,10 @@ func TestDockerDriver_CreateContainerConfig_Labels(t *testing.T) {
// user provided labels
"user_label": "user_value",
// default labels
"com.hashicorp.nomad.alloc_id": task.AllocID,
"com.hashicorp.nomad.alloc_id": task.AllocID,
"com.hashicorp.nomad.job_name": task.JobName,
"com.hashicorp.nomad.task_group_name": task.TaskGroupName,
"com.hashicorp.nomad.task_name": task.Name,
}

require.Equal(t, expectedLabels, c.Config.Labels)
Expand Down