Commit graph

421 commits

Author SHA1 Message Date
Gabriel Adrian Samfira
b17c921a7c
Add Run() function
* Add Run() helper for external providers
  * Make GARM_CONTROLLER_ID env var common to all commands

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-15 01:35:42 +02:00
Gabriel Adrian Samfira
e29d5db72c
Properly detect if we have something on stdin
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-14 20:20:26 +02:00
Gabriel Adrian Samfira
223477c4dd
Define interface for external providers
This interface is similar to the common.Provider interface, but lacks
the AsParams() function. Decoupling the external provider interface from
the internal provider interface allows us to account for any
particularities there may appear between them.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-14 19:49:54 +02:00
Gabriel Adrian Samfira
882d07a0da
Add execution environment to external provider
The execution package is a common package that can be used by external
providers to load environment variables and stdin, in a coherent struct
that can be consumed by the various commands that need to execute as
part of the provider.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-14 18:28:31 +02:00
Gabriel
e67c08b1d4
Merge pull request #81 from gabriel-samfira/move-some-variables
Move some defaults and types from config
2023-03-14 14:21:26 +02:00
Gabriel Adrian Samfira
0074af9370
Move some defaults and types from config
The params package should not depend on config. The params packages
should be consumable by external applications that wish to interact with
garm, and it makes no sense to pull in the config package just for some
constants. As such, the following changes have been made:

  * Moved some types from config to params
  * Moved defaults in a new leaf package called appdefaults

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-14 14:15:10 +02:00
Gabriel
086a4564ea
Merge pull request #80 from gabriel-samfira/rename-module
Rename module
2023-03-12 16:27:12 +02:00
Gabriel Adrian Samfira
c61b7fd268
Update go modules
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-03-12 16:22:37 +02: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
24f61ceb8c
Merge pull request #78 from gabriel-samfira/add-scale-down-grace-period
Add grace period to scale-down
2023-02-08 15:16:28 +02:00
Gabriel Adrian Samfira
43d2fd8c2d
Add grace period to scale-down
Add a grace period for idle runners of 5 minutes. A new idle runner will
not be taken into consideration for scale-down unless it's older than 5
minutes. This should prevent situations where the scaleDown() routine
that runs every minute will evaluate candidates for reaping and
erroneously count the new one as well. The in_progress hooks that
transitiones an idle runner to "active" may arive a long while after the
"queued" hook has spun up a runner.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-02-07 13:36:15 +02:00
Gabriel
226536b587
Merge pull request #77 from gabriel-samfira/fix-instance-retry
Bail if we fail to cleanup failed instance
2023-02-07 13:20:39 +02:00
Gabriel
439eeee479
Update runner/pool/pool.go
Co-authored-by: Michael Kuhnt <maigl@users.noreply.github.com>
2023-02-07 13:14:28 +02:00
Gabriel Adrian Samfira
77307998ea
Bail if we fail to cleanup failed instance
if we fail to cleanup failed instance, we return before retrying to
recreate it.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-02-06 14:53:23 +02:00
Gabriel
fc1012d4a1
Merge pull request #75 from gabriel-samfira/fix-list-instances-in-examples
Fix ListInstances in external provider examples
2023-02-03 19:22:05 +02:00
Gabriel Adrian Samfira
4982cab608
Fix ListInstances in external provider examples
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-02-03 19:16:20 +02:00
Gabriel
05137675d2
Merge pull request #73 from mercedes-benz/idle-pool
fix: skip spawn new runners if enough idle runner available
2023-01-31 18:01:40 +02:00
Michael Kuhnt
4eb8d905ab
fix: skip spawn new runners if enough idle runner available 2023-01-31 16:38:04 +01:00
Gabriel
c219d4fd84
Merge pull request #72 from gabriel-samfira/fix-tls-listener
Fix TLS listener
2023-01-31 15:49:52 +02:00
Gabriel Adrian Samfira
27a523f133 Fix TLS listener
The TLS listener was not being set up correctly. The TLSConfig was changed
to include only cert and key. The cert now needs to be a full chain bundle
including intermediary CA certificates. The ca_cert config option was removed.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-31 13:42:39 +00:00
Gabriel
1ad52e87ef
Merge pull request #71 from gabriel-samfira/add-extra-specs
Add extra specs on pools
2023-01-30 18:09:50 +02:00
Gabriel Adrian Samfira
040cb0f5f6 Add extra-specs flag
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-30 16:03:50 +00:00
Gabriel Adrian Samfira
d00da32375 Deduplicate some code
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-30 14:29:55 +00:00
Gabriel Adrian Samfira
f25951decb Add extra specs on pools
Extra specs is an opaque valid JSON that can be set on a pool and which
will be passed along to the provider as part of instance bootstrap params.

