cloudapi: Add artifact cleanup to delete handler

Related: RHEL-60120
This commit is contained in:
Brian C. Lane 2024-05-01 18:13:50 -07:00 committed by Tomáš Hozza
parent 56fc58cca3
commit b33f86783f
2 changed files with 7 additions and 0 deletions

View file

@ -79,6 +79,7 @@ const (
ErrorGettingComposeList ServiceErrorCode = 1021
ErrorArtifactNotFound ServiceErrorCode = 1022
ErrorDeletingJob ServiceErrorCode = 1023
ErrorDeletingArtifacts ServiceErrorCode = 1024
// Errors contained within this file
ErrorUnspecified ServiceErrorCode = 10000
@ -165,6 +166,7 @@ func getServiceErrors() serviceErrors {
serviceError{ErrorTenantNotInContext, http.StatusInternalServerError, "Unable to retrieve tenant from request context"},
serviceError{ErrorGettingComposeList, http.StatusInternalServerError, "Unable to get list of composes"},
serviceError{ErrorDeletingJob, http.StatusInternalServerError, "Unable to delete job"},
serviceError{ErrorDeletingArtifacts, http.StatusInternalServerError, "Unable to delete job artifacts"},
serviceError{ErrorUnspecified, http.StatusInternalServerError, "Unspecified internal error "},
serviceError{ErrorNotHTTPError, http.StatusInternalServerError, "Error is not an instance of HTTPError"},

View file

@ -345,6 +345,11 @@ func (h *apiHandlers) deleteComposeImpl(ctx echo.Context, jobId uuid.UUID) error
return HTTPErrorWithInternal(ErrorDeletingJob, err)
}
err = h.server.workers.CleanupArtifacts()
if err != nil {
return HTTPErrorWithInternal(ErrorDeletingArtifacts, err)
}
return ctx.JSON(http.StatusOK, ComposeDeleteStatus{
Href: fmt.Sprintf("/api/image-builder-composer/v2/composes/delete/%v", jobId),
Id: jobId.String(),