Commit graph

40 commits

Author SHA1 Message Date
Gabriel Adrian Samfira
ef3402bf17 Add write lock for sqlite3
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-29 17:22:14 +00:00
Gabriel Adrian Samfira
750446acec Make the default github.com endpoint mutable
The k8s operator seems to want to define its own endpoint. This change
allows the removal of the default gh endpoint if no credentials are tied
to it.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-24 13:35:17 +00:00
Gabriel Adrian Samfira
dd1740c189 Refactor the websocket client and add fixes
The websocket client and hub interaction has been simplified a bit.
The hub now acts only as a tee writer to the various clients that
register. Clients must register and unregister explicitly. The hub
is no longer passed in to the client.

Websocket clients now watch for password changes or jwt token expiration
times. Clients are disconnected if auth token expires or if the password
is changed.

Various aditional safety checks have been added.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-07-05 12:55:35 +00:00
Gabriel Adrian Samfira
892a62bfe4 Allow configuration of job backoff interval
GARM has a backoff interval when consuming queued jobs. This backoff
is intended to allow any potential idle runners to pick up a job before
GARM attempts to spin up a new one. This change allows users to set a
custom backoff interval or disable it altogether by setting it to 0.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-07-01 10:27:31 +00:00
Gabriel Adrian Samfira
b51683f1ae Add some tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-06-17 19:42:50 +00:00
Gabriel Adrian Samfira
8d57fc8fa2 Add rudimentary database watcher
Adds a simple database watcher. At this point it's just one process, but
the plan is to allow different implementations that inform the local running
workers of changes that have occured on entities of interest in the database.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-06-14 19:47:12 +00:00
Gabriel
75eb45c97a
Update database/sql/sql.go
Co-authored-by: Mario Constanti <github@constanti.de>
2024-05-07 13:13:16 +03:00
Gabriel Adrian Samfira
208a4eea37 Ensure github endpoint
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-22 14:08:37 +00:00
Gabriel Adrian Samfira
eadbe784b9 Add github credentials API and cli code
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-22 14:08:37 +00:00
Gabriel Adrian Samfira
257fb0b09a Take into account legacy config
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-22 14:08:37 +00:00
Gabriel Adrian Samfira
90870c11be Use database for github creds
Add database models that deal with github credentials. This change
adds models for github endpoints (github.com, GHES, etc). This change
also adds code to migrate config credntials to the DB.

Tests need to be fixed and new tests need to be written. This will come
in a later commit.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-22 14:03:25 +00:00
Gabriel Adrian Samfira
e441b6ce89 Switch to log/slog
This change switches GARM to the new structured logging standard
library. This will allow us to set log levels and reduce some of
the log spam.

Given that we introduced new knobs to tweak logging, the number of
config options for logging now warrants it's own section.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-01-05 23:46:40 +00:00
Gabriel Adrian Samfira
59e6fb28c2 Create relation between WorkflowJobs and Instances
Ensure that there is a foreign key constraint between runners and jobs.
Once a runner is associated with a job, we want the job to be removed along
with the runner.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-26 19:45:59 +00:00
Gabriel Adrian Samfira
dea941df43 Set on delete for jobs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-05 19:49:48 +00:00
Gabriel Adrian Samfira
774b790cca tweak select
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-03 07:46:20 +00:00
Gabriel Adrian Samfira
6169677cd9 Convert uuid.Nil to NULL
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-03 07:46:20 +00:00
Gabriel Adrian Samfira
f027bc4fbd Attempt to add OnDelete:CASCADE to sqlite
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-03 07:46:20 +00:00
Gabriel Adrian Samfira
4a2ba68867 Use the same db connection in runner
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-03 07:46:20 +00:00
Gabriel Adrian Samfira
b3c754c015 set max connections to 1 when using sqlite3
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-03 07:46:20 +00:00
Gabriel Adrian Samfira
fbffd8157b Add job tracking
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-03 07:46:20 +00:00
Gabriel Adrian Samfira
829db87f15
Rename module
This change renames the module from "garm" to "github.com/cloudbase/garm".

This will make it easier to consume public functions defined in garm, by
external applications, without having to resort to replace.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-12 16:01:49 +02:00
Gabriel Adrian Samfira
296333412a
Add enterprise support
This change adds enterprise support throughout garm.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
0ff2fd2e06
Make owners and repos case insensitive
Github treats owners (users and orgs) and repos as case insensitive. To
github, https://github.com/cloudbase/garm is equivalent to
https://github.com/CloudBase/GaRm. This commit makes the sql store
backend, case insensitive when querying repos and orgs.

Fixes: #25

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-05 18:14:07 +03:00
Gabriel Adrian Samfira
99856af4de
Silence gorm default logger
Disable the default logger for gorm when debug is not set on the sql
store backend. By default gorm will print error level log messages,
which includes queries which find no results, which is not really an
error.

These messages will show up if debug is enabled on the sql store
backend.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-09-06 21:35:01 +03:00
Gabriel Adrian Samfira
afb1d31394 Slight cleanup
* added interface for the github client. This will help mocking it
out for testing.
  * removed some unused code
  * moved some code around

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-07-07 16:48:00 +00:00
Gabriel Adrian Samfira
5e0a64f909 Add license headers 2022-05-05 13:25:50 +00:00
Gabriel Adrian Samfira
3e416d8272 Slight refactor of sql code 2022-05-04 13:15:27 +00:00
Gabriel Adrian Samfira
1dda4a835c Rename project to garm
Project renamed to garm (Github Actions Runner Manager)
2022-05-04 11:44:10 +00:00
Gabriel Adrian Samfira
2bd128af13 Runners now send status messages 2022-05-03 19:49:14 +00:00
Gabriel Adrian Samfira
6bdb8cd78b return proper error on conflict 2022-05-03 13:20:49 +00:00
Gabriel Adrian Samfira
8ceafff09b Add more CLI commands 2022-05-03 12:40:59 +00:00
Gabriel Adrian Samfira
475d424f32 Add a basic CLI 2022-05-02 17:55:29 +00:00
Gabriel Adrian Samfira
7ec937a138 Main webhook cases implemented
Queued, completed and in_progress workflow_job messages are now
acted upon.
2022-04-29 23:43:37 +00:00
Gabriel Adrian Samfira
a78ad539fe Auto create runners for pools 2022-04-29 16:08:31 +00:00
Gabriel Adrian Samfira
0314fd3b67 Add some API resources 2022-04-29 14:18:22 +00:00
Gabriel Adrian Samfira
75e06b36b0 Fix GetUser 2022-04-28 16:24:26 +00:00
Gabriel Adrian Samfira
0883fcd5cd Add some basic auth 2022-04-28 16:13:20 +00:00
Gabriel Adrian Samfira
66b46ae0ab Implement some more db functions 2022-04-27 16:56:28 +00:00
Gabriel Adrian Samfira
62ba5a5a08 WiP 2022-04-26 20:29:58 +00:00
Gabriel Adrian Samfira
2be5653683 Added some DB logic 2022-04-25 00:21:44 +00:00