Remove extra fields set in client allocations during update

This commit is contained in:
Preetha Appan
2018-01-23 11:38:53 -06:00
parent 162f75e834
commit 095e99bc92
3 changed files with 14 additions and 15 deletions

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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)