diff --git a/client/client.go b/client/client.go index 74f4b2ffc..b5fcaa8f7 100644 --- a/client/client.go +++ b/client/client.go @@ -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)