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

Conversation

devashishTaneja
Copy link
Contributor

@devashishTaneja devashishTaneja commented Jul 7, 2023

Fixes: #17751

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 7, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

Looking pretty good @devashishTaneja! In addition to the comments I've left, can you run make cl to add a changelog entry?


I've smoke tested this with the following jobspec:

job "example" {
  type        = "batch"

  parameterized {
    payload = "required"
  }

  group "group" {
    task "task" {
      driver = "docker"
      config {
        image   = "busybox:1"
        command = "/bin/sh"
        args    = ["-c", "cat local/payload.txt; sleep 300"]
      }
      dispatch_payload {
        file = "payload.txt"
      }
    }
  }
}

After running and dispatching that job, I get the following labels on the resulting container:

$ docker inspect 120 | jq '.[0].Config.Labels'
{
  "com.hashicorp.nomad.alloc_id": "45b9fe13-0c85-9b87-0f3d-1c82774d9b5f",
  "com.hashicorp.nomad.job_id": "example/dispatch-1688760549-ec1a5470",
  "com.hashicorp.nomad.job_name": "example/dispatch-1688760549-ec1a5470",
  "com.hashicorp.nomad.parent_job_id": "example",
  "com.hashicorp.nomad.task_name": "task"
}

drivers/docker/driver.go Outdated Show resolved Hide resolved
client/allocrunner/taskrunner/task_runner.go Outdated Show resolved Hide resolved
plugins/drivers/driver.go Outdated Show resolved Hide resolved
Fix field name for Nitpicky Golang style
Add condition to add label only if parent job id is not null (dispatch/ periodic job)
@devashishTaneja
Copy link
Contributor Author

@tgross All the review comments are taken care. Please check

@devashishTaneja
Copy link
Contributor Author

@tgross Please have a look when possible.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

Looking good @devashishTaneja! Just a couple more items to wrap up.

.changelog/17843.txt Outdated Show resolved Hide resolved
plugins/drivers/proto/driver.proto Show resolved Hide resolved
@devashishTaneja
Copy link
Contributor Author

@tgross taken care of changelog and proto suggestions

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @devashishTaneja !

@tgross tgross merged commit b31e891 into hashicorp:main Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

include parent job ID as a Docker container label
3 participants