Skip to content

Commit

Permalink
Stopped status passed through to the statuses endpoint and observed o…
Browse files Browse the repository at this point in the history
…n job model and steady-state panel
  • Loading branch information
philrenaud committed Jun 14, 2024
1 parent eacf47a commit 83b6400
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions nomad/job_endpoint_statuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func jobStatusesJobFromJob(ws memdb.WatchSet, store *state.StateStore, job *stru
GroupCountSum: 0,
ChildStatuses: nil,
LatestDeployment: nil,
Stop: job.Stop,
}

// the GroupCountSum will map to how many allocations we expect to run
Expand Down
1 change: 1 addition & 0 deletions nomad/structs/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type JobStatusesJob struct {
// ParentID is set on child (batch) jobs, specifying the parent job ID
ParentID string
LatestDeployment *JobStatusesLatestDeployment
Stop bool // has the job been manually stopped?
}

// JobStatusesAlloc contains a subset of Allocation info.
Expand Down
11 changes: 9 additions & 2 deletions ui/app/components/job-status/panel/steady.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ export default class JobStatusPanelSteadyComponent extends Component {

/**
* @typedef {Object} CurrentStatus
* @property {"Healthy"|"Failed"|"Degraded"|"Recovering"|"Complete"|"Running"} label - The current status of the job
* @property {"highlight"|"success"|"warning"|"critical"} state -
* @property {"Healthy"|"Failed"|"Degraded"|"Recovering"|"Complete"|"Running"|"Stopped"} label - The current status of the job
* @property {"highlight"|"success"|"warning"|"critical"|"neutral"} state -
*/

/**
Expand All @@ -217,6 +217,13 @@ export default class JobStatusPanelSteadyComponent extends Component {
// If all allocs are running, the job is Healthy
const totalAllocs = this.totalAllocs;

if (this.job.status === 'dead' && this.job.stopped) {
return {
label: 'Stopped',
state: 'neutral',
};
}

if (this.job.type === 'batch' || this.job.type === 'sysbatch') {
// If all the allocs are complete, the job is Complete
const completeAllocs = this.allocBlocks.complete?.healthy?.nonCanary;
Expand Down
12 changes: 11 additions & 1 deletion ui/app/models/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class Job extends Model {
@attr('number') modifyIndex;
@attr('date') submitTime;
@attr('string') nodePool; // Jobs are related to Node Pools either directly or via its Namespace, but no relationship.
@attr('boolean') stopped;
@attr() ui;

@attr('number') groupCountSum;
Expand Down Expand Up @@ -89,7 +90,7 @@ export default class Job extends Model {

/**
* @typedef {Object} CurrentStatus
* @property {"Healthy"|"Failed"|"Deploying"|"Degraded"|"Recovering"|"Complete"|"Running"|"Removed"} label - The current status of the job
* @property {"Healthy"|"Failed"|"Deploying"|"Degraded"|"Recovering"|"Complete"|"Running"|"Removed"|"Stopped"} label - The current status of the job
* @property {"highlight"|"success"|"warning"|"critical"|"neutral"} state -
*/

Expand Down Expand Up @@ -224,6 +225,7 @@ export default class Job extends Model {
* - Degraded: A deployment is not taking place, and some allocations are failed, lost, or unplaced
* - Failed: All allocations are failed, lost, or unplaced
* - Removed: The job appeared in our initial query, but has since been garbage collected
* - Stopped: The job has been manually stopped (and not purged or yet garbage collected) by a user
* @returns {CurrentStatus}
*/
/**
Expand All @@ -238,6 +240,14 @@ export default class Job extends Model {
return { label: 'Deploying', state: 'highlight' };
}

// if manually stopped by a user:
if (this.stopped) {
return {
label: 'Stopped',
state: 'neutral',
};
}

// If the job was requested initially, but a subsequent request for it was
// not found, we can remove links to it but maintain its presence in the list
// until the user specifies they want a refresh
Expand Down
6 changes: 6 additions & 0 deletions ui/app/serializers/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export default class JobSerializer extends ApplicationSerializer {
});
}

// job.stop is reserved as a method (points to adapter method) so we rename it here
if (hash.Stop) {
hash.Stopped = hash.Stop;
delete hash.Stop;
}

return super.normalize(typeHash, hash);
}

Expand Down

0 comments on commit 83b6400

Please sign in to comment.