Skip to content

Commit

Permalink
add LatestDeployment
Browse files Browse the repository at this point in the history
probably will remove ActiveDeploymentID later
  • Loading branch information
gulducat committed Apr 9, 2024
1 parent 22b2b8f commit 01f7d8c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 12 additions & 1 deletion nomad/jobs_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func UIJobFromJob(ws memdb.WatchSet, store *state.StateStore, job *structs.Job,
uiJob.Allocs = append(uiJob.Allocs, alloc)
}

// look for active deployment
// look for latest deployment
deploy, err := store.LatestDeploymentByJobID(ws, job.Namespace, job.ID)
if err != nil {
return uiJob, idx, err
Expand All @@ -303,6 +303,17 @@ func UIJobFromJob(ws memdb.WatchSet, store *state.StateStore, job *structs.Job,
if deploy.Active() {
uiJob.ActiveDeploymentID = deploy.ID
}

uiJob.LatestDeployment = &structs.JobStatusLatestDeployment{
ID: deploy.ID,
IsActive: deploy.Active(),
JobVersion: deploy.JobVersion,
Status: deploy.Status,
StatusDescription: deploy.StatusDescription,
AllAutoPromote: deploy.HasAutoPromote(),
RequiresPromotion: deploy.RequiresPromotion(),
}

if deploy.ModifyIndex > idx {
idx = deploy.ModifyIndex
}
Expand Down
11 changes: 11 additions & 0 deletions nomad/structs/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type UIJob struct {
GroupCountSum int
ChildStatuses []string
ActiveDeploymentID string
LatestDeployment *JobStatusLatestDeployment
Version uint64
SubmitTime int64
ModifyIndex uint64
Expand Down Expand Up @@ -58,6 +59,16 @@ type JobStatusDeployment struct {
Healthy bool
}

type JobStatusLatestDeployment struct {
ID string
IsActive bool
JobVersion uint64
Status string
StatusDescription string
AllAutoPromote bool
RequiresPromotion bool
}

// JobServiceRegistrationsRequest is the request object used to list all
// service registrations belonging to the specified Job.ID.
type JobServiceRegistrationsRequest struct {
Expand Down

0 comments on commit 01f7d8c

Please sign in to comment.