Skip to content

Commit 058846d

Browse files
committed
add stop upgrade endpoint
1 parent fe0b042 commit 058846d

File tree

9 files changed

+366
-92
lines changed

9 files changed

+366
-92
lines changed

cmd/gendoc/docs.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,21 @@ Contains a JSON object with the details of an error.
823823
{StatusCode: http.StatusNoContent, Reference: "#/components/responses/NoContent"},
824824
},
825825
},
826+
{
827+
OperationId: "stopUpdate",
828+
Method: http.MethodPut,
829+
Path: "/v1/system/update/stop",
830+
CustomSuccessResponse: &CustomResponseDef{
831+
Description: "Successful response",
832+
StatusCode: http.StatusOK,
833+
},
834+
Description: "Stop the upgrade process.",
835+
Summary: "Stop the upgrade process in background",
836+
Tags: []Tag{SystemTag},
837+
PossibleErrors: []ErrorResponse{
838+
{StatusCode: http.StatusConflict, Reference: "#/components/responses/Conflict"},
839+
},
840+
},
826841
{
827842
OperationId: "applyUpdate",
828843
Method: http.MethodPut,

internal/api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func NewHTTPRouter(
6666
mux.Handle("GET /v1/system/update/check", handlers.HandleCheckUpgradable(updater))
6767
mux.Handle("GET /v1/system/update/events", handlers.HandleUpdateEvents(updater))
6868
mux.Handle("PUT /v1/system/update/apply", handlers.HandleUpdateApply(updater))
69+
mux.Handle("PUT /v1/system/update/stop", handlers.HandlerUpdateStop(updater))
6970
mux.Handle("GET /v1/system/resources", handlers.HandleSystemResources())
7071

7172
mux.Handle("GET /v1/models", handlers.HandleModelsList(modelsIndex))

internal/api/docs/openapi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,18 @@ paths:
10821082
summary: SSE stream of the update process
10831083
tags:
10841084
- System
1085+
/v1/system/update/stop:
1086+
put:
1087+
description: Stop the upgrade process.
1088+
operationId: stopUpdate
1089+
responses:
1090+
"200":
1091+
description: Successful response
1092+
"409":
1093+
$ref: '#/components/responses/Conflict'
1094+
summary: Stop the upgrade process in background
1095+
tags:
1096+
- System
10851097
/v1/version:
10861098
get:
10871099
description: returns the application current version

internal/api/handlers/update.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ func HandleUpdateApply(updater *update.Manager) http.HandlerFunc {
125125
}
126126
}
127127

128+
func HandlerUpdateStop(updater *update.Manager) http.HandlerFunc {
129+
return func(w http.ResponseWriter, r *http.Request) {
130+
if updater.StopUpgrade() {
131+
render.EncodeResponse(w, http.StatusOK, "Upgrade operation cancellation requested")
132+
} else {
133+
render.EncodeResponse(w, http.StatusConflict, models.ErrorResponse{Details: "No upgrade operation in progress"})
134+
}
135+
}
136+
}
137+
128138
func HandleUpdateEvents(updater *update.Manager) http.HandlerFunc {
129139
return func(w http.ResponseWriter, r *http.Request) {
130140
// HOTFIX: app-lab use HEAD requests to check endpoint availability

internal/e2e/client/client.gen.go

Lines changed: 102 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)