1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Commit Graph

465 Commits

Author SHA1 Message Date
Syed Mushtaq Ahmed
df4ad94527 modelcache: Make ModelCache TTL configurable (PROJQUAY-1878) (#765)
Adds a configuration option to modify the cache expiry timeout
for ModelCache objects

Co-authored-by: Syed <syed@apache.org>
2021-04-28 10:46:32 -04:00
Syed Mushtaq Ahmed
94ed47164b migration: Add composite index in manifestblob (PROJQUAY-1922) (#769)
Adds composite index manifestblob_repository_id_blob_id.  From our
testing on the quay.io production DB, This increased the number of rows
filtered for the manifestblob & imagestorage join slow query from 1.8%
to 100%

Co-authored-by: syed <syed@apache.org>
2021-04-26 10:49:20 -04:00
Kenny Lee Sin Cheong
4ad5a458c2 chore: remove uploading filtering from imagestorage queries (PROJQUAY-1914) (#764)
The "uploading" column is an artifact from depending on writing to the
Image table (see BlobUpload table instead). As of 3.4, Quay no longer
writes to that table, and is only needed until quayio moves away from
Clair v2, after which work to remove "glue" code and fully deprecate
the Image table (amongst other tables) can start.

This is done as a separate commit from the actual migration so that it
can be cherrypicked.
2021-04-21 13:53:28 -04:00
Alec Merdler
1180ea99fa cache: remove GlobalLock from redis model cache (PROJQUAY-1902) (#755)
Remove GlobalLock from Redis model cache implementation in
favor of 'nx=True' when setting the key.

Signed-off-by: Alec Merdler <alecmerdler@gmail.com>
2021-04-19 19:06:18 -07: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
Alec Merdler
780685c490 cache: add Redis model cache implementation (PROJQUAY-788) (#444)
Adds implementation of DataModelCache interface backed by Redis.
All containers in a Quay cluster deployment will share a single
model cache, rather than each container using its own cache.

Signed-off-by: Alec Merdler <alecmerdler@gmail.com>
2021-04-15 10:31:42 -07: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
79faf5f367 tags: apply tag expiry to created tags pointing to existing manifest (#690)
Apply a manifest's "quay.expires-after" label expiry value to new tags pointing
to that existing manifest. Before, that label would be only applied at when the
manifest was created, and new tags targeting that manifest would not
have the manifest's corresponding expiry value set.
2021-03-23 12:46:34 -04:00
Arunprasad Rajkumar
d575f39136 PROJQUAY-963: Add package and vulnerability related metadata into secscan response (#515)
* clairv4: Add package and vulnerability metadata into secscan response

* Update field name

* Add missing mapping

* Fix code format

* Piggyback Metadata field to expose updater, repository and distro details

* Fix format

* Use distro and repo details from vulnerability

* Trigger PR check

* fix: Add missing model mapping

* Add response with Metadata field

* Modify response according to new Metadata format
2021-03-19 15:43:50 -04:00
Kenny Lee Sin Cheong
7d9a49da10 Replace jwkest with authlib (#685)
* Replace jwkest with authlib and PyCrypto with cryptography

Remove pycryptodome dependencies.
Remove post-fork random seed init - python-cryptography's pseudo RNG should be fork safe:
- https://cryptography.io/en/latest/security.html?highlight=fork
- https://cryptography.io/en/latest/hazmat/backends/openssl.html?highlight=fork#os-random-engine

* deps: Pin cryptography to 3.3.1

Latest available version available on RHEL.
As of 3.4, cryptography builds on rust, which is not readily available
on RHEL.
2021-03-15 15:25:23 -04:00
Kenny Lee Sin Cheong
4785f2d119 Deprecate use of pycryptodome for AES (#679)
Since we're already using the cryptography package elsewhere, there is
no need to have 2 different crypto packages as dependencies.
2021-03-08 13:33:44 -05:00
Kenny Lee Sin Cheong
35492851de Add metrics to app instance's peewee connection pool (#612) 2020-12-09 10:58:01 -05:00
Kurtis Mullins
bd7252c536 [PROJQUAY-1021] task: Update "Black" to version 20.8b1 2020-11-30 18:48:19 -05:00
Kurtis Mullins
4d0581e2d9 [PROJQUAY-879] fix: Schema migrations with MySQL and SSL (#596) 2020-11-19 14:04:16 -05:00
thomasmckay
f9126ea375 PROJQUAY-1258 - correct ldap python3 call (#600) 2020-11-18 15:20:42 -05:00
thomasmckay
e1ecbbd467 PROJQUAY-1292 - do not scan manifest lists (#599) 2020-11-18 12:32:14 -05:00
thomasmckay
bf83ddee4b PROJQUAY-1273 - ldap bytes-like strings (#598) 2020-11-12 14:07:37 -05:00
Kurtis Mullins
9ccb3ea9b2 [PROJQUAY-1190] fix: Use Python3 strings for user-facing tokens (#589) 2020-10-27 12:28:52 -04:00
thomasmckay
bde9d57bf4 PROJQUAY-1079 - do not rescan unsupported manifests (#561) 2020-10-08 14:00:21 -04:00
Kurtis Mullins
52b86ac9fd [PROJQUAY-822] security: Hide sensitive LDAP log data (#562) 2020-10-06 12:44:07 -04:00
Louis DeLosSantos
b389f885cf sec: implement jwt signing to ClairV4 (#554)
this commit adds jwt signing directly in Quay when contacting
ClairV4

Signed-off-by: ldelossa <louis@localhost.localdomain>

Co-authored-by: ldelossa <louis@localhost.localdomain>
2020-10-02 11:00:56 -07:00
Alec Merdler
a4390c3785 implement notification system for security scanner v4 (#557) 2020-10-01 12:27:45 -07:00
Kenny Lee Sin Cheong
5e03c4c1b6 Use days instead of weeks to represent a month worth of time (#549)
* Use days instead of weeks to represent a month worth of time

* Returns 400 on bad date ranges
2020-09-09 14:31:44 -04:00
Kenny Lee Sin Cheong
8583206220 Fix the RepoMirrorConfig model to match the latest migrations (#530)
RepoMirrorConfig in the current database migration version has a
non-null constraint on the internal_robot field, but the model in
database.py does not.

Updates the  model to match the current database revision, and handles
delete api calls when there are mirrors still using the robot.

Also set a default test DATABASE_SECRET_KEY when generating the test.db
2020-08-24 10:21:35 -04:00
Kenny Lee Sin Cheong
0c65f88a0e json loads fix: given arg should be a str (#527) 2020-08-19 17:47:19 -04:00
Kenny Lee Sin Cheong
27c6e2b99b Reduce log noise from fallbacks in executor (#526) 2020-08-19 16:24:10 -04:00
Joseph Schorr
ef5cf22993 Fix transaction error in postgres on repo create (#522)
We now break out of the transaction if the repository already exists,
so that Postgres doesn't raise an error when we try to retrieve the
existing repository

Fixes https://issues.redhat.com/browse/PROJQUAY-973
2020-08-17 16:24:42 -04:00
Arunprasad Rajkumar
4672db1df7 fix: Missing storage argument and type error when calling file.write (#514)
* fix: Missing storage argument and type error when calling file.write

* Use binary mode in file ops
2020-08-12 12:04:41 -04:00
Kenny Lee Sin Cheong
a16124e6bf Handles out of range pagination token datetime (#517)
Check that "after_datetime" token used for pagination is smaller than the given starting datetime when doing a lookup
2020-08-11 14:49:32 -04:00
Joseph Schorr
005b1e44f4 Mark invalid manifests in Secscan V4 (#512)
If we get an invalid manifest when indexing, we now mark the manifest
as invalid for security indexing

Fixes https://issues.redhat.com/browse/PROJQUAY-949
2020-08-10 13:17:44 -04:00
Joseph Schorr
f626d4eceb Ensure shared blob layers are present on lookup (#511)
Due to the requirement for the shared empty layer for manifest schema 1,
we need to make sure it is written to the ImageStorage table, even if
the only schemas pushed are version 2

Fixes https://issues.redhat.com/browse/PROJQUAY-948
2020-08-10 12:20:12 -04:00
Kenny Lee Sin Cheong
71a2ba052c Fix ldap user login (#509)
* Fix typo

* Make sure python-ldap uses str instead of bytes
2020-08-07 16:08:36 -04:00
Joseph Schorr
bf656b26ef Further fixes for duplicate manifest pushing (#507)
Catch IntegrityError from the other inserts as well, to ensure we handle
duplicate rows

Further addresses https://issues.redhat.com/browse/PROJQUAY-915
2020-08-07 11:41:27 -04:00
Joseph Schorr
a431c61d4d Fix lookup of tag history sizes (#506)
Add missing @property decorator on legacy image size handler to fix
the raised exception
2020-08-06 12:50:48 -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
4fa1459583 Fix lookup of manifests if we detect a duplicate during creation (#498)
This changes the lookup to occur outside of the transaction as otherwise
we won't find the manifest that was inserted during the transaction's
view

Fixes https://issues.redhat.com/browse/PROJQUAY-915
2020-07-30 16:47:18 -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
Joseph Schorr
a7210edc6a Turn off ignore_exc in memcache cache to fix an NPE (#472)
The PooledCache implementation incorrectly returns `None` instead of
the default if an exception occurs, but `None` is a valid cached value,
so we instead catch the exceptions ourselves now and skip the caching
code if we encounter an exception
2020-07-08 14:41:36 -04:00
Joseph Schorr
a4adce140e Have the RAC worker fast-check whether it needs to do work (#463)
The RAC worker will now check the count of entries for the day, versus
the number of repos. If all entries are found, the worker will go to
sleep.
2020-06-30 12:32:56 -04:00
Joseph Schorr
0635ea5d9b Fix serving of local user files (#461)
Fixes https://issues.redhat.com/browse/PROJQUAY-808
2020-06-26 17:59:26 -04:00
Joseph Schorr
1b083d7d51 Add caching support for app registry show package call (#460) 2020-06-26 12:36:59 -04:00
Joseph Schorr
9a9608de3f Adds a pre-disconnect option to memcache (#459)
Add a config option for configuring whether to pre-disconnect from the
DB before making a memcache call
2020-06-25 16:08:36 -04:00
Joseph Schorr
8c39691538 Ensure we are passing an int for the memcache pool size (#458) 2020-06-25 13:10:17 -04:00
Joseph Schorr
a25ed4cb9e Change memcache implementation to use a connection pool (#457) 2020-06-25 11:46:53 -04:00
Joseph Schorr
3efa209697 Fix the lookup query for RAC (#454)
Also adds a new test for this query
2020-06-23 17:34:34 -04:00
Joseph Schorr
ac6b1378cf Ensure that all robot lookups are ASCII only (#453)
We only allow ASCII for robot names anyway, so just catch it early

Fixes https://issues.redhat.com/browse/PROJQUAY-807
2020-06-23 13:07:37 -04:00
Joseph Schorr
cbb854fc63 Fix the RepositoryActionCount worker to properly select rows (#452) 2020-06-23 10:45:12 -04:00
Kurtis Mullins
f1237bdb29 [PROJQUAY-753] Reduce logging noise (#445) 2020-06-18 13:54:20 -04:00
zhouhaibing089
4c429687fe keystonev2: populate user.name into UserInformation (#440)
The behavior between keystonev2 and keystonev3 is different today.
In keystonev3 implementation, the username comes from [user.name][1],
but keystonev2 just uses the incoming `username_or_email`.

Also, by reading `user.name`, we can use keystone APIKeys to do
authentication which is necessary due to potential 2FA requirements.

[1]: f4179e5e71/data/users/keystone.py (L316)
2020-06-17 14:13:00 -04:00