mirror of
				https://github.com/gravitl/netmaker.git
				synced 2025-10-31 04:06:37 +08:00 
			
		
		
		
	code review changes
This commit is contained in:
		| @@ -9,8 +9,10 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| 	ZOMBIE_TIMEOUT     = 60 // timeout in seconds | 	// ZOMBIE_TIMEOUT - timeout in seconds for checking zombie status | ||||||
| 	ZOMBIE_DELETE_TIME = 10 // minutes | 	ZOMBIE_TIMEOUT = 60 | ||||||
|  | 	// ZOMBIE_DELETE_TIME - timeout in minutes for zombie node deletion | ||||||
|  | 	ZOMBIE_DELETE_TIME = 10 | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var ( | var ( | ||||||
| @@ -44,13 +46,17 @@ func ManageZombies(ctx context.Context) { | |||||||
| 			logger.Log(1, "adding", id, "to zombie quaratine list") | 			logger.Log(1, "adding", id, "to zombie quaratine list") | ||||||
| 			zombies = append(zombies, id) | 			zombies = append(zombies, id) | ||||||
| 		case id := <-removeZombie: | 		case id := <-removeZombie: | ||||||
|  | 			found := false | ||||||
| 			for i, zombie := range zombies { | 			for i, zombie := range zombies { | ||||||
| 				if zombie == id { | 				if zombie == id { | ||||||
| 					logger.Log(1, "removing zombie from quaratine list", zombie) | 					logger.Log(1, "removing zombie from quaratine list", zombie) | ||||||
| 					zombies = append(zombies[:i], zombies[i+1:]...) | 					zombies = append(zombies[:i], zombies[i+1:]...) | ||||||
|  | 					found = true | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | 			if !found { | ||||||
| 				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): | ||||||
| 			for i, zombie := range zombies { | 			for i, zombie := range zombies { | ||||||
| 				node, err := GetNodeByID(zombie) | 				node, err := GetNodeByID(zombie) | ||||||
| @@ -61,6 +67,7 @@ func ManageZombies(ctx context.Context) { | |||||||
| 				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 { | ||||||
| 					if err := DeleteNodeByID(&node, true); err != nil { | 					if err := DeleteNodeByID(&node, true); err != nil { | ||||||
| 						logger.Log(1, "error deleting zombie node", zombie, err.Error()) | 						logger.Log(1, "error deleting zombie node", zombie, err.Error()) | ||||||
|  | 						continue | ||||||
| 					} | 					} | ||||||
| 					logger.Log(1, "deleting zombie node", node.Name) | 					logger.Log(1, "deleting zombie node", node.Name) | ||||||
| 					zombies = append(zombies[:i], zombies[i+1:]...) | 					zombies = append(zombies[:i], zombies[i+1:]...) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Matthew R. Kasun
					Matthew R. Kasun