From c657713181f9eeeb3cbd5a1d082ccdc82c5f45b6 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 25 Jan 2022 14:29:47 -0800 Subject: [PATCH] weldr: Allow cancel on waiting and running composes Fix the cancel API to allow a waiting compose to be canceled. This also fixes the cancel return code to be 400, the lorax-composer behavior was a bug, and using 400 allows composer-cli to properly display the error. --- internal/weldr/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 43a3cca07..dcaf8f354 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2496,12 +2496,12 @@ func (api *API) composeCancelHandler(writer http.ResponseWriter, request *http.R } composeStatus := api.getComposeStatus(compose) - if composeStatus.State == ComposeWaiting { + if composeStatus.State != ComposeWaiting && composeStatus.State != ComposeRunning { errors := responseError{ ID: "BuildInWrongState", - Msg: fmt.Sprintf("Build %s has not started yet. No logs to view.", uuidString), + Msg: fmt.Sprintf("Build %s is not in WAITING or RUNNING.", uuidString), } - statusResponseError(writer, http.StatusOK, errors) // weirdly, Lorax returns 200 in this case + statusResponseError(writer, http.StatusBadRequest, errors) return }