Commit graph

44 commits

Author SHA1 Message Date
Tomáš Hozza
992c6365f0 Use gcp upload implementation from osbuild/images
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-08-14 13:23:49 +02:00
Tomáš Hozza
3db1f88f84 internal/awscloud: use AWS.DeleteEC2Image() from osbuild/images
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-08-13 09:36:58 +02:00
Tomáš Hozza
e7d8431489 internal/awscloud: use AWS.TerminateInstancesEC2() from osbuild/images
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-08-13 09:36:58 +02:00
Lukas Zapletal
0e5d8a94f2 cmd: use log in service-maintenance 2025-05-12 15:20:16 +02:00
Florian Schüller
153bcadf2d osbuild-service-maintenance/aws: merge errors
Collect and merge errors, instead of
nesting errors.
In this case we want to continue execution if only one
cleanup fails.
2024-12-10 11:43:51 +01:00
Florian Schüller
87ef1527fc osbuild-service-maintenance/aws: avoid error on empty list
Passing an empty list to `TerminateInstances` causes an
error message, which is not necessary, as there is
nothing to terminate.
2024-12-10 11:43:51 +01:00
Florian Schüller
24e256c225 osbuild-service-maintenance: add test for allTerminated
HMS-3632
2024-12-10 11:43:51 +01:00
Florian Schüller
65b7ee65b2 osbuild-service-maintenance: implement removal of launch templates
Launch templates of instances that are terminated should be removed.
HMS-3632
2024-12-10 11:43:51 +01:00
Florian Schüller
a96ea533c0 osbuild-service-maintenance: implement removal of security groups
Security groups of instances that are terminated should be removed.
HMS-3632
2024-12-10 11:43:51 +01:00
Florian Schüller
7ebe266d3c osbuild-service-maintenance: implement removal on invalid parent
Add a safeguard to ensure secure instances without valid
parent instances are terminated, as they are unnecessary to retain.
Typically, the parent does not exist if the secure instance is
older than 2 hours, but this check provides additional validation.
HMS-3632
2024-12-10 11:43:51 +01:00
Florian Schüller
a7119a4d0f osbuild-service-maintenance/aws: support aws credential file
Support running the maintenance locally with a valid
`~/aws/credentials` file. HMS-3632
2024-12-10 11:43:51 +01:00
Sanne Raymaekers
056b3c5ea6 jobqueue: return if a job was requeued or not 2024-11-07 17:18:48 +01:00
Florian Schüller
00d3f07d08 Makefile: implement make db-tests
enables the option to run the DB tests locally
that are executed in the github actions
2024-11-06 15:16:42 +01:00
Sanne Raymaekers
c1b67440c4 cmd/osbuild-service-maintenance: respect dry run
Respect dry run when terminating leftover SIs.
2024-10-28 10:59:25 +01:00
Sanne Raymaekers
661f39cbb9 cmd/osbuild-service-maintenance: add test for filtering SIs 2024-10-23 10:32:57 +02:00
Sanne Raymaekers
04a5ca6965 cmd/osbuild-service-maintenance: clean up secure instances
Now and then there are leftover secure instances, probably when worker
instances get terminated during builds, this is possible in ASGs. 2
hours as a cutoff should be enough, since the build times out after 60
minutes, and fetching the output archive after 30 minutes, so that
leaves 30 minutes for booting and connection.
2024-10-23 10:32:57 +02:00
Sanne Raymaekers
c87cbe0cbc osbuild-service-maintenance: adapt to aws sdk v2 2024-08-20 15:32:40 +02:00
Sanne Raymaekers
5a776c5b79 templates/openshift: split worker from composer maintenance 2024-04-25 17:32:21 +02:00
Sanne Raymaekers
d784075d31 jobqueue: add ability to track workers 2023-12-06 17:22:36 +01:00
Brian C. Lane
b1c2dbdfc6 Remove old build tag comments
Go is transitioning from the old '// +build' form to '//go:build', this
removes all uses of the old form, adding the new one where needed.

See https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md
2023-03-07 09:22:23 -08:00
Sanne Raymaekers
2e3dd16220 osbuild-service-maintenance: clean up all regions
Since we started cloning images to different regions, the maintenance
script should clean up all of these regions.
2023-01-25 14:20:51 +01:00
Ondřej Budai
0359647a82 go.mod: update to Go 1.18
Fedora 35 support was dropped, so we can update to a newer Go.

Stable RHEL 8 and 9 and Fedora 36 ships Go 1.18, so let's switch to it.

"//go:build" directives are now apparently enforced by go fmt, so that's why
there were added.

Also, all the github actions were adjusted to use Go 1.18.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-01-09 14:03:18 +01:00
Tom Gundersen
626530818d worker/server: requeue unresponsive jobs
If a job is unresponsive the worker has most likely crashed or been shut
down and the in-progress job been lost.

Instead of failing these jobs, requeue them up to two times. Once a job is lost
a third time it fails. This avoids infinite loops.

This is implemented by extending FinishJob to RequeuOrFinish job. It takes a
max number of requeues as an argument, and if that is 0, it has the same
behavior as FinishJob used to have.

