Skip to content

Commit 3344a17

Browse files
Allow pinning garm-agent version and UX improvements
This change allows operators to pin the garm-agent version to a known good version that works with their setup. This should prevent situations where we do an update to the GARM agent, the controller automatically updates to latest and a potential requirement we added (ie: mandatory TLS) breaks their setup, or if the latest version of the agent requires a newer version of the agent. This change also gives users the ability to see available versions, with release notes directly in GARM, so they can decide whether or not they want to update. This is surfaced by both the CLI and the Web UI. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
1 parent e6947f2 commit 3344a17

32 files changed

Lines changed: 2947 additions & 516 deletions

apiserver/controllers/metadata.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,30 @@ func (a *APIController) AdminGARMToolsHandler(w http.ResponseWriter, r *http.Req
155155
}
156156
}
157157

158+
// swagger:route GET /tools/garm-agent/releases tools ListGARMAgentReleases
159+
//
160+
// List the garm-agent releases available at the controller's releases URL,
161+
// as recorded in the cached release index. The release the controller is
162+
// pinned to and the release "latest" resolves to are marked.
163+
//
164+
// Responses:
165+
// 200: GARMAgentReleases
166+
// 400: APIErrorResponse
167+
func (a *APIController) ListGARMAgentReleasesHandler(w http.ResponseWriter, r *http.Request) {
168+
ctx := r.Context()
169+
170+
releases, err := a.r.ListGARMAgentReleases(ctx)
171+
if err != nil {
172+
handleError(ctx, w, err)
173+
return
174+
}
175+
176+
w.Header().Set("Content-Type", "application/json")
177+
if err := json.NewEncoder(w).Encode(releases); err != nil {
178+
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
179+
}
180+
}
181+
158182
func (a *APIController) InstanceShowGARMToolHandler(w http.ResponseWriter, r *http.Request) {
159183
ctx := r.Context()
160184

apiserver/routers/routers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
267267
///////////////////////////////////////////////////////
268268
// Tools URLs (garm agent, cached gitea runner, etc) //
269269
///////////////////////////////////////////////////////
270+
// List garm-agent releases available upstream (from the cached release index)
271+
apiRouter.Handle("/tools/garm-agent/releases/", http.HandlerFunc(han.ListGARMAgentReleasesHandler)).Methods("GET", "OPTIONS")
272+
apiRouter.Handle("/tools/garm-agent/releases", http.HandlerFunc(han.ListGARMAgentReleasesHandler)).Methods("GET", "OPTIONS")
270273
apiRouter.Handle("/tools/garm-agent/", http.HandlerFunc(han.AdminGARMToolsHandler)).Methods("GET", "OPTIONS")
271274
apiRouter.Handle("/tools/garm-agent", http.HandlerFunc(han.AdminGARMToolsHandler)).Methods("GET", "OPTIONS")
272275
// Upload garm agent tool

apiserver/swagger-models.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,22 @@ definitions:
442442
type: object
443443
x-go-type:
444444
type: GARMAgentTool
445+
import:
446+
package: github.com/cloudbase/garm/params
447+
alias: garm_params
448+
GARMAgentReleases:
449+
type: array
450+
x-go-type:
451+
type: GARMAgentReleases
452+
import:
453+
package: github.com/cloudbase/garm/params
454+
alias: garm_params
455+
items:
456+
$ref: '#/definitions/GARMAgentRelease'
457+
GARMAgentRelease:
458+
type: object
459+
x-go-type:
460+
type: GARMAgentRelease
445461
import:
446462
package: github.com/cloudbase/garm/params
447463
alias: garm_params

apiserver/swagger.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,22 @@ definitions:
185185
alias: garm_params
186186
package: github.com/cloudbase/garm/params
187187
type: ForgeInstances
188+
GARMAgentRelease:
189+
type: object
190+
x-go-type:
191+
import:
192+
alias: garm_params
193+
package: github.com/cloudbase/garm/params
194+
type: GARMAgentRelease
195+
GARMAgentReleases:
196+
items:
197+
$ref: '#/definitions/GARMAgentRelease'
198+
type: array
199+
x-go-type:
200+
import:
201+
alias: garm_params
202+
package: github.com/cloudbase/garm/params
203+
type: GARMAgentReleases
188204
GARMAgentTool:
189205
type: object
190206
x-go-type:
@@ -3030,6 +3046,24 @@ paths:
30303046
summary: Upload a GARM agent tool binary.
30313047
tags:
30323048
- tools
3049+
/tools/garm-agent/releases:
3050+
get:
3051+
description: |-
3052+
as recorded in the cached release index. The release the controller is
3053+
pinned to and the release "latest" resolves to are marked.
3054+
operationId: ListGARMAgentReleases
3055+
responses:
3056+
"200":
3057+
description: GARMAgentReleases
3058+
schema:
3059+
$ref: '#/definitions/GARMAgentReleases'
3060+
"400":
3061+
description: APIErrorResponse
3062+
schema:
3063+
$ref: '#/definitions/APIErrorResponse'
3064+
summary: List the garm-agent releases available at the controller's releases URL,
3065+
tags:
3066+
- tools
30333067
produces:
30343068
- application/json
30353069
security:

client/tools/list_g_a_r_m_agent_releases_parameters.go

Lines changed: 128 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)