drain: fix double-close panic on drain future

This commit is contained in:
Michael Schurter
2018-04-02 16:39:18 -07:00
parent b4bb89d6da
commit 0900a1dbcc

View File

@@ -6,6 +6,7 @@ import (
"sync"
"time"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/state"
@@ -399,11 +400,12 @@ func (n *NodeDrainer) drainAllocs(future *structs.BatchFuture, allocs []*structs
var finalIndex uint64
for _, u := range partitionAllocDrain(transistions, evals) {
index, err := n.raft.AllocUpdateDesiredTransition(u.Transistions, u.Evals)
var mErr multierror.Error
if err != nil {
future.Respond(index, err)
mErr.Errors = append(mErr.Errors, err)
}
finalIndex = index
}
future.Respond(finalIndex, nil)
future.Respond(finalIndex, mErr.ErrorOrNil())
}