mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Removing the alloc runner from GC if it is destroyed by the server
This commit is contained in:
@@ -1759,6 +1759,9 @@ func (c *Client) removeAlloc(alloc *structs.Allocation) error {
|
||||
delete(c.allocs, alloc.ID)
|
||||
c.allocLock.Unlock()
|
||||
|
||||
// Remove the allocrunner from garbage collector
|
||||
c.garbageCollector.Remove(ar)
|
||||
|
||||
ar.Destroy()
|
||||
return nil
|
||||
}
|
||||
|
||||
12
client/gc.go
12
client/gc.go
@@ -329,3 +329,15 @@ func (a *AllocGarbageCollector) MarkForCollection(ar *AllocRunner) error {
|
||||
a.logger.Printf("[INFO] client: marking allocation %v for GC", ar.Alloc().ID)
|
||||
return a.allocRunners.Push(ar)
|
||||
}
|
||||
|
||||
// Remove removes an alloc runner without garbage collecting it
|
||||
func (a *AllocGarbageCollector) Remove(ar *AllocRunner) {
|
||||
if ar == nil || ar.Alloc() == nil {
|
||||
return
|
||||
}
|
||||
|
||||
alloc := ar.Alloc()
|
||||
if _, err := a.allocRunners.Remove(alloc.ID); err == nil {
|
||||
a.logger.Printf("[INFO] client: removed alloc runner %v from garbage collector", alloc.ID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user