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

[question] Query Container ID #4848

Open
sevagh opened this issue Nov 7, 2018 · 4 comments
Open

[question] Query Container ID #4848

sevagh opened this issue Nov 7, 2018 · 4 comments

Comments

@sevagh
Copy link
Contributor

sevagh commented Nov 7, 2018

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:

config {
  labels = "${NOMAD_ALLOC_ID}"
}

Also, the container name seems to contain the alloc id in it, e.g. ${task-name}-${nomad_alloc_id} in the output of docker 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? Or nomad 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).

@preetapan
Copy link
Contributor

preetapan commented Nov 14, 2018

@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.

@sevagh
Copy link
Contributor Author

sevagh commented Nov 14, 2018

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?

@Smithx10
Copy link

I've opened up this, #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
}

@Smithx10
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants