Commit graph

196 commits

Author SHA1 Message Date
Gabriel Adrian Samfira
72ec1bf68f No need to explicitly call Stop() on runner loops
Once the context is canceled, the loops will exit, so there is no
need to explicitly Stop(). We just need to Wait() for the loops to
exit.
2022-12-30 15:13:49 +00:00
Gabriel Adrian Samfira
d5f5524934 Wait for loop exit and some fixes
* Wait for http server graceful shutdown and for pool managers to
properly exit.
  * Fix potential nil pointer dereference when checking response
code from github API.
2022-12-30 15:07:40 +00:00
Gabriel Adrian Samfira
6fc950e513 Readd the instance status check
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-29 23:45:17 +00:00
Gabriel
59ddb4157a
Merge pull request #49 from gabriel-samfira/add-token-endpoint
Add a metadata resource for instances
2022-12-30 01:26:52 +02:00
Gabriel Adrian Samfira
a91f64331e Limit instances to one runner token 2022-12-29 22:57:10 +00:00
Gabriel Adrian Samfira
3a92a5be0e Some cleanup and safety checks
* Add logging middleware
  * Remove some noise from logs
  * Add some safety checks when managing runners
2022-12-29 16:50:11 +00:00
Gabriel Adrian Samfira
5bc2bec991 Update docs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-07 15:29:35 +00:00
Gabriel Adrian Samfira
45357359a4 Update docs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-07 15:03:34 +00:00
Gabriel Adrian Samfira
7e42ba6ecc Make curl fail on error
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-06 20:03:16 +00:00
Gabriel Adrian Samfira
2085ad6945 Remove unused field and sync azure provider
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-06 20:01:10 +00:00
Gabriel Adrian Samfira
d3fe741cfe Don't save runner registration tolen in DB
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-06 19:48:00 +00:00
Gabriel Adrian Samfira
0b50397b47 Make sure to decode token
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-06 15:28:36 +00:00
Gabriel Adrian Samfira
dfc3c1ff5c Update providers to use new token URL
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-05 21:29:30 +00:00
Gabriel Adrian Samfira
cb5baeb547 Add Enterprise tests 2022-12-04 17:30:42 +00:00
Gabriel Adrian Samfira
0869073906 Define a metadata subrouter
Define a metadata subrouter and move the token endpoint there. We may
end up needing multiple endpoints for various purposes in the future.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-12-02 19:48:38 +00:00
Gabriel Adrian Samfira
a078645ab2
Add token endpoint
This change adds a github registration endpoint that instances can use
to fetch a github registration token.

This change also invalidates disables access to an instance to the token
and status updates endpoints once the instance transitions from
"pending" or "installing" to any other state.
2022-12-01 18:00:22 +02:00
Gabriel
eba42b0481
Merge pull request #37 from gabriel-samfira/add-ghe-server-support
Add GitHub Enterprise support
2022-10-21 17:58:52 +03:00
Gabriel Adrian Samfira
f13d63b2e4
Use logWriter instead of os.Stdout 2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
970ffb608e
Mark pool manager as offline in case of 403
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
05057e37fd
Start pool managers in the background
Garm no longer fails on startup if a pool manager cannot be started. It
will attempt to start the pool manager in the background. If it fails
due to an unauthorized error, it will sleep for 3 hours. It is unlikely
it will work a second time if credentials are not updated in the config
and garm is restarted, so no point in getting rate limited.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
80452aac39
Update go-github and remove redirect 2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
adaeaa48f8
Properly paginate
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
b8e3303e54
Lower tools update interval 2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
95379b81bc
Update docs 2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
afb2bd9ab8
Fix internal config credentials
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
3e3b91ee59
Add enterprise support to garm-cli
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
fb344ab2f2
Update vendor
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03: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
f40420bfb6
Add ability to specify github enpoints for creds
The GitHub credentials section now allows setting some API endpoints
that point the github client and the runner setup script to the propper
URLs. This allows us to use garm with an on-prem github enterprise server.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:14:03 +03:00
Gabriel Adrian Samfira
a55f852161
Use multi writer for API logs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 17:13:53 +03:00
Gabriel Adrian Samfira
b4496fef1c
Update sample nginx config 2022-10-21 12:36:57 +03:00
Gabriel
3247065c0a
Merge pull request #46 from gabriel-samfira/add-log-stream
Add log streamer
2022-10-21 12:21:19 +03:00
Gabriel Adrian Samfira
d277c0d275
Add enable_log_streamer to sample config 2022-10-21 11:48:51 +03:00
Gabriel Adrian Samfira
16b56c89de
Format message on error 2022-10-21 11:38:16 +03:00
Gabriel Adrian Samfira
bad7398b6c
Convert byte array to string 2022-10-21 11:23:04 +03:00
Gabriel Adrian Samfira
a7f151e2d2
Add log streamer
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-21 11:13:42 +03:00
Gabriel
79087d1347
Merge pull request #45 from ionutbalutoiu/contrib-providers-fixes
Fix azure and openstack external providers
2022-10-21 10:44:51 +03:00
Ionut Balutoiu
85fd3924ee Fix azure and openstack external providers
* The `{{ .RunnerUsername }}` is not replaced in any external providers' scripts.
  However, we can safely assume that the username is properly created by
  cloud-init before the userdata is executed.
