Open sevagh opened 5 years ago
@sevagh thanks for the suggestion. This isn't something we are actively working on, but will consider adding it to a future roadmap with a more generic way to surface allocation metadata.
The upcoming 0.9 release will add support for passing allocid/taskid etc to docker as docker labels. #4781 tracks this.
Thanks @preetapan - so that means instead of manually specifying labels = "${NOMAD_*_ID}"
in all of my HCL files, Nomad will do it automatically in the new release?
I've opened up this, https://github.com/hashicorp/nomad/issues/5863 trying to do the same for my users.
While exploring the code, I'm curious if DriverAttributes in the TaskStatus struct could be used for this? Or what they are used for.... I can't figure it out, or What NetworkOverride does. It is returned Nomad calls "func (d Driver) InspectTask(taskID string) (drivers.TaskStatus, error)" but I cant figure out when Nomad calls that function either. Hopefully someone can help educate me :) :)
type TaskStatus struct { ID string Name string State TaskState StartedAt time.Time CompletedAt time.Time ExitResult ExitResult DriverAttributes map[string]string NetworkOverride DriverNetwork }
Anyone curious about this... we currently are getting around this by using the event.Eventer and then leaving it up to the consumer of /allocations to pull the latest information if they want. Not sure if Docker does this or not but it wouldn't break anything to add this.
I'm looking for a way to associate running containers to an alloc id. This is for general debugging, or for example to use tools like https://github.com/google/cadvisor
I experimented with the label solution, where I add this to my HCL:
Also, the container name seems to contain the alloc id in it, e.g.
${task-name}-${nomad_alloc_id}
in the output ofdocker ps
.I'm sure the ContainerID is kept track of in the code - is there a way to print this information from
nomad alloc-status
? Ornomad node status
?Is that useful? e.g.
nomad alloc-status ${alloc-id}
to print the actual container ID (if it's using the Docker driver).