Deployment adds JobSpecModifyIndex

Deployment tracks the Job.JobModifyIndex so that PUTS against /v1/jobs
can be more easily coorelated with the created deployment.

Fixes https://github.com/hashicorp/nomad/issues/4301
This commit is contained in:
Alex Dadgar 2018-05-30 11:33:56 -07:00
parent e96a4af694
commit 195e19827b
2 changed files with 53 additions and 20 deletions

View File

@ -125,15 +125,42 @@ func (d *Deployments) SetAllocHealth(deploymentID string, healthy, unhealthy []s
// Deployment is used to serialize an deployment.
type Deployment struct {
// ID is a generated UUID for the deployment
ID string
// Namespace is the namespace the deployment is created in
Namespace string
// JobID is the job the deployment is created for
JobID string
// JobVersion is the version of the job at which the deployment is tracking
JobVersion uint64
// JobModifyIndex is the modify index of the job at which the deployment is
// tracking. This is the ModifyIndex field on the job.
JobModifyIndex uint64
// JobSpecModifyIndex is the modify index of the job spec at which the
// deployment is tracking. This is the JobModifyIndex field on the job.
JobSpecModifyIndex uint64
// JobCreateIndex is the create index of the job which the deployment is
// tracking. It is needed so that if the job gets stopped and reran we can
// present the correct list of deployments for the job and not old ones.
JobCreateIndex uint64
// TaskGroups is the set of task groups effected by the deployment and their
// current deployment status.
TaskGroups map[string]*DeploymentState
// The status of the deployment
Status string
// StatusDescription allows a human readable description of the deployment
// status.
StatusDescription string
CreateIndex uint64
ModifyIndex uint64
}

View File

@ -5425,9 +5425,14 @@ type Deployment struct {
// JobVersion is the version of the job at which the deployment is tracking
JobVersion uint64
// JobModifyIndex is the modify index of the job at which the deployment is tracking
// JobModifyIndex is the modify index of the job at which the deployment is
// tracking. This is the ModifyIndex field on the job.
JobModifyIndex uint64
// JobSpecModifyIndex is the modify index of the job spec at which the
// deployment is tracking. This is the JobModifyIndex field on the job.
JobSpecModifyIndex uint64
// JobCreateIndex is the create index of the job which the deployment is
// tracking. It is needed so that if the job gets stopped and reran we can
// present the correct list of deployments for the job and not old ones.
@ -5456,6 +5461,7 @@ func NewDeployment(job *Job) *Deployment {
JobID: job.ID,
JobVersion: job.Version,
JobModifyIndex: job.ModifyIndex,
JobSpecModifyIndex: job.JobModifyIndex,
JobCreateIndex: job.CreateIndex,
Status: DeploymentStatusRunning,
StatusDescription: DeploymentStatusDescriptionRunning,