* Correctly use the `OS_TO_GH_ARCH_MAP` bash map.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2022-10-21 10:26:06 +03:00
Gabriel
0699973abe
Merge pull request #43 from mihaelabalutoiu/add-db-repositories-unit-tests
Add unit tests for the `database/sql/repositories.go`
2022-10-18 16:59:09 +03:00
Mihaela Balutoiu
989717dcfa Add unit tests for the database/sql/repositories.go
Add more test cases regarding the SQL database interactions.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-18 16:44:10 +03:00
Gabriel
19e31cc922
Merge pull request #42 from mihaelabalutoiu/fix-error-wrap
Fixed error wrap
2022-10-18 10:17:07 +03:00
Gabriel
8db1f05d09
Merge pull request #41 from gabriel-samfira/do-not-remove-foreign-runners
Don't remove foreign runners
2022-10-18 08:46:15 +03:00
Gabriel Adrian Samfira
49fbc110d5
Don't remove foreign runners
When garm starts up, it attempts to cleanup any orphaned runners from
github. This, unfortunately ends up deleting manually set up runners.
This change looks for our controller ID in the labels of the runners and
only deleted runners that we created.

Fixes: #40

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-17 18:45:48 +03:00
Mihaela Balutoiu
36a51f83ab Fixed error wrap
The error is not wrapped correctly, because instead of using `q.Error`,
it uses `err`, which is defined elsewhere.

Also, the `UpdateRepository` and `CreateRepositoryPool` functions will
never fail on update/create repo, because it returns a nil error, instead
of wrap error.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-17 17:48:00 +03:00
Gabriel
996102fd98
Merge pull request #39 from mihaelabalutoiu/add-db-repositories-unit-tests
Add more test cases for the `database/sql/repositories.go`
2022-10-17 13:39:29 +03:00
Mihaela Balutoiu
04e89ce1ab Add more test cases for the database/sql/repositories.go
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-17 13:35:38 +03:00
Gabriel
5ff935a4da
Merge pull request #38 from mihaelabalutoiu/add-db-repositories-unit-tests
Add `repositories.go` unit testing
2022-10-14 19:15:33 +03:00
Mihaela Balutoiu
98306dd25a Add repositories.go unit testing
Add initial unit tests for the `database/sql/repositories.go` from `sql`package.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-14 18:10:34 +03:00
Gabriel
68100e438b
Merge pull request #36 from mihaelabalutoiu/add-db-pools-unit-tests
Add `pools.go` database unit tests
2022-10-13 18:39:07 +03:00
Mihaela Balutoiu
c65cf9ab0c Add pools.go database unit tests
Add full tests coverage for `database/sql/pools.go` file.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2022-10-13 17:57:00 +03:00