1
0
mirror of https://github.com/quay/quay.git synced 2026-01-27 18:42:52 +03:00
Commit Graph

81 Commits

Author SHA1 Message Date
Marcus Kok
de8c48fa28 marketplace: fixing allowed repo count (PROJQUAY-5513) (#1891)
* Aggregate stripe plans and subscriptions.

* Validate end date for subscriptions when fetching from marketplace.

* Check subscription returned from stripe api is non-null value when
finding stripe plan for sku.
2023-05-25 10:46:58 -04:00
Brandon Caton
6cf0a3531b quota: calculating registry size (PROJQUAY-5476) (#1879)
Allows superusers to trigger a calculation of the deduplicated registry size. A superuser can go to the organization panel of the superuser page and select Calculate to queue a calculation of the registry total. The total will only be calculated when requested. Includes warning to user of increase of database load when running calculation.
2023-05-24 17:10:40 -04:00
Brandon Caton
e6f2dc3354 quota: excluding robots from quota total (PROJQUAY-5469) (#1871)
Adding quotatotalworker to config services / excluding robots from quota total
2023-05-10 14:54:57 -04:00
Marcus Kok
0a1c7fb22e marketplace: add reconciler (PROJQUAY-5320) (#1817)
marketplace: add reconciler (PROJQUAY-5320)
* check RH marketplace after stripe for private repo creation / changing visibility
* add reconciliation worker that creates RH subscriptions in marketplace for pre-existing stripe customers
2023-05-08 09:48:17 -04:00
Kenny Lee Sin Cheong
c0efc75207 storagereplication: add retry logic without exhausting queue retries (PROJQUAY-4793) (#1832)
Allow the replication worker to retry immediately without having to
wait and exhaust the queueitem's retries. This addresses transient
unreliable storage service issues.
2023-05-04 16:43:40 -04:00
Brandon Caton
a2c379d47c quota: Include blob deduplication in totals (PROJQUAY-3942) (#1751)
Allows for only unique blobs are counted at the namespace and repository level. Calculation includes manifest list sizes.
Add's the following internal configurations that default to true:
QUOTA_INVALIDATE_TOTALS: Invalidates calculated totals when FEATURE_QUOTA_MANAGEMENT is set to false
RESET_CHILD_MANIFEST_EXPIRATION: Resets the expiry for child manifests on push of the manifest list for immediate GC eligibility
PERMANENTLY_DELETE_TAGS: Enables features related to the permanent deletion of tags outside the configured time machine window
2023-05-01 16:40:01 -04:00
Kenny Lee Sin Cheong
2e5f25726a storagereplication: sleep on unexpected exception for retry (PROJQUAY-4792) (#1792) 2023-03-27 12:06:10 -04:00
Oleg Bulatov
15ea8350db repomirror: Use skopeo list-tags to get repo tags (PROJQUAY-2179) (#1427)
* repomirror: Use skopeo list-tags to get repo tags

`skopeo inspect foo` returns infromation about the image `foo:latest`,
and repository tags. Quay needs only list of tags, so it should use
`skopeo list-tags` that doesn't fail if `foo:latest` doesn't exist.

* Update type hints

* On local-dev Quay does not provide valid TLS certificate
2022-10-12 09:45:04 -04:00
Brandon Caton
679380b99f mirror: Rollback failed tags (PROJQUAY-4322) (#1496)
Currently Quay creates tags for Docker V2 schema 1 manifests in manifest lists. This makes it appear a tag was mirrored successfully when it had actually failed. This change rolls back those failed tags when the sync fails.
2022-08-29 09:18:00 -04:00
Brandon Caton
30298699fc mirror: Default mirror rollback to false (PROJQUAY-4296) (#1490)
Adds the `REPO_MIRROR_ROLLBACK` option to specify whether the mirror will rollback the state of the repo on failure of any one of the tags. Defaults to false. Adds additional `PARTIAL_SYNC` error status which logs the tags that failed to sync to the console.
2022-08-23 14:27:22 -04:00
Brandon Caton
9eb4fb6aa4 Revert workqueue refactor (#1456)
Currently the prometheus and GC workers are not running correctly.
Reverting the following commits:
- 4e1a985e70
- dac183a1ef
- 68a0d9eaf0
- af1aacea08
- f334b80098
2022-07-22 13:11:39 -04:00
Kenny Lee Sin Cheong
26a334f5d8 mirroring: fix mirror claims for multiple processes (PROJQUAY-3982) (#1433)
Previous logic for claiming mirror ("locking") relied on the value
returned from updating the database row. Since this was always being
updated with a new expiration time, it would always succeed, even when
another process had already claimed the same mirror.
2022-07-11 11:15:04 -04:00
Oleg Bulatov
dac183a1ef Replace app with singletons.config and workqueues (#1399)
Where it is possible, instead of importing app, import only required
packages.
2022-06-20 12:07:13 +02:00
Oleg Bulatov
af1aacea08 Remove app from GunicornWorker (#1394)
Quay uses GunicornWorker to run background workers in the development
environment. It is not expected to serve any HTTP server.
2022-06-17 13:34:05 +02:00
Oleg Bulatov
f334b80098 Reduce memory usage by notificationworker (#1370) 2022-06-16 18:44:13 +02:00
Oleg Bulatov
5eaf0584db chore: Run mypy as CI job (#1363)
* Run mypy as CI job

* Fix peewee.pyi and configure pyright
2022-06-13 11:01:17 +02:00
Kenny Lee Sin Cheong
f3c3916bc7 secscan: add option to skip recent manifest batch lock (PROJQUAY-3501) (#1299)
Having only one worker index recent manifest doesn't keep up with the
rate new manifests being pushed, given the time it takes for an index
request to complete. Adding the option to bypass the global lock
allows for more workers, but also increase the chance of duplicate work.
2022-05-03 11:21:23 -04:00
Kenny Lee Sin Cheong
72c8d7a3c5 secscan: fix config reference (PROJQUAY-3501) (#1283) 2022-04-25 11:49:21 -04:00
Kenny Lee Sin Cheong
ed77147b21 secscan: split indexing of recent manifest into separate background operation (PROJQUAY-3501) (#1281)
Index recent manifests in a separate background process, allowing the
main process to correctly select random slabs from the entire table
set and marking them completed in the allocator (rbtree). This avoids
the worker having to start iterating from the beginning of the table
whenever it is restarted.
2022-04-25 11:21:45 -04:00
Kenny Lee Sin Cheong
a9e1b71a2c secscan: fix missing import (PROJQUAY-3501) (#1261) 2022-04-19 16:07:32 -04:00
Kenny Lee Sin Cheong
922892d1af secscan: configure global lock (PROJQUAY-3501) (#1255) 2022-04-19 15:06:52 -04:00
Kenny Lee Sin Cheong
d719dfadc5 secscan: optimize deduplicating manifests for indexing in securityworker (PROJQUAY-3501) (#1247)
Acquire lock on recent manifests batch to prevent multiple workers
from working on the same set.
2022-04-19 11:34:53 -04:00
Brandon Caton
d2e758dad5 mirror: Get all tags during rollback (PROJQUAY-3146) (#1244)
During a rollback the mirror worker checks for new tags that were created in the repository in the time that the mirror operation has been running. If it encounters older tags that have been updated it will attempt to create a new tag that will point to the previous manifest. Currently for large lists of tags this will fail since we only retrieve the 100 latest tags. The mirror worker will never reach the tags that have been updated and will never recreate them, leading to the behavior of deleting tags during a rollback.
2022-04-14 09:11:48 -04:00
Kenny Lee Sin Cheong
dd1eab5238 Revert "secscan: add a global lock on security worker runs (PROJQUAY-3501) (#1226)" (#1232)
This reverts commit 9d89b6fa47.
2022-04-06 11:27:06 -04:00
Kenny Lee Sin Cheong
9d89b6fa47 secscan: add a global lock on security worker runs (PROJQUAY-3501) (#1226)
Add a global lock on security worker iterations, based on the value of
the current pagination token. This is to avoid multilple worker
processes possibly doing work on the same set of manifests.
2022-04-05 13:26:06 -04:00
Brandon Caton
ef91c57c23 format: Updating black to resolve click dependency issue (PROJQUAY-3487) (#1209)
Currently the CI breaks due to a dependency of black, `click`, breaking with it's latest release with `ImportError: cannot import name '_unicodefun' from 'click'`. Since black does not pin it's version of click it pulls in the latest version containing the breaking change and fails the CI check. This updates black with the patch. [See the original issue here.](https://github.com/psf/black/issues/2964) The rest of the changes are format updates introduced with the latest version of black.
2022-03-29 15:34:57 -04:00
Brandon Caton
0d3ecb132e imagemirror: Add unsigned registries mirror option (PROJQUAY-3106) (#1085)
Currently when attempting to mirror a registry containing unsigned images the mirror will fail due to not finding the source signature. This is caused by the updated version of Skopeo blocking unsigned images by default. This allows users to specify the ability to pull unsigned images per-repository. The Skopeo version is also now pinned.
2022-02-04 13:10:19 -05:00
Brandon Caton
f35f3f137c blobuploadcleanupworker: Add BLOBUPLOAD_DELETION_DATE_THRESHOLD (PROJQUAY-2915) (#1022)
Added BLOBUPLOAD_DELETION_DATE_THRESHOLD option to configure TTL on orphaned blobs.
2021-12-07 11:00:53 -05:00
Brandon Caton
22282dae09 blobuploadcleanupworker: Add cleanup for orphaned blobs (PROJQUAY-2313) (#967)
Currently blobs leftover in the uploads directory during cancelled uploads do not get cleaned up since they are no longer tracked. This change cleans up the uploads storage directory directly.
2021-11-17 15:55:33 -05:00
Kenny Lee Sin Cheong
a839a78eb5 chore: allows Quay to run for account recoveries (PROJQUAY-970) (#793)
Adds ACCOUNT_RECOVERY_MODE to allow Quay to run with some core
features disabled. When this is set, the instance should only be used
in order by existing users who hasn't linked their account to an
external login service, after database authentication has been
disabled.
2021-07-07 12:45:24 -04:00
thomasmckay
95ec9478fc mirror: Do not store signatures on repo mirroring (PROJQUAY-2167) (#816)
Newer versions of skopeo attempt to store signatures locally. This change prevents copying signatures during repo mirroring.
2021-07-07 12:21:18 -04:00
Kenny Lee Sin Cheong
efa0692e5a gc: increment quay_gc_repos_purged for NamespaceGCWorker (PROJQUAY-1802) (#749)
Since NamespaceGCWorker does a superset of RepositoryGCWorker's
operations, make sure that quay_gc_repos_purged is incremented if
either workers deletes a repository.
2021-04-15 16:09:58 -04:00
Kenny Lee Sin Cheong
c12654bf46 lock: allows global lock to be used from main app (PROJQUAY-788) (#745)
GlobalLock had a dependency on app, which would cause a circular
dependency if imported from the main app. Workaround this by requiring
to pass the configuration to the GlobalLock instead (this is done by a
classmethod, due to the use of Redlock's factory). This means before
the use of GlobalLock, "configure" will need to be called once, per process.
2021-04-14 14:44:33 -04:00
Kenny Lee Sin Cheong
778afaf36b lock: reuse redis client when creating locks (PROJQUAY-1872) (#741)
By default, Redlock creates a new client per instance. Using the
provided factory allows Redlock to reuse a single connection per
instance and avoid running out of connections. e.g When a worker tries
to get a lock, it should not open new connections every time.

Increase sleep duration between queue polls on
WorkerSleepException. This will give more time before retrying after
failing to acquire a lock.
2021-04-14 11:39:56 -04:00
Kenny Lee Sin Cheong
90f9ef95af queueworker: prevent stop event on WorkerSleepException (PROJQUAY-1857) (#737)
Prevents the queueworker from setting the event to stop the poll_queue
job when a WorkerSleepException is raised. On WorkerSleepException,
the worker should instead skip this iteration (go to sleep). e.g when
the NamespaceGCWorker can't acquire a lock because it is already taken
by some other worker.

Reverts the gcworkers job timeout from 24h to 3h. In case of a
deadlock between processes (for example, redeploying the app will not
clear the existing Redis keys), 24h is too long waiting for the locks to
expires so that the workers can resume work.

Add missing Counter increment for on row deletion on the Manifest table.
2021-04-12 14:43:42 -04:00
Kenny Lee Sin Cheong
f774e4c6b6 gc: add metrics for deleted resources (#711)
Add counters for the number of resources deleted by the gc worker, the
repository gc worker and the namespace gc worker.
2021-04-09 14:32:37 -04:00
Kenny Lee Sin Cheong
3b94cda751 gc: fix GlobalLock ttl unit and increase gc workers lock timeout (#712)
Correctly converts the given ttl from seconds to milliseconds when
passed to Redis (redlock uses 'px', not 'ex'). Also increase the lock
timeout of gc workers to 1 day.

Some iteration, for repos with large numbers of tags (1000s), will
take more than 15 minutes to complete. This change will prevent multiple
workers GCing the same repo, and one possibly preempting
another. GlobalLock's ttl will make the lock available again when
expired, but will not actually stop execution of the current GC
iteration until the GlobalLock context is done. Having a 1 day timeout
should be enough.

NOTE: The correct solution would have GlobalLock should either renew
the lock until the caller is done, or signal that it is no longer
valid to the caller.
2021-04-06 14:05:11 -04:00
Kenny Lee Sin Cheong
8d9fa22c26 deps: Update boto2 to boto3 (#479)
Migrate from using boto2 to boto3. Changes include:
- Removes explicit bucket addressing style: Boto3 will initially try virtual-style addressing first then fallback to path-style addressing (https://github.com/boto/boto3/blob/develop/docs/source/guide/configuration.rst)
- GCS workarounds to use boto3:
  - Handles CORS config
  - Update signed url access key parameter name
  - Uses ListBucket V1 API
- On client-side chunks join, copy using non-multipart api: Use copy_from instead of copy when joining chunks client-side. This is because copy assumes multipart upload should be used which GCS and Rados are not compatible with (S3's version. They have their own parallel upload api)
- Update RDS healthcheck to use boto3
2021-03-18 15:08:02 -04:00
Kenny Lee Sin Cheong
63386d914d PROJQUAY-1562 repo mirror config schema (#673)
* Revert "Set default REPO_MIRROR_SERVER_HOSTNAME value to match SERVER_HOSTNAME (#667)"

This reverts commit 55e11c2bd6.

`REPO_MIRROR_SERVER_HOSTNAME` should match `SERVER_HOSTNAME` if its
value is None (default). i.e. if it's not set explicitly.

Instead changing the config's jsonschema to allow
`REPO_MIRROR_SERVER_HOSTNAME` to be None.

* Allow null value for REPO_MIRROR_SERVER_HOSTNAME
2021-02-10 13:20:44 -05:00
Syed Mushtaq Ahmed
5753fa4a23 PROJQUAY-586 - Remove Defcon1 severity from Quay (#664)
Co-authored-by: Syed A <syed@apache.org>
2021-01-26 10:41:32 -05:00
Kenny Lee Sin Cheong
55e11c2bd6 Set default REPO_MIRROR_SERVER_HOSTNAME value to match SERVER_HOSTNAME (#667)
Set REPO_MIRROR_SERVER_HOSTNAME to a value instead of None in order to
match the defined json schema for the config.
2021-01-26 10:01:16 -05:00
Louis DeLosSantos
113ccebbbf local-dev: implement local development environment (#610)
* local-dev: implement local development environment

this commit copies the files in /init into /local-dev, edits those files
to support hot-reload features for local development, and introduces
docker-compose/makefile targets in order to support local dev.

Signed-off-by: ldelossa <ldelossa@redhat.com>

* local-dev: hop quay workers to gunicorn

this commit adds a uwsgi worker application delegate and a factory
function allowing each worker to be ran by gunicorn.

each worker now supports hot-reload and will reload itself when it's
code is updated.

this changes only affects the local dev env.

Signed-off-by: ldelossa <ldelossa@redhat.com>

* local-dev: add docs

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-12-15 12:37:21 -05:00
Kurtis Mullins
bd7252c536 [PROJQUAY-1021] task: Update "Black" to version 20.8b1 2020-11-30 18:48:19 -05:00
Alec Merdler
1e25370b17 skip security scanning notification worker test on MySQL (#575) 2020-10-13 12:27:14 -07:00
Alec Merdler
a4390c3785 implement notification system for security scanner v4 (#557) 2020-10-01 12:27:45 -07:00
thomasmckay
34d47575b0 PROJQUAY-1055 - correct reindexing due to hash compare (#550) 2020-09-10 13:25:52 -04:00
thomasmckay
e81b9ee539 PROJQUAY-381 - failed mirror tg cleanup (#516) 2020-08-19 16:29:54 -04:00
Kenny Lee Sin Cheong
ac70f6b5eb Add an extra "metadata" field to Elasticsearch logentries (#504)
* Add an extra "metadata" field to Elasticsearch logentries

The current "metadata_json" field is stored as a text field, and
cannot be searched easily. "metadata" will store the given dict as a
dynamically mapped Object type.

* Remove duplicate "metadata_json" field in Elasticsearch

Instead, json dumps the "metadata" field for the Log datatype.
2020-08-06 12:03:30 -04:00
Joseph Schorr
0e628b1569 Deprecate Image rows and move to in-memory synthesized legacy images [Python 3] (#442)
* Change verbs to use a DerivedStorageForManifest table instead of DerivedStorageForImage

This allows us to deprecate the DerivedStorageForImage table.

Fixes https://issues.redhat.com/browse/PROJQUAY-519

* Change uploaded blob tracking to use its own table and deprecate
RepositoryTag

* Start recording the compressed layers size and config media type on the
manifest row in the database

NOTE: This change includes a database migration which will *lock* the
manifest table

* Change tag API to return the layers size from the manifest

* Remove unused code

* Add new config_media_type field to OCI types

* Fix secscan V2 test for us no longer writing temp images

* Remove unused uploading field

* Switch registry model to use synthetic legacy images

Legacy images are now (with exception of the V2 security model) read from the *manifest* and sythensized in memory. The legacy image IDs are generated realtime based on the hashids library. This change also further deprecates a bunch of our Image APIs, reducing them to only returning the image IDs, and emptying out the remaining metadata (to avoid the requirement of us loading the information for the manifest from storage).

This has been tested with our full clients test suite with success.

* Add a backfill worker for manifest layers compressed sizes

* Change image tracks into manifest tracks now that we no longer have
manifest-less tags

* Add back in the missing method

* Add missing joins to reduce extra queries

* Remove unnecessary join when looking up legacy images

* Remove extra hidden filter on tag queries

* Further DB improvements

* Delete all Verbs, as they were deprecated

* Add back missing parameter in manifest data type

* Fix join to return None for the robot if not defined on mirror config

* switch to using secscan_v4_model for all indexing and remove most of secscan_v2_model code

* Add a missing join

* Remove files accidentally re-added due to rebase

* Add back hashids lib

* Rebase fixes

* Fix broken test

* Remove unused GPG signer now that ACI conversion is removed

* Remove duplicated repomirrorworker

* Remove unused notification code for secscan. We'll re-add it once Clair
V4 security notifications are ready to go

* Fix formatting

* Stop writing Image rows when creating manifests

* Stop writing empty layer blobs for manifests

As these blobs are shared, we don't need to write ManifestBlob rows
for them

* Remove further unused code

* Add doc comment to _build_blob_map

* Add unit test for synthetic V1 IDs

* Remove unused import

* Add an invalid value test to synthetic ID decode tests

* Add manifest backfill worker back in

Seems to have been removed at some point

* Add a test for cached active tags

* Rename test_shared to not conflict with another same-named test file

Pytest doesn't like having two test modules with the same name

* Have manifestbackfillworker also copy over the config_media_type if present

Co-authored-by: alecmerdler <alecmerdler@gmail.com>
2020-07-28 13:03:10 -04:00
thomasmckay
8d57e769fa PROJQUAY-907 - repo mirror initial date (#495) 2020-07-28 12:02:17 -04:00