If the maximum number of requeues has not yet been reached, then the running
job is returned to pending state to be picked up again.
2022-11-02 15:26:00 +01:00
Sanne Raymaekers
0fe3f1b2ae jobqueue: Query job dependents 2022-08-30 16:14:52 +02:00
Sanne Raymaekers
fa18206918 osbuild-service-maintenance: Rely on the db's timezone in tests
Avoid calculating the new expire date on the test host, because
differences in timezones can yield unexpected failures.
2022-08-01 10:59:05 +02:00
Sanne Raymaekers
69d4429e8f osbuild-service-maintenance: Honor dryrun in db cleanup 2022-08-01 10:59:05 +02:00
Sanne Raymaekers
2eaad3701d osbuild-service-maintenance: Reword log messages and query name
The query is deleting multiple jobs, and it's deleting the entire job,
not just the results.
2022-08-01 10:59:05 +02:00
Sanne Raymaekers
c78c69b273 osbuild-service-maintenance: Run vacuum analyze after each delete 2022-07-28 16:53:55 +02:00
Simon de Vlieger
78ae275c61 jobqueue: store an expiry date
This introduces an expiry date (default: 14 days from insert date) and
adjust the service-maintenance script to delete jobs that are older than
the expiration date.
2022-07-13 17:26:04 +02:00
Sanne Raymaekers
03b57f002c jobqueue: Move jobqueue out of internal 2022-07-04 15:37:28 +02:00
Sanne Raymaekers
d9bd19404d osbuild-service-maintenance: Move maintenance queries out of jobqueue 2022-07-04 15:37:28 +02:00
Tomas Hozza
a4e6531565 worker: define job types as constants
Define supported job type names as constants and use them in all places,
instead of string literals.

There are multiple benefits of this approach. Using constants removed
the room for typos in the string literals. One can use autocompletion in
IDE for job types. Using constant makes it easier to find all references
where it is used and thus all places that are handling a specific job
type.
2022-06-10 14:48:18 +01:00
Sanne Raymaekers
ff408aa68f osbuild-service-maintenance: Vacuum tables
Call vacuum analyze after each chunk of updates, and dump vacuum stats
at the beginning and end of the db cleanup.

Nulling results can increase size on disk, but calling vacuum analyze
will free up space within the table (not on disk) and reuse the space
for new inserts and updates.
2022-06-08 21:12:46 +02:00
Sanne Raymaekers
92ae2f7c83 osbuild-service-maintenance: Delete/update results in chunks
The results of the manifest jobs can be very big, and operating on
30-40k rows at once can starve or crash a smaller rds instance.
2022-06-06 17:49:46 +02:00
Sanne Raymaekers
9b119fa4cf osbuild-service-maintenance: Delete results from select jobs
Instead of deleting records, delete the results from the manifest and
depsolve jobs. This redacts sensitive data which the manifest can
contain, and this conserves space.
2022-06-03 14:38:53 +02:00
Sanne Raymaekers
eeb2238b12 osbuild-service-maintenance: Split out db cleanup 2022-06-03 14:38:53 +02:00
Sanne Raymaekers
d1911f6484 osbuild-service-maintenance: Move type conversion to config 2022-05-14 16:21:21 +02:00
Sanne Raymaekers
8219dcdee8 osbuild-service-maintenance: Explicitly enable maintenance parts
Stage and production share the GCP account. To avoid trying to delete
each GCP image twice, the maintenance script needs the ability to
selectively disable certain parts based on the config.
2022-05-14 16:21:21 +02:00
Sanne Raymaekers
0f26672e45 cmd/osbuild-service-maintenance: Log aws error 2022-03-02 12:36:09 +01:00
Sanne Raymaekers
d492e8f702 cmd/osbuild-service-maintenance: GCP deletes by image name 2022-02-15 18:22:39 +01:00
Sanne Raymaekers
4956e48a0b service-maintenance: Skip db cleanup
Let's enable the cloud cleanup first, and then move on to the db.
2022-02-07 20:42:45 +01:00
Tomas Hozza
07a5745875 internal/cloud/gcp: use pkg.go.dev/cloud.google.com/go for Compute Engine
The internal GCP package used `pkg.go.dev/google.golang.org/api` [1] to
interact with Compute Engine API. Modify the package to use the new and
idiomatic `pkg.go.dev/cloud.google.com/go` [2] library for interacting
with the Compute Engine API. The new library have been already used to
interact with the Cloudbuild and Storage APIs. The new library was not
used for Compute Engine since the beginning, because at that time, it
didn't support Compute Engine.

Update go.mod and vendored packages.

[1] https://github.com/googleapis/google-api-go-client
[2] https://github.com/googleapis/google-cloud-go

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-02-03 15:35:28 +01:00
sanne
4797ac281a osbuild-service-maintenance: Rework GCP credentials mapping
Because of the way the gcp secrets are stored for the workers, and how
the mapping from vault to openshift works (unable to map a multiple key
secret into a single json file), there's a bit of juggling required to
get the gcp credentials in the right format.
2022-01-11 12:57:02 +01:00
sanne
c43ad2b22a osbuild-service-maintenance: Clean up expired images 2021-12-03 00:14:09 +00:00