mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-21 07:46:04 +08:00
doing a backwards loop instead
This commit is contained in:
parent
d836718f04
commit
5b21b03a61
|
@ -47,27 +47,29 @@ func ManageZombies(ctx context.Context) {
|
|||
zombies = append(zombies, id)
|
||||
case id := <-removeZombie:
|
||||
found := false
|
||||
for i := 0; i < len(zombies); i++ {
|
||||
if len(zombies) > 0 {
|
||||
for i := len(zombies) - 1; i <= 0; i-- {
|
||||
if zombies[i] == id {
|
||||
logger.Log(1, "removing zombie from quaratine list", zombies[i])
|
||||
zombies = append(zombies[:i], zombies[i+1:]...)
|
||||
found = true
|
||||
i--
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
logger.Log(3, "no zombies found")
|
||||
}
|
||||
case <-time.After(time.Second * ZOMBIE_TIMEOUT):
|
||||
for i, zombie := range zombies {
|
||||
node, err := GetNodeByID(zombie)
|
||||
if len(zombies) > 0 {
|
||||
for i := len(zombies) - 1; i <= 0; i-- {
|
||||
node, err := GetNodeByID(zombies[i])
|
||||
if err != nil {
|
||||
logger.Log(1, "error retrieving zombie node", zombie, err.Error())
|
||||
logger.Log(1, "error retrieving zombie node", zombies[i], err.Error())
|
||||
continue
|
||||
}
|
||||
if time.Since(time.Unix(node.LastCheckIn, 0)) > time.Minute*ZOMBIE_DELETE_TIME {
|
||||
if err := DeleteNodeByID(&node, true); err != nil {
|
||||
logger.Log(1, "error deleting zombie node", zombie, err.Error())
|
||||
logger.Log(1, "error deleting zombie node", zombies[i], err.Error())
|
||||
continue
|
||||
}
|
||||
logger.Log(1, "deleting zombie node", node.Name)
|
||||
|
@ -76,6 +78,7 @@ func ManageZombies(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// InitializeZombies - populates the zombie quarantine list (should be called from initialization)
|
||||
|
|
Loading…
Reference in a new issue