-
Notifications
You must be signed in to change notification settings - Fork 10
Add new capacity resource #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ac05c81
Add new capacity resource
SuperSandro2000 a713dea
Resolve easy todo to check for audit events
SuperSandro2000 118e499
Bump liquid info version and test /liquid/v1/info endpoint
SuperSandro2000 4c104ed
Switch to standard helpers for uploading
SuperSandro2000 ad6a8a7
Handle the absence of images when doing a resource request as an error
SuperSandro2000 8e5ea80
Add quotas test with bytes enabled
SuperSandro2000 9dd637a
Expand quota test coverage
SuperSandro2000 ac15c74
Do not default bytes quota to 0 to make migration easier
SuperSandro2000 fdf5ea1
Move liquid to its own process
SuperSandro2000 4f00e09
Combine all the environment tables into one
SuperSandro2000 b272ede
Minor doc fixes
SuperSandro2000 06f276b
Do not pass a boolean to DefaultQuotas
SuperSandro2000 9f4d388
Add some envs missing for liquidapi
SuperSandro2000 3439d73
Use DefaultQuotas to construct test quotas
SuperSandro2000 5ae55d0
Use -1 to represent infinity quota bytes
SuperSandro2000 068bb43
Fix more doc
SuperSandro2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package liquidapicmd | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/dlmiddlecote/sqlstats" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/prometheus/client_golang/prometheus/promhttp" | ||
| "github.com/sapcc/go-bits/easypg" | ||
| "github.com/sapcc/go-bits/httpapi" | ||
| "github.com/sapcc/go-bits/httpapi/pprofapi" | ||
| "github.com/sapcc/go-bits/httpext" | ||
| "github.com/sapcc/go-bits/must" | ||
| "github.com/sapcc/go-bits/osext" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/sapcc/keppel/internal/api/liquid" | ||
| "github.com/sapcc/keppel/internal/keppel" | ||
| ) | ||
|
|
||
| // AddCommandTo mounts this command into the command hierarchy. | ||
| func AddCommandTo(parent *cobra.Command) { | ||
| cmd := &cobra.Command{ | ||
| Use: "liquidapi", | ||
| Short: "Run the keppel-liquidapi server component.", | ||
| Long: "Run the keppel-liquidapi server component. Configuration is read from environment variables as described in README.md.", | ||
| Args: cobra.NoArgs, | ||
| Run: run, | ||
| } | ||
| parent.AddCommand(cmd) | ||
| } | ||
|
|
||
| func run(cmd *cobra.Command, args []string) { | ||
| _, _ = cmd, args | ||
|
|
||
| keppel.SetTaskName("liquidapi") | ||
|
|
||
| cfg := keppel.ParseConfiguration() | ||
| ctx := httpext.ContextWithSIGINT(cmd.Context(), 10*time.Second) | ||
| auditor := must.Return(keppel.InitAuditTrail(ctx)) | ||
|
|
||
| dbURL, dbName := keppel.GetDatabaseURLFromEnvironment() | ||
| dbConn := must.Return(easypg.Connect(dbURL, keppel.DBConfiguration())) | ||
| prometheus.MustRegister(sqlstats.NewStatsCollector(dbName, dbConn)) | ||
| db := keppel.InitORM(dbConn) | ||
|
|
||
| ad := must.Return(keppel.NewAuthDriver(ctx, osext.MustGetenv("KEPPEL_DRIVER_AUTH"), nil)) | ||
| sd := must.Return(keppel.NewStorageDriver(osext.MustGetenv("KEPPEL_DRIVER_STORAGE"), ad, cfg)) | ||
|
|
||
| // wire up HTTP handlers | ||
| handler := httpapi.Compose( | ||
| liquid.NewLiquidAPI(cfg, ad, sd, db, auditor), | ||
| httpapi.HealthCheckAPI{ | ||
| SkipRequestLog: true, | ||
| Check: func() error { | ||
| return db.Db.PingContext(ctx) | ||
| }, | ||
| }, | ||
| pprofapi.API{IsAuthorized: pprofapi.IsRequestFromLocalhost}, | ||
| ) | ||
| mux := http.NewServeMux() | ||
| mux.Handle("/", handler) | ||
| mux.Handle("/metrics", promhttp.Handler()) | ||
|
|
||
| // start HTTP server | ||
| apiListenAddress := osext.GetenvOrDefault("KEPPEL_LIQUIDAPI_LISTEN_ADDRESS", ":8080") | ||
| must.Succeed(httpext.ListenAndServeContext(ctx, apiListenAddress, mux)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.