Merge pull request #1629 from gravitl/bugfix_0.16.2_zombies

re-enable zombie processing
This commit is contained in:
Alex Feiszli
2022-10-11 16:42:47 -04:00
committed by GitHub
3 changed files with 10 additions and 3 deletions

View File

@@ -335,7 +335,7 @@ func CreateNode(node *models.Node) error {
if err != nil { if err != nil {
return err return err
} }
// CheckZombies(node) CheckZombies(node)
nodebytes, err := json.Marshal(&node) nodebytes, err := json.Marshal(&node)
if err != nil { if err != nil {

View File

@@ -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())
@@ -101,8 +107,10 @@ func InitalizeZombies() {
if node.MacAddress == othernode.MacAddress { if node.MacAddress == othernode.MacAddress {
if node.LastCheckIn > othernode.LastCheckIn { if node.LastCheckIn > othernode.LastCheckIn {
zombies = append(zombies, othernode.ID) zombies = append(zombies, othernode.ID)
logger.Log(1, "adding ", othernode.Name, " with ID ", othernode.ID, " to zombie list")
} else { } else {
zombies = append(zombies, node.ID) zombies = append(zombies, node.ID)
logger.Log(1, "adding ", node.Name, " with ID ", node.ID, " to zombie list")
} }
} }
} }

View File

@@ -134,7 +134,6 @@ func initialize() { // Client Mode Prereq Check
logger.Log(0, "error occurred when notifying nodes of startup", err.Error()) logger.Log(0, "error occurred when notifying nodes of startup", err.Error())
} }
} }
logic.InitalizeZombies()
} }
func startControllers() { func startControllers() {