mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-13 19:15:27 +00: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:
parent
5d3a503f98
commit
65d88be523
1 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue