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

Include parent job ID as a Docker container label #17751 #17843

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions .changelog/17843.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
build: Added support for parent job id for periodic/dispatch jobs
```
1 change: 1 addition & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ func (tr *TaskRunner) buildTaskConfig() *drivers.TaskConfig {
Namespace: alloc.Namespace,
NodeName: alloc.NodeName,
NodeID: alloc.NodeID,
ParentJobID: alloc.Job.ParentID,
Resources: &drivers.Resources{
NomadResources: taskResources,
LinuxResources: &drivers.LinuxResources{
Expand Down
4 changes: 4 additions & 0 deletions drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
dockerLabelNamespace = "com.hashicorp.nomad.namespace"
dockerLabelNodeName = "com.hashicorp.nomad.node_name"
dockerLabelNodeID = "com.hashicorp.nomad.node_id"
dockerLabelParentJobID = "com.hashicorp.nomad.parent_job_id"
)

type pauseContainerStore struct {
Expand Down Expand Up @@ -1324,6 +1325,9 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
if glob.Glob(configurationExtraLabel, "job_id") {
labels[dockerLabelJobID] = task.JobID
}
if glob.Glob(configurationExtraLabel, "parent_job_id") && len(task.ParentJobID) > 0 {
labels[dockerLabelParentJobID] = task.ParentJobID
}
if glob.Glob(configurationExtraLabel, "task_group_name") {
labels[dockerLabelTaskGroupName] = task.TaskGroupName
}
Expand Down
1 change: 1 addition & 0 deletions plugins/drivers/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ type TaskConfig struct {
JobName string
JobID string
TaskGroupName string
ParentJobID string
Name string // task.Name
Namespace string
NodeName string
Expand Down
3 changes: 3 additions & 0 deletions plugins/drivers/proto/driver.proto
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ message TaskConfig {

// NodeId is the ID of the node where the associated allocation is running
string node_id = 21;

// ParentJobID is the parent id for dispatch and periodic jobs
string parent_job_id = 22;
}

message Resources {
Expand Down