hashicorp / hashicorp/nomad

Ability to query allocs by their job-id, task-id and count-number in the CLI

Open
#6,276 0 comments 0 reactions 0 assignees View on GitHub
theme/cli type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

In common operations, such as getting the status of an alloc, or getting logs for an alloc, using the CLI requires knowing the alloc ID which is impossible to know in advance. To get the alloc id, a `nomad status job-id` must be issued, and the alloc-id can then be copy-pasted to the next command. This is cumbersome.

I suggest that each time in the CLI an alloc id can be provided, the alloc name should also be able to be used. The alloc name is already available in `nomad alloc status`:

```
[root@elyas ~]# nomad status 73c788fe
ID = 73c788fe
Eval ID = 4921b540
Name = job-name.group-name[0]
Node ID = d1afc60c
Node Name = hostname
Job ID = job-name
Job Version = 824636183280
Client Status = pending
Client Description =
Desired Status = run
Desired Description =
Created = 3m24s ago
Modified = 3m24s ago
```

Example of uses could be:

- `nomad status job-name.group-name[0]`
- `nomad logs job-name.group-name[0]`

As a convenience, and because `[` and `]` are special shell characters, perhaps the alloc name could also be referred as `job-name.group-name.0` instead. Another convenience could be to omit the group-name when the job has only one group, or omit the count index when the count is 1.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the CLI handles allocation IDs for `nomad status` and `nomad logs`, then inspect the existing allocation name shown by `nomad alloc status`. Define and document the accepted job, group, and count forms, including shell-safe input, and verify that the relevant commands resolve them consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.