Skip to content

Commit

Permalink
cloudapi: Add artifact cleanup to delete handler
Browse files Browse the repository at this point in the history
  • Loading branch information
bcl committed May 23, 2024
1 parent 1be77d9 commit 6974088
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/cloudapi/v2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const (
ErrorTenantNotInContext ServiceErrorCode = 1020
ErrorGettingComposeList ServiceErrorCode = 1021
ErrorRemovingJob ServiceErrorCode = 1022
ErrorRemovingArtifacts ServiceErrorCode = 1023

// Errors contained within this file
ErrorUnspecified ServiceErrorCode = 10000
Expand Down Expand Up @@ -159,6 +160,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{ErrorRemovingJob, http.StatusInternalServerError, "Unable to remove job"},
serviceError{ErrorRemovingArtifacts, http.StatusInternalServerError, "Unable to remove job artifacts"},

serviceError{ErrorUnspecified, http.StatusInternalServerError, "Unspecified internal error "},
serviceError{ErrorNotHTTPError, http.StatusInternalServerError, "Error is not an instance of HTTPError"},
Expand Down
5 changes: 5 additions & 0 deletions internal/cloudapi/v2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ func (h *apiHandlers) deleteComposeImpl(ctx echo.Context, id string) error {
return HTTPErrorWithInternal(ErrorRemovingJob, err)
}

err = h.server.workers.CleanupArtifacts()
if err != nil {
return HTTPErrorWithInternal(ErrorRemovingArtifacts, err)
}

return ctx.JSON(http.StatusOK, ComposeDeleteStatus{
Href: fmt.Sprintf("/api/image-builder-composer/v2/composes/delete/%v", jobId),
Id: jobId.String(),
Expand Down

0 comments on commit 6974088

Please sign in to comment.