Consistently quote alloc ids in client logs
This commit is contained in:
parent
4fd9ef6a8c
commit
644f0cfaa4
|
@ -302,7 +302,7 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic
|
|||
logger.Printf("[ERR] client: failed to restore state: %v", err)
|
||||
logger.Printf("[ERR] client: Nomad is unable to start due to corrupt state. "+
|
||||
"The safest way to proceed is to manually stop running task processes "+
|
||||
"and remove Nomad's state (%q) and alloc (%d) directories before "+
|
||||
"and remove Nomad's state (%q) and alloc (%q) directories before "+
|
||||
"restarting. Lost allocations will be rescheduled.",
|
||||
c.config.StateDir, c.config.AllocDir)
|
||||
logger.Printf("[ERR] client: Corrupt state is often caused by a bug. Please " +
|
||||
|
@ -666,14 +666,14 @@ func (c *Client) restoreState() error {
|
|||
c.allocLock.Unlock()
|
||||
|
||||
if err := ar.RestoreState(); err != nil {
|
||||
c.logger.Printf("[ERR] client: failed to restore state for alloc %s: %v", id, err)
|
||||
c.logger.Printf("[ERR] client: failed to restore state for alloc %q: %v", id, err)
|
||||
mErr.Errors = append(mErr.Errors, err)
|
||||
} else {
|
||||
go ar.Run()
|
||||
|
||||
if upgrading {
|
||||
if err := ar.SaveState(); err != nil {
|
||||
c.logger.Printf("[WARN] client: initial save state for alloc %s failed: %v", id, err)
|
||||
c.logger.Printf("[WARN] client: initial save state for alloc %q failed: %v", id, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ func (c *Client) saveState() error {
|
|||
go func(id string, ar *AllocRunner) {
|
||||
err := ar.SaveState()
|
||||
if err != nil {
|
||||
c.logger.Printf("[ERR] client: failed to save state for alloc %s: %v", id, err)
|
||||
c.logger.Printf("[ERR] client: failed to save state for alloc %q: %v", id, err)
|
||||
l.Lock()
|
||||
multierror.Append(&mErr, err)
|
||||
l.Unlock()
|
||||
|
@ -1268,7 +1268,7 @@ func (c *Client) updateAllocStatus(alloc *structs.Allocation) {
|
|||
delete(c.blockedAllocations, blockedAlloc.PreviousAllocation)
|
||||
c.blockedAllocsLock.Unlock()
|
||||
|
||||
c.logger.Printf("[DEBUG] client: unblocking alloc %s because alloc %s terminated", blockedAlloc.ID, alloc.ID)
|
||||
c.logger.Printf("[DEBUG] client: unblocking alloc %q because alloc %q terminated", blockedAlloc.ID, alloc.ID)
|
||||
|
||||
// Need to call addAlloc without holding the lock
|
||||
if err := c.addAlloc(blockedAlloc, prevAllocDir); err != nil {
|
||||
|
@ -1282,7 +1282,7 @@ func (c *Client) updateAllocStatus(alloc *structs.Allocation) {
|
|||
// Mark the allocation for GC if it is in terminal state
|
||||
if ar, ok := c.getAllocRunners()[alloc.ID]; ok {
|
||||
if err := c.garbageCollector.MarkForCollection(ar); err != nil {
|
||||
c.logger.Printf("[DEBUG] client: couldn't add alloc %v for GC: %v", alloc.ID, err)
|
||||
c.logger.Printf("[DEBUG] client: couldn't add alloc %q for GC: %v", alloc.ID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1581,7 +1581,7 @@ func (c *Client) runAllocs(update *allocUpdates) {
|
|||
// Update the existing allocations
|
||||
for _, update := range diff.updated {
|
||||
if err := c.updateAlloc(update.exist, update.updated); err != nil {
|
||||
c.logger.Printf("[ERR] client: failed to update alloc '%s': %v",
|
||||
c.logger.Printf("[ERR] client: failed to update alloc %q: %v",
|
||||
update.exist.ID, err)
|
||||
}
|
||||
|
||||
|
@ -1608,7 +1608,7 @@ func (c *Client) runAllocs(update *allocUpdates) {
|
|||
// Check if the alloc is already present in the blocked allocations
|
||||
// map
|
||||
if _, ok := c.blockedAllocations[add.PreviousAllocation]; !ok {
|
||||
c.logger.Printf("[DEBUG] client: added alloc %s to blocked queue for previous allocation %s",
|
||||
c.logger.Printf("[DEBUG] client: added alloc %q to blocked queue for previous alloc %q",
|
||||
add.ID, add.PreviousAllocation)
|
||||
c.blockedAllocations[add.PreviousAllocation] = add
|
||||
}
|
||||
|
@ -1720,7 +1720,7 @@ func (c *Client) waitForAllocTerminal(allocID string, stopCh *migrateAllocCtrl)
|
|||
case <-time.After(retry):
|
||||
continue
|
||||
case <-stopCh.ch:
|
||||
return nil, fmt.Errorf("giving up waiting on alloc %v since migration is not needed", allocID)
|
||||
return nil, fmt.Errorf("giving up waiting on alloc %q since migration is not needed", allocID)
|
||||
case <-c.shutdownCh:
|
||||
return nil, fmt.Errorf("aborting because client is shutting down")
|
||||
}
|
||||
|
@ -1804,8 +1804,8 @@ func (c *Client) migrateRemoteAllocDir(alloc *structs.Allocation, allocID string
|
|||
resp, err := apiClient.Raw().Response(url, nil)
|
||||
if err != nil {
|
||||
os.RemoveAll(pathToAllocDir)
|
||||
c.logger.Printf("[ERR] client: error getting snapshot: %v", err)
|
||||
return nil, fmt.Errorf("error getting snapshot for alloc %v: %v", alloc.ID, err)
|
||||
c.logger.Printf("[ERR] client: error getting snapshot for alloc %q: %v", alloc.ID, err)
|
||||
return nil, fmt.Errorf("error getting snapshot for alloc %q: %v", alloc.ID, err)
|
||||
}
|
||||
|
||||
if err := c.unarchiveAllocDir(resp, allocID, pathToAllocDir); err != nil {
|
||||
|
|
Loading…
Reference in New Issue