|
@@ -31,6 +31,7 @@ func CheckZombies(newnode *models.Node) {
|
|
}
|
|
}
|
|
for _, node := range nodes {
|
|
for _, node := range nodes {
|
|
if node.MacAddress == newnode.MacAddress {
|
|
if node.MacAddress == newnode.MacAddress {
|
|
|
|
+ logger.Log(0, "adding ", node.ID, " to zombie list")
|
|
newZombie <- node.ID
|
|
newZombie <- node.ID
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -38,6 +39,8 @@ func CheckZombies(newnode *models.Node) {
|
|
|
|
|
|
// ManageZombies - goroutine which adds/removes/deletes nodes from the zombie node quarantine list
|
|
// ManageZombies - goroutine which adds/removes/deletes nodes from the zombie node quarantine list
|
|
func ManageZombies(ctx context.Context) {
|
|
func ManageZombies(ctx context.Context) {
|
|
|
|
+ logger.Log(2, "Zombie management started")
|
|
|
|
+ InitializeZombies()
|
|
for {
|
|
for {
|
|
select {
|
|
select {
|
|
case <-ctx.Done():
|
|
case <-ctx.Done():
|
|
@@ -60,11 +63,14 @@ func ManageZombies(ctx context.Context) {
|
|
logger.Log(3, "no zombies found")
|
|
logger.Log(3, "no zombies found")
|
|
}
|
|
}
|
|
case <-time.After(time.Second * ZOMBIE_TIMEOUT):
|
|
case <-time.After(time.Second * ZOMBIE_TIMEOUT):
|
|
|
|
+ logger.Log(0, "checking for zombie nodes")
|
|
if len(zombies) > 0 {
|
|
if len(zombies) > 0 {
|
|
for i := len(zombies) - 1; i >= 0; i-- {
|
|
for i := len(zombies) - 1; i >= 0; i-- {
|
|
node, err := GetNodeByID(zombies[i])
|
|
node, err := GetNodeByID(zombies[i])
|
|
if err != nil {
|
|
if err != nil {
|
|
logger.Log(1, "error retrieving zombie node", zombies[i], err.Error())
|
|
logger.Log(1, "error retrieving zombie node", zombies[i], err.Error())
|
|
|
|
+ logger.Log(1, "deleting ", node.Name, " from zombie list")
|
|
|
|
+ zombies = append(zombies[:i], zombies[i+1:]...)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
if time.Since(time.Unix(node.LastCheckIn, 0)) > time.Minute*ZOMBIE_DELETE_TIME {
|
|
if time.Since(time.Unix(node.LastCheckIn, 0)) > time.Minute*ZOMBIE_DELETE_TIME {
|
|
@@ -82,7 +88,7 @@ func ManageZombies(ctx context.Context) {
|
|
}
|
|
}
|
|
|
|
|
|
// InitializeZombies - populates the zombie quarantine list (should be called from initialization)
|
|
// InitializeZombies - populates the zombie quarantine list (should be called from initialization)
|
|
-func InitalizeZombies() {
|
|
|
|
|
|
+func InitializeZombies() {
|
|
nodes, err := GetAllNodes()
|
|
nodes, err := GetAllNodes()
|
|
if err != nil {
|
|
if err != nil {
|
|
logger.Log(1, "failed to retrieve nodes", err.Error())
|
|
logger.Log(1, "failed to retrieve nodes", err.Error())
|