Adding the alloc if we can't find the TG

This commit is contained in:
Diptanu Choudhury
2016-10-27 15:39:12 -07:00
parent a9f5799f5a
commit c8afc418c9

View File

@@ -1393,8 +1393,6 @@ func (c *Client) runAllocs(update *allocUpdates) {
// blockForRemoteAlloc blocks until the previous allocation of an allocation has
// been terminated and migrates the snapshot data
func (c *Client) blockForRemoteAlloc(alloc *structs.Allocation) {
c.logger.Printf("[DEBUG] client: blocking alloc %q for previous allocation %q", alloc.ID, alloc.PreviousAllocation)
// Removing the allocation from the set of allocs which are currently
// undergoing migration
defer func() {
@@ -1403,19 +1401,20 @@ func (c *Client) blockForRemoteAlloc(alloc *structs.Allocation) {
c.migratingAllocsLock.Unlock()
}()
// prevAllocDir is the allocation directory of the previous allocation
var prevAllocDir *allocdir.AllocDir
// If the allocation is not sticky then we won't wait for the previous
// allocation to be terminal
tg := alloc.Job.LookupTaskGroup(alloc.TaskGroup)
if tg == nil {
c.logger.Printf("[ERR] client: task group %q not found in job %q", tg.Name, alloc.Job.ID)
return
goto ADDALLOC
}
// prevAllocDir is the allocation directory of the previous allocation
var prevAllocDir *allocdir.AllocDir
// Wait for the remote previous alloc to be terminal if the alloc is sticky
if tg.EphemeralDisk.Sticky {
c.logger.Printf("[DEBUG] client: blocking alloc %q for previous allocation %q", alloc.ID, alloc.PreviousAllocation)
// Block until the previous allocation migrates to terminal state
prevAlloc, err := c.waitForAllocTerminal(alloc.PreviousAllocation)
if err != nil {
@@ -1431,6 +1430,7 @@ func (c *Client) blockForRemoteAlloc(alloc *structs.Allocation) {
}
}
ADDALLOC:
// Add the allocation
if err := c.addAlloc(alloc, prevAllocDir); err != nil {
c.logger.Printf("[ERR] client: error adding alloc: %v", err)