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

Add NodeName to the alloc/job status outputs. #4516

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions api/allocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type Allocation struct {
EvalID string
Name string
NodeID string
NodeName string
JobID string
Job *Job
TaskGroup string
Expand Down Expand Up @@ -121,6 +122,7 @@ type AllocationListStub struct {
EvalID string
Name string
NodeID string
NodeName string
JobID string
JobVersion uint64
TaskGroup string
Expand Down
1 change: 1 addition & 0 deletions command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func formatAllocBasicInfo(alloc *api.Allocation, client *api.Client, uuidLength
fmt.Sprintf("Eval ID|%s", limit(alloc.EvalID, uuidLength)),
fmt.Sprintf("Name|%s", alloc.Name),
fmt.Sprintf("Node ID|%s", limit(alloc.NodeID, uuidLength)),
fmt.Sprintf("Node Name|%s", alloc.NodeName),
fmt.Sprintf("Job ID|%s", alloc.JobID),
fmt.Sprintf("Job Version|%d", getVersion(alloc.Job)),
fmt.Sprintf("Client Status|%s", alloc.ClientStatus),
Expand Down
10 changes: 6 additions & 4 deletions command/job_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,13 @@ func formatAllocListStubs(stubs []*api.AllocationListStub, verbose bool, uuidLen

allocs := make([]string, len(stubs)+1)
if verbose {
allocs[0] = "ID|Eval ID|Node ID|Task Group|Version|Desired|Status|Created|Modified"
allocs[0] = "ID|Eval ID|Node ID|Node Name|Task Group|Version|Desired|Status|Created|Modified"
for i, alloc := range stubs {
allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%d|%s|%s|%s|%s",
allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%d|%s|%s|%s|%s",
limit(alloc.ID, uuidLength),
limit(alloc.EvalID, uuidLength),
limit(alloc.NodeID, uuidLength),
alloc.NodeName,
alloc.TaskGroup,
alloc.JobVersion,
alloc.DesiredStatus,
Expand All @@ -427,14 +428,15 @@ func formatAllocListStubs(stubs []*api.AllocationListStub, verbose bool, uuidLen
formatUnixNanoTime(alloc.ModifyTime))
}
} else {
allocs[0] = "ID|Node ID|Task Group|Version|Desired|Status|Created|Modified"
allocs[0] = "ID|Node ID|Node Name|Task Group|Version|Desired|Status|Created|Modified"
for i, alloc := range stubs {
now := time.Now()
createTimePretty := prettyTimeDiff(time.Unix(0, alloc.CreateTime), now)
modTimePretty := prettyTimeDiff(time.Unix(0, alloc.ModifyTime), now)
allocs[i+1] = fmt.Sprintf("%s|%s|%s|%d|%s|%s|%s|%s",
allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%d|%s|%s|%s|%s",
limit(alloc.ID, uuidLength),
limit(alloc.NodeID, uuidLength),
alloc.NodeName,
alloc.TaskGroup,
alloc.JobVersion,
alloc.DesiredStatus,
Expand Down
5 changes: 5 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5751,6 +5751,9 @@ type Allocation struct {
// NodeID is the node this is being placed on
NodeID string

// NodeName is the name of the node this is being placed on.
NodeName string

// Job is the parent job of the task group being allocated.
// This is copied at allocation time to avoid issues if the job
// definition is updated.
Expand Down Expand Up @@ -6132,6 +6135,7 @@ func (a *Allocation) Stub() *AllocListStub {
EvalID: a.EvalID,
Name: a.Name,
NodeID: a.NodeID,
NodeName: a.NodeName,
JobID: a.JobID,
JobVersion: a.Job.Version,
TaskGroup: a.TaskGroup,
Expand All @@ -6157,6 +6161,7 @@ type AllocListStub struct {
EvalID string
Name string
NodeID string
NodeName string
JobID string
JobVersion uint64
TaskGroup string
Expand Down
1 change: 1 addition & 0 deletions scheduler/generic_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ func (s *GenericScheduler) computePlacements(destructive, place []placementResul
TaskGroup: tg.Name,
Metrics: s.ctx.Metrics(),
NodeID: option.Node.ID,
NodeName: option.Node.Name,
DeploymentID: deploymentID,
TaskResources: option.TaskResources,
DesiredStatus: structs.AllocDesiredStatusRun,
Expand Down
1 change: 1 addition & 0 deletions scheduler/system_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ func (s *SystemScheduler) computePlacements(place []allocTuple) error {
TaskGroup: missing.TaskGroup.Name,
Metrics: s.ctx.Metrics(),
NodeID: option.Node.ID,
NodeName: option.Node.Name,
TaskResources: option.TaskResources,
DesiredStatus: structs.AllocDesiredStatusRun,
ClientStatus: structs.AllocClientStatusPending,
Expand Down