diff --git a/command/monitor.go b/command/monitor.go index 7e99f24df..ef0287071 100644 --- a/command/monitor.go +++ b/command/monitor.go @@ -21,13 +21,14 @@ const ( // evalState is used to store the current "state of the world" // in the context of monitoring an evaluation. type evalState struct { - status string - desc string - node string - job string - allocs map[string]*allocState - wait time.Duration - index uint64 + status string + desc string + node string + deployment string + job string + allocs map[string]*allocState + wait time.Duration + index uint64 } // newEvalState creates and initializes a new monitorState @@ -111,6 +112,11 @@ func (m *monitor) update(update *evalState) { m.ui.Output(fmt.Sprintf("Evaluation triggered by job %q", update.job)) } + // Check if the evaluation was triggered by a deployment + if existing.deployment == "" && update.deployment != "" { + m.ui.Output(fmt.Sprintf("Evaluation within deployment: %q", limit(update.deployment, m.length))) + } + // Check the allocations for allocID, alloc := range update.allocs { if existing, ok := existing.allocs[allocID]; !ok { @@ -236,6 +242,7 @@ func (m *monitor) monitor(evalID string, allowPrefix bool) int { state.desc = eval.StatusDescription state.node = eval.NodeID state.job = eval.JobID + state.deployment = eval.DeploymentID state.wait = eval.Wait state.index = eval.CreateIndex diff --git a/nomad/job_endpoint_test.go b/nomad/job_endpoint_test.go index ddc6f2357..c811bb9f7 100644 --- a/nomad/job_endpoint_test.go +++ b/nomad/job_endpoint_test.go @@ -121,36 +121,6 @@ func TestJobEndpoint_Register_InvalidDriverConfig(t *testing.T) { } } -func TestJobEndpoint_Register_UpdateWarning(t *testing.T) { - s1 := testServer(t, func(c *Config) { - c.NumSchedulers = 0 // Prevent automatic dequeue - }) - defer s1.Shutdown() - codec := rpcClient(t, s1) - testutil.WaitForLeader(t, s1.RPC) - - // Create the register request with a job containing an invalid driver - // config - job := mock.Job() - job.Update.Stagger = 1 * time.Second - job.Update.MaxParallel = 1 - req := &structs.JobRegisterRequest{ - Job: job, - WriteRequest: structs.WriteRequest{Region: "global"}, - } - - // Fetch the response - var resp structs.JobRegisterResponse - err := msgpackrpc.CallWithCodec(codec, "Job.Register", req, &resp) - if err != nil { - t.Fatalf("err: %v", err) - } - - if !strings.Contains(resp.Warnings, "Update stagger deprecated") { - t.Fatalf("expected a deprecation warning but got: %v", err) - } -} - func TestJobEndpoint_Register_Payload(t *testing.T) { s1 := testServer(t, func(c *Config) { c.NumSchedulers = 0 // Prevent automatic dequeue @@ -2629,22 +2599,6 @@ func TestJobEndpoint_ValidateJob_InvalidSignals(t *testing.T) { } } -func TestJobEndpoint_ValidateJob_UpdateWarning(t *testing.T) { - // Create a mock job with an invalid config - job := mock.Job() - job.Update.Stagger = 1 * time.Second - job.Update.MaxParallel = 1 - - err, warnings := validateJob(job) - if err != nil { - t.Fatalf("Unexpected validation error; got %v", err) - } - - if !strings.Contains(warnings.Error(), "Update stagger deprecated") { - t.Fatalf("expected a deprecation warning but got: %v", err) - } -} - func TestJobEndpoint_ValidateJobUpdate(t *testing.T) { old := mock.Job() new := mock.Job() diff --git a/scheduler/reconcile.go b/scheduler/reconcile.go index 9bf435eff..2528d076e 100644 --- a/scheduler/reconcile.go +++ b/scheduler/reconcile.go @@ -191,7 +191,7 @@ func (a *allocReconciler) cancelDeployments() { } // Check if the deployment is active and referencing an older job and cancel it - if d.JobCreateIndex != a.job.CreateIndex || d.JobModifyIndex != a.job.JobModifyIndex { + if d.JobCreateIndex != a.job.CreateIndex || d.JobVersion != a.job.Version { if d.Active() { a.result.deploymentUpdates = append(a.result.deploymentUpdates, &structs.DeploymentStatusUpdate{ DeploymentID: a.deployment.ID, diff --git a/scheduler/reconcile_test.go b/scheduler/reconcile_test.go index 498d0e4f5..0798c56f9 100644 --- a/scheduler/reconcile_test.go +++ b/scheduler/reconcile_test.go @@ -1219,7 +1219,7 @@ func TestReconciler_CancelDeployment_JobUpdate(t *testing.T) { failed.Status = structs.DeploymentStatusFailed // Make the job newer than the deployment - job.JobModifyIndex += 10 + job.Version += 10 cases := []struct { name string @@ -1872,7 +1872,7 @@ func TestReconciler_StopOldCanaries(t *testing.T) { d.TaskGroups[job.TaskGroups[0].Name] = s // Update the job - job.JobModifyIndex += 10 + job.Version += 10 // Create 10 allocations from the old job var allocs []*structs.Allocation @@ -2735,12 +2735,12 @@ func TestReconciler_FailedDeployment_NewJob(t *testing.T) { // Up the job version jobNew := job.Copy() - jobNew.JobModifyIndex += 100 + jobNew.Version += 100 reconciler := NewAllocReconciler(testLogger(), allocUpdateFnDestructive, false, job.ID, jobNew, d, allocs, nil) r := reconciler.Compute() - dnew := structs.NewDeployment(job) + dnew := structs.NewDeployment(jobNew) dnew.TaskGroups[job.TaskGroups[0].Name] = &structs.DeploymentState{ DesiredTotal: 10, }