Skip to content

Commit

Permalink
Pack metadata booleanified and added to the statuses endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Jul 19, 2024
1 parent cf6ce22 commit 4dfdf2f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
12 changes: 12 additions & 0 deletions nomad/job_endpoint_statuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package nomad
import (
"errors"
"net/http"
"strings"
"time"

"github.com/armon/go-metrics"
Expand Down Expand Up @@ -198,6 +199,16 @@ func (j *Job) Statuses(
func jobStatusesJobFromJob(ws memdb.WatchSet, store *state.StateStore, job *structs.Job) (structs.JobStatusesJob, uint64, error) {
highestIdx := job.ModifyIndex

isPack := false
if job.Meta != nil {
for key, value := range job.Meta {
if strings.HasPrefix(key, "pack") && value != "" {
isPack = true
break
}
}
}

jsj := structs.JobStatusesJob{
NamespacedID: structs.NamespacedID{
ID: job.ID,
Expand All @@ -219,6 +230,7 @@ func jobStatusesJobFromJob(ws memdb.WatchSet, store *state.StateStore, job *stru
LatestDeployment: nil,
Stop: job.Stop,
Status: job.Status,
IsPack: isPack,
}

// 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 @@ -98,6 +98,7 @@ type JobStatusesJob struct {
ParentID string
LatestDeployment *JobStatusesLatestDeployment
Stop bool // has the job been manually stopped?
IsPack bool // is pack metadata present?
Status string
}

Expand Down
2 changes: 1 addition & 1 deletion ui/app/components/child-job-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
>
{{@job.name}}

{{#if @job.meta.structured.pack}}
{{#if @job.isPack}}
<span data-test-pack-tag class="tag is-pack">
{{x-icon "box" class= "test"}}
<span>Pack</span>
Expand Down
4 changes: 1 addition & 3 deletions ui/app/models/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ export default class Job extends Model {
}
@fragment('structured-attributes') meta;

get isPack() {
return !!this.meta?.structured?.pack;
}
@attr('boolean') isPack;

/**
* A task with a schedule block can have execution paused at specific cron-based times.
Expand Down
3 changes: 1 addition & 2 deletions ui/app/templates/jobs/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@
class="is-primary"
>
{{B.data.name}}
{{!-- TODO: going to lose .meta with statuses endpoint! --}}
{{#if B.data.meta.structured.pack}}
{{#if B.data.isPack}}
<span data-test-pack-tag class="tag is-pack">
{{x-icon "box" class= "test"}}
<span>Pack</span>
Expand Down

0 comments on commit 4dfdf2f

Please sign in to comment.