Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/gendoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,21 @@ Contains a JSON object with the details of an error.
{StatusCode: http.StatusNoContent, Reference: "#/components/responses/NoContent"},
},
},
{
OperationId: "stopUpdate",
Method: http.MethodPut,
Path: "/v1/system/update/stop",
CustomSuccessResponse: &CustomResponseDef{
Description: "Successful response",
StatusCode: http.StatusOK,
},
Description: "Stop the upgrade process.",
Summary: "Stop the upgrade process in background",
Tags: []Tag{SystemTag},
PossibleErrors: []ErrorResponse{
{StatusCode: http.StatusConflict, Reference: "#/components/responses/Conflict"},
},
},
{
OperationId: "applyUpdate",
Method: http.MethodPut,
Expand Down
1 change: 1 addition & 0 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func NewHTTPRouter(
mux.Handle("GET /v1/system/update/check", handlers.HandleCheckUpgradable(updater))
mux.Handle("GET /v1/system/update/events", handlers.HandleUpdateEvents(updater))
mux.Handle("PUT /v1/system/update/apply", handlers.HandleUpdateApply(updater))
mux.Handle("PUT /v1/system/update/stop", handlers.HandlerUpdateStop(updater))
mux.Handle("GET /v1/system/resources", handlers.HandleSystemResources())

mux.Handle("GET /v1/models", handlers.HandleModelsList(modelsIndex))
Expand Down
12 changes: 12 additions & 0 deletions internal/api/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,18 @@ paths:
summary: SSE stream of the update process
tags:
- System
/v1/system/update/stop:
put:
description: Stop the upgrade process.
operationId: stopUpdate
responses:
"200":
description: Successful response
"409":
$ref: '#/components/responses/Conflict'
summary: Stop the upgrade process in background
tags:
- System
/v1/version:
get:
description: returns the application current version
Expand Down
10 changes: 10 additions & 0 deletions internal/api/handlers/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ func HandleUpdateApply(updater *update.Manager) http.HandlerFunc {
}
}

func HandlerUpdateStop(updater *update.Manager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if updater.StopUpgrade() {
render.EncodeResponse(w, http.StatusOK, "Upgrade operation cancellation requested")
} else {
render.EncodeResponse(w, http.StatusConflict, models.ErrorResponse{Details: "No upgrade operation in progress"})
}
}
}

func HandleUpdateEvents(updater *update.Manager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
sseStream, err := render.NewSSEStream(r.Context(), w)
Expand Down
102 changes: 102 additions & 0 deletions internal/e2e/client/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading