mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(edgejobs): remove endpoint from edge job mapping on endpoint deletion EE-4764 (#8212)
This commit is contained in:
parent
1c180346e4
commit
6570f1f8eb
4 changed files with 38 additions and 1 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/portainer/libhttp/response"
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
httperrors "github.com/portainer/portainer/api/http/errors"
|
||||
"github.com/portainer/portainer/api/internal/endpointutils"
|
||||
)
|
||||
|
||||
// @id EndpointDelete
|
||||
|
@ -124,6 +125,28 @@ func (handler *Handler) endpointDelete(w http.ResponseWriter, r *http.Request) *
|
|||
}
|
||||
}
|
||||
|
||||
if !endpointutils.IsEdgeEndpoint(endpoint) {
|
||||
return response.Empty(w)
|
||||
}
|
||||
|
||||
edgeJobs, err := handler.DataStore.EdgeJob().EdgeJobs()
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to retrieve edge jobs from the database", err)
|
||||
}
|
||||
|
||||
for idx := range edgeJobs {
|
||||
edgeJob := &edgeJobs[idx]
|
||||
if _, ok := edgeJob.Endpoints[endpoint.ID]; ok {
|
||||
err = handler.DataStore.EdgeJob().UpdateEdgeJobFunc(edgeJob.ID, func(j *portainer.EdgeJob) {
|
||||
delete(j.Endpoints, endpoint.ID)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to update edge job", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response.Empty(w)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue