mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-15 17:13:46 +01:00
Prevent agent deletion when it's still running tasks (#3377)
It wont solve the underlying issues like https://github.com/woodpecker-ci/autoscaler/issues/50 completely, but should be a first step in the correct direction.
This commit is contained in:
@@ -204,6 +204,16 @@ func DeleteAgent(c *gin.Context) {
|
||||
handleDBError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// prevent deletion of agents with running tasks
|
||||
info := server.Config.Services.Queue.Info(c)
|
||||
for _, task := range info.Running {
|
||||
if task.AgentID == agent.ID {
|
||||
c.String(http.StatusConflict, "Agent has running tasks")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err = _store.AgentDelete(agent); err != nil {
|
||||
c.String(http.StatusInternalServerError, "Error deleting user. %s", err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user