diff --git a/client/client.go b/client/client.go index 8bf2ce40e..314b9dda4 100644 --- a/client/client.go +++ b/client/client.go @@ -1333,8 +1333,6 @@ func (c *Client) updateAllocStatus(alloc *structs.Allocation) { // send the fields that are updatable by the client. stripped := new(structs.Allocation) stripped.ID = alloc.ID - stripped.JobID = alloc.JobID - stripped.Namespace = alloc.Namespace stripped.NodeID = c.NodeID() stripped.TaskStates = alloc.TaskStates stripped.ClientStatus = alloc.ClientStatus diff --git a/nomad/fsm.go b/nomad/fsm.go index ec1d81a38..c45ce6c3b 100644 --- a/nomad/fsm.go +++ b/nomad/fsm.go @@ -588,7 +588,7 @@ func (n *nomadFSM) applyAllocClientUpdate(buf []byte, index uint64) interface{} // Update any evals if len(req.Evals) > 0 { if err := n.upsertEvals(index, req.Evals); err != nil { - n.logger.Printf("[ERR] nomad.fsm: UpdateAllocFromClient failed: %v", err) + n.logger.Printf("[ERR] nomad.fsm: applyAllocClientUpdate failed to update evaluations: %v", err) return err } } diff --git a/nomad/node_endpoint.go b/nomad/node_endpoint.go index 6636cb88e..440fb75dc 100644 --- a/nomad/node_endpoint.go +++ b/nomad/node_endpoint.go @@ -835,26 +835,27 @@ func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.Gene // Add an evaluation if this is a failed alloc that is eligible for rescheduling if alloc.ClientStatus == structs.AllocClientStatusFailed { - ws := memdb.NewWatchSet() - job, err := n.srv.State().JobByID(ws, alloc.Namespace, alloc.JobID) - if err != nil { - n.srv.logger.Printf("[ERR] nomad.client: Unable to find jobid %v", alloc.JobID) - return err - } - if job == nil { - return fmt.Errorf("[ERR] nomad.client: Unable to find jobid %v", alloc.JobID) - } // Only create evaluations if this is an existing alloc, // and eligible as per its task group's ReschedulePolicy - if existingAlloc, _ := n.srv.State().AllocByID(ws, alloc.ID); existingAlloc != nil { + if existingAlloc, _ := n.srv.State().AllocByID(nil, alloc.ID); existingAlloc != nil { + job, err := n.srv.State().JobByID(nil, existingAlloc.Namespace, existingAlloc.JobID) + if err != nil { + n.srv.logger.Printf("[WARN] nomad.client: UpdateAlloc unable to find job ID %q :%v", existingAlloc.JobID, err) + continue + } + if job == nil { + n.srv.logger.Printf("[ERR] nomad.client: UpdateAlloc unable to find job ID %q", existingAlloc.JobID) + continue + } taskGroup := job.LookupTaskGroup(existingAlloc.TaskGroup) if taskGroup != nil && existingAlloc.RescheduleEligible(taskGroup.ReschedulePolicy, now) { eval := &structs.Evaluation{ ID: uuid.Generate(), - Namespace: alloc.Namespace, + Namespace: existingAlloc.Namespace, TriggeredBy: structs.EvalTriggerRetryFailedAlloc, - JobID: alloc.JobID, + JobID: existingAlloc.JobID, Type: job.Type, + Priority: job.Priority, Status: structs.EvalStatusPending, } evals = append(evals, eval)