🐞 fix: rm only specific id in store
This commit is contained in:
parent
88bb8123a3
commit
7f84285421
@ -58,10 +58,12 @@ func (gs *gocServer) removeAgents(c *gin.Context) {
|
|||||||
idQuery := c.Query("id")
|
idQuery := c.Query("id")
|
||||||
ifInIdMap := idMaps(idQuery)
|
ifInIdMap := idMaps(idQuery)
|
||||||
|
|
||||||
|
errs := ""
|
||||||
gs.agents.Range(func(key, value interface{}) bool {
|
gs.agents.Range(func(key, value interface{}) bool {
|
||||||
|
|
||||||
// check if id is in the query ids
|
// check if id is in the query ids
|
||||||
if !ifInIdMap(key.(string)) {
|
id := key.(string)
|
||||||
|
if !ifInIdMap(id) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,13 +72,26 @@ func (gs *gocServer) removeAgents(c *gin.Context) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err := gs.removeAgentFromStore(id)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("fail to remove agent: %v", id)
|
||||||
|
err := fmt.Errorf("fail to remove agent: %v, err: %v", id, err)
|
||||||
|
errs = errs + err.Error()
|
||||||
|
return true
|
||||||
|
}
|
||||||
agent.closeConnection()
|
agent.closeConnection()
|
||||||
gs.agents.Delete(key)
|
gs.agents.Delete(key)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
gs.removeAllAgentsFromStore()
|
if errs != "" {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
|
"msg": errs,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusOK, nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getProfiles get and merge all agents' informations
|
// getProfiles get and merge all agents' informations
|
||||||
|
Loading…
Reference in New Issue
Block a user