Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit df1eb43

Browse files
add stop upgrade endpoint
1 parent 5be93c5 commit df1eb43

File tree

9 files changed

+387
-123
lines changed

9 files changed

+387
-123
lines changed

‎cmd/gendoc/docs.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,21 @@ Contains a JSON object with the details of an error.
824824
{StatusCode: http.StatusNoContent, Reference: "#/components/responses/NoContent"},
825825
},
826826
},
827+
{
828+
OperationId: "stopUpdate",
829+
Method: http.MethodPut,
830+
Path: "/v1/system/update/stop",
831+
CustomSuccessResponse: &CustomResponseDef{
832+
Description: "Successful response",
833+
StatusCode: http.StatusOK,
834+
},
835+
Description: "Stop the upgrade process.",
836+
Summary: "Stop the upgrade process in background",
837+
Tags: []Tag{SystemTag},
838+
PossibleErrors: []ErrorResponse{
839+
{StatusCode: http.StatusConflict, Reference: "#/components/responses/Conflict"},
840+
},
841+
},
827842
{
828843
OperationId: "applyUpdate",
829844
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
@@ -1080,6 +1080,18 @@ paths:
10801080
summary: SSE stream of the update process
10811081
tags:
10821082
- System
1083+
/v1/system/update/stop:
1084+
put:
1085+
description: Stop the upgrade process.
1086+
operationId: stopUpdate
1087+
responses:
1088+
"200":
1089+
description: Successful response
1090+
"409":
1091+
$ref: '#/components/responses/Conflict'
1092+
summary: Stop the upgrade process in background
1093+
tags:
1094+
- System
10831095
/v1/version:
10841096
get:
10851097
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
@@ -107,6 +107,16 @@ func HandleUpdateApply(updater *update.Manager) http.HandlerFunc {
107107
}
108108
}
109109

110+
func HandlerUpdateStop(updater *update.Manager) http.HandlerFunc {
111+
return func(w http.ResponseWriter, r *http.Request) {
112+
if updater.StopUpgrade() {
113+
render.EncodeResponse(w, http.StatusOK, "Upgrade operation cancellation requested")
114+
} else {
115+
render.EncodeResponse(w, http.StatusConflict, models.ErrorResponse{Details: "No upgrade operation in progress"})
116+
}
117+
}
118+
}
119+
110120
func HandleUpdateEvents(updater *update.Manager) http.HandlerFunc {
111121
return func(w http.ResponseWriter, r *http.Request) {
112122
sseStream, err := render.NewSSEStream(r.Context(), w)

‎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)

AltStyle によって変換されたページ (->オリジナル) /