This field is meant to allow operators to send extra configuration values
to external or built-in providers. The extra specs is not interpreted or
useful in any way to garm itself, but it may be useful to the provider
which interacts with the IaaS.

The extra specs are not meant to be used for secrets. Adding sensitive
information to this field is highly discouraged. This field is meant as a    
means to add fine tuning knobs to the providers, on a per pool basis.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-30 13:10:21 +00:00
Gabriel
1867bbaad6
Merge pull request #70 from gabriel-samfira/move-some-code-around
Move some code around
2023-01-29 17:58:22 +02:00
Gabriel Adrian Samfira
8d17498ab8
Remove caches, retry fetching the hostname
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-29 16:03:20 +02:00
Gabriel Adrian Samfira
77f96d2761 Drive-by fix: Get propper runner prefix for pool
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-27 15:00:06 +00:00
Gabriel Adrian Samfira
4d071b7d10 Return only alpha numeric characters as an ID
On some providers the default character set used by shortid may lead to
errors when creating runners, due to the fact that underscores are not
allowed in their names.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-27 14:57:25 +00:00
Gabriel Adrian Samfira
8f56f51598 Move some code around
Move the metrics code into its own package.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-27 14:57:25 +00:00
Gabriel
a3ddb5e63a
Merge pull request #69 from mercedes-benz/fix-update-prefix
fix: don't update empty runner prefix
2023-01-27 10:54:11 +02:00
Michael Kuhnt
ddae6095a1
fix: don't update unset runner prefix 2023-01-27 09:05:58 +01:00
Gabriel
9dcd9df95f
Merge pull request #60 from mercedes-benz/metrics
feat: add prometheus metrics & endpoint
2023-01-26 23:58:57 +02:00
Michael Kuhnt
6cd18ff1fd
improve access to controller info 2023-01-26 22:13:18 +01:00
Michael Kuhnt
6a032bfaa2
metrics: fix review findings 2023-01-26 15:46:27 +01:00
Michael Kuhnt
ee659f509f
feat: add prometheus metrics & endpoint 2023-01-26 14:15:16 +01:00
Gabriel
a0670c6503
Merge pull request #61 from mercedes-benz/fix-webhook-signature-validation
Fix webhook signature validation
2023-01-24 15:08:03 +02:00
mgoeppe
0ebd20620d added secret check in param validation 2023-01-24 08:56:57 +01:00
mgoeppe
dce1808860 fixed runner tests 2023-01-24 08:51:25 +01:00
mgoeppe
f9f917ba05 aligned code enterprises,organizations and repositories and fixed sql tests 2023-01-24 08:51:25 +01:00
mgoeppe
5813dce051 fix webhook validation for enterprises
* also list needs to decrypt the secret
2023-01-24 08:47:54 +01:00
Gabriel
03d632c2b6
Merge pull request #68 from gabriel-samfira/sanitize-log-entries
Sanitize log entries
2023-01-23 18:06:06 +02:00
Gabriel Adrian Samfira
e93b6d73e5
Sanitize log entries
While most of these log entries come from either github or our own
database, it's still a good idea to sanitize them.
2023-01-23 18:01:46 +02:00
Gabriel
114f17718b
Merge pull request #67 from gabriel-samfira/disable-windows-build
Disable Windows binary build
2023-01-21 01:45:51 +02:00
Gabriel Adrian Samfira
b8e02ecbe1
Disable Windows binary build
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-21 01:32:19 +02:00
Gabriel
baa02dde98
Create codeql.yml 2023-01-21 01:21:03 +02:00
Gabriel Adrian Samfira
ee06fe7384
Add lint, fmt and install-lint-deps targets
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-21 00:41:33 +02:00
Gabriel Adrian Samfira
3aef31d0f0
Make verify-vendor message more friendly
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-21 00:26:20 +02:00
Gabriel
e96caf4711
Merge pull request #66 from gabriel-samfira/add-aditional-checks
Fix linting errors and add workflow to check
2023-01-21 00:01:55 +02:00
Gabriel Adrian Samfira
70fd3f47d0
Remove unused functions
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-20 23:57:03 +02:00
Gabriel Adrian Samfira
4063265478
Add checks for gofmt
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-01-20 23:43:48 +02:00