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

197 Commits

Author SHA1 Message Date
Ryan Wallace
a06cc6fa43 chore: update all black versions to 24.4.2 and run make black (#4754)
* chore(pre-commit): match black version with requirements-dev

* run `make black` against repo

* ci: switch to black 24.4.2

* fix: py312

* fix: flake8 errors

* fix: flake8 conflicts

* chore: add git blame ignore revs file
2025-12-19 11:29:53 -06:00
jbpratt
52a5a85f7f fix(data): clear pull statistics when tags are deleted (PROJQUAY-9887) (#4667)
When a tag is deleted and re-pushed, pull statistics now start fresh
at 0 instead of persisting from the deleted tag.

Changes:
- Clear TagPullStatistics in _delete_tag()
- Clear TagPullStatistics in remove_tag_from_timemachine()
- Add tests for tag deletion clearing pull statistics
- Add test for re-push scenario starting with fresh stats

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Brady Pratt <bpratt@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-03 10:22:39 -06:00
Harish Govindarajulu
a97ca5c231 fix(oauth): prevent redirect URI validation bypass (PROJQUAY-9849) (#4635)
* fix(oauth): prevent redirect URI validation bypass (PROJQUAY-9849)

Co-authored-by: Claude <noreply@anthropic.com>

* test(oauth): add comprehensive coverage for redirect URI validation (PROJQUAY-9849)

Co-authored-by: Claude <noreply@anthropic.com>

* fix(oauth): add percent-encoding protection and improve test coverage (PROJQUAY-9849)

Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-25 13:26:38 -05:00
Shubhra Deshpande
3d2248d723 pullstats: updated bulk upsert function to track correct pull count and timestamp in case of race condition (PROJQUAY-9684) (#4463)
pullstats: updated bulk upsert function to track correct pull count and timestamp in case of race condition

Co-authored-by: shudeshp <shudeshp@redhat.com>
2025-11-14 09:48:23 -05:00
Shubhra Deshpande
aad7ffc89f feat: Added garbage collection hook for TagPullStatistics and ManifestPullStatistics tables (PROJQUAY-7176) (#4405)
feat: Added garbage collection hook for TagPullStatistics and ManifestPullStatistics tables

Co-authored-by: shudeshp <shudeshp@redhat.com>
2025-10-28 14:35:28 -04:00
Shubhra Deshpande
240d6441ba feat: Add image pull statistics API endpoints and UI integration (PROJQUAY-7176) (#4382)
feat: Add image pull statistics API endpoints and UI integration

- Add new API endpoints for tag and manifest pull statistics
- Integrate pull metrics into web UI with new table columns
- Add FEATURE_IMAGE_PULL_STATS feature flag and PULL_METRICS_REDIS config
- Add pullstatsredisflushworker to supervisord configuration
- Add comprehensive test coverage for pull statistics functionality

Co-authored-by: shudeshp <shudeshp@redhat.com>
2025-10-27 15:19:52 -04:00
Dave O'Connor
d83e2c8647 feat(api v1): global readonly superuser support and app token visibility (PROJQUAY-8279) (#4276)
Implements global read-only superuser permissions for v1 endpoints, adjusts superuser write checks, and updates app token listing and detail endpoints; includes comprehensive tests.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-21 15:00:59 -04:00
Shubhra Deshpande
ba57ee67e6 db: Added TagPullStatistics and ManifestPullStatistics tables with migrations (PROJQUAY-8414) (#4318)
Added TagPullStatistics and ManifestPullStatistics tables with migrations



---------

Co-authored-by: shudeshp <shudeshp@redhat.com>
2025-10-07 10:59:37 -04:00
Brandon Caton
c843bf2104 quota: only create notification if one doesn't already exist (PROJQUAY-8857) (#4092)
Add check if a notification exists before creating another. Previously many notifications were being created causing tables to inflate.
2025-09-02 09:12:32 -04:00
Ivan Bazulic
9be679eb58 mirror: Add job timeout to mirror configurations (PROJQUAY-7249) (#3723)
* mirror: Add job timeout to mirror configurations (PROJQUAY-7249)
Previous global job timeout of 5 minutes was inadequate for big images. The timeout should now be configurable in much the same way as sync is. Minimum job length is 300 seconds/5 minutes.

The PR is still work in progress.

* Fix init db, remove reference to user data in logs

* Fix tests, change repo mirror configuration

* Fix tests, make mirroring cancellable through UI

* Add cancel mirror test, change HTML document to reflect mirror timeout

* Flake8 doesn't like when '==' is used with 'None'

* Fix mirror registry tests

* Add new cypress data to fix cypress tests

* Added ability to define upload chunk size to RADOS driver, small changes to repo mirror HTML page

* Fix database migration to follow HEAD

* Upload new database data for Cypress tests

* Make skopeo_timeout_interval mandatory on API calls

---------

Co-authored-by: Ivan Bazulic <ibazulic@redhat.com>
2025-06-12 19:09:51 +02:00
Michaela Lang
be82aefb44 proxycache(permissions): CVE-2025-4374 (PROJQUAY-8892) (#3941)
fixing CVE-2025-4374 by extending the create_repository method to understand if we are requesting a proxy_cache repository
added unittests for create_repository when proxy_cache.
2025-05-22 09:09:02 -04:00
Syed Ahmed
d674ab54cb db: use iterator chain for _get_user_repo_permissions (PROJQUAY-8839) (#3822)
* db: use iterator chain for _get_user_repo_permissions (PROJQUAY-8839)

Unwrapping can cause increase in CPU. Use iterator chain to let
the caller unwrap
2025-04-29 11:44:31 -04:00
Kenny Lee Sin Cheong
454f09ed89 logging: fix unreferenced variable from logging (PROJQUAY-8136) (#3819) 2025-04-25 18:44:46 +00:00
Syed Ahmed
36a552058a db: optimize _get_user_repo_permissions to send to read replica (PROJQUAY-8839) (#3818)
* db: optimize _get_user_repo_permissions to send to read replica (PROJQUAY-8839)

it uses a union query which doesn't invoke the replica selection
logic. Make this into 2 seperate queries

* fix unit tests
2025-04-25 09:36:43 -04:00
Kenny Lee Sin Cheong
5c51ab85e1 gc: garbage collect manifests not targetted by any tags when deleting repository (PROJQUAY-8136) (#3797)
* gc: garbage collect manifests not targetted by any tags when deleting repository (PROJQUAY-8136)

* test untagged manifest removal
2025-04-22 10:42:48 -04:00
Sunandadadi
3bf6e1b16b db: moving robot search and find repo to garbage collect queries to read replica (PROJQUAY-8792) (#3795)
* db: moving robot search and find repository to garbage collect queries to read replica (PROJQUAY-8792)

* removing lookup_robot from read_replica
2025-04-17 15:13:51 +00:00
Sunandadadi
fda188e23f db: revert get_namespace_user from read replica (PROJQUAY-8792) (#3796) 2025-04-17 15:06:37 +00:00
Sunandadadi
43bc1db13e db: moving get sorted matching repos and find repos to garbage collect to read replica (PROJQUAY-8792) (#3782) 2025-04-16 13:13:06 -04:00
Sunandadadi
275b6e8540 db: moving robot search query to read replica (PROJQUAY-8792) (#3781) 2025-04-15 09:51:12 -04:00
Sunandadadi
433124d95f db: moving get user from username query to read replica (PROJQUAY-8792) (#3773) 2025-04-14 11:58:06 -04:00
Sunandadadi
58357ca84f db: moving get user repo permissions query to read replica (PROJQUAY-8792) (#3772) 2025-04-10 15:16:04 -04:00
Kenny Lee Sin Cheong
b674c7cfc4 gc: Allow setting a deleted repo name's suffix (PROJQUAY-8408) (#3563)
Allows adding a suffix to uuid repo names to collect metrics
2025-01-13 14:21:47 -05:00
Marcus Kok
8d835a9a94 worker: include orgs in reconciler runs (PROJQUAY-8431) (#3560)
Adds an include_orgs param to the active users query used by the reconciler and sets it to true for reconciler runs

Reconciler is not including orgs as a candidate for creating corresponding RH entitlements. As a result it misses users with stripe billing that are considered orgs.
2025-01-10 13:05:22 -05:00
Sunandadadi
70a0edef5b teamsync: peewee integrity error check on teamsync (PROJQUAY-7747) (#3550)
This issue should fix PROJQUAY-7747 and PROJQUAY-8130. Adding IntegrityError to the try except block to skip adding existing user to team.
2025-01-09 15:40:01 -05:00
Marcus Kok
f69716b867 marketplace: splittable sku for MW02702 (PROJQUAY-8151) (#3389)
* marketplace: splittable sku for MW02702 (PROJQUAY-8151)
* Alembic migration to drop unique constraint on the orgrhsubscriptions
  table
* Can split sub quantities of MW02702 across multiple orgs
* Can specify quantity for the MW02702 SKU across orgs on react UI
* Update angular UI to allow user to specify quantities for MW02702
2025-01-09 09:37:09 -05:00
Kenny Lee Sin Cheong
6c10313eea gc: allow setting the repositorygc queueitems' availability (PROJQUAY-8408) (#3551) 2025-01-07 15:05:17 -05:00
Syed Ahmed
f7f4fbcbde oci: fix nested index parsing (PROJQUAY-8272) (#3427)
image index can refer to another index when parsing. We currently
assume only a manifest can be referenced from an index. This fixes
the parse logic
2024-11-26 19:24:16 +00:00
Sunandadadi
296b5f35c3 notifications: fetch autoprune tags with multiple policies for image expiry notification (PROJQUAY-8117) (#3340)
* notifications: fetch autoprune tags with multiple policies for image expiry notification(PROJQUAY-8117)

* don't fetch notifications if tags expiry is greater than notification days + add tests
2024-10-18 16:17:07 -04:00
Sunandadadi
409d464cca autoprune: order policies by method before execution (PROJQUAY-8104) (#3334) 2024-10-16 14:35:16 -04:00
Brandon Caton
92d1a31ace api: allowing superuser to read catalog endpoint (PROJQUAY-8023) (#3310)
Allows for the full access and global readonly superuser to read all repositories from the /v2/_catalog endpoint.
2024-10-16 09:44:01 -04:00
Sunandadadi
d39a6f06c3 autoprune: fix tags returned by autoprune worker (PROJQUAY-8070) (#3314)
* autoprune: fix tags returned by autoprune worker (PROJQUAY-8070)

* fixing tests

* moving limit and offset to db_regex_search

* adding test cases
2024-10-11 12:10:59 -04:00
Sunandadadi
d28d2b00f8 gc: fix fk constraint violation tag delete (PROJQUAY-8006) (#3271)
* gc: fix fk constraint violation tag delete (PROJQUAY-8006)

* revert fix and call delete tag notifications

* add test
2024-10-02 09:07:24 -04:00
Syed Ahmed
e9161cb3ae robots: Add robot federation for keyless auth (PROJQUAY-7803) (#3207)
robots: Add robot federation for keyless auth (PROJQUAY-7652)

adds the ability to configure federated auth for robots by
using external OIDC providers. Each robot can be configured
to have multiple external OIDC providers as the source for
authentication.
2024-09-24 11:32:38 -04:00
Sunandadadi
f327551ccc autoprune: support multiple organization and repository policies (PROJQUAY-7695) (#3209)
* autoprune: support multiple organization policies (PROJQUAY-7695)

* ui to support multiple org policies

* backend to support multiple repository autoprune policies

* ui: multiple repository policies

* fixing tests

* adding tests
2024-09-20 09:18:09 -04:00
Ivan Bazulic
84249a153b health: Add statement timeout to health check (PROJQUAY-7950) (#3228)
* health: Add statement timeout to health check (PROJQUAY-7950)
Currently, our query to check team roles (part of the db health check) does not time out after a certain period but runs indefinitely. This causes worker timeouts after 30 seconds, which ends up in worker being killed by the master gunicorn process.
We limit the maximum execution time of the query to 5000 ms so that proper exception is raised if that timeout is reached.

PostgreSQL logs:

~~~
2024-09-16 09:38:56.431 EDT [115775] testuser@quayclone2 LOG:  duration: 0.011 ms  statement: BEGIN
2024-09-16 09:38:56.431 EDT [115775] testuser@quayclone2 LOG:  duration: 0.034 ms  statement: SET statement_timeout=5000
2024-09-16 09:38:56.431 EDT [115775] testuser@quayclone2 LOG:  duration: 0.010 ms  statement: COMMIT
2024-09-16 09:38:56.432 EDT [115775] testuser@quayclone2 LOG:  duration: 0.004 ms  statement: BEGIN
2024-09-16 09:38:56.432 EDT [115775] testuser@quayclone2 LOG:  duration: 0.300 ms  statement: SELECT "t1"."id", "t1"."name" FROM "teamrole" AS "t1" LIMIT 1
2024-09-16 09:38:56.433 EDT [115775] testuser@quayclone2 LOG:  duration: 0.010 ms  statement: COMMIT
2024-09-16 09:38:56.433 EDT [115775] testuser@quayclone2 LOG:  duration: 0.005 ms  statement: BEGIN
2024-09-16 09:38:56.433 EDT [115775] testuser@quayclone2 LOG:  duration: 0.012 ms  statement: SET statement_timeout=0
2024-09-16 09:38:56.433 EDT [115775] testuser@quayclone2 LOG:  duration: 0.006 ms  statement: COMMIT
~~~

Quay logs:

~~~
gunicorn-web stdout | 2024-09-16 13:38:56,412 [287] [DEBUG] [peewee.pool] Created new connection 127610088683136.
gunicorn-web stdout | 2024-09-16 13:38:56,417 [287] [DEBUG] [data.model.health] Validating database connection.
gunicorn-web stdout | 2024-09-16 13:38:56,418 [287] [INFO] [data.database] Connection pooling disabled for postgresql
gunicorn-web stdout | 2024-09-16 13:38:56,431 [287] [DEBUG] [peewee] ('SET statement_timeout=%s', (5000,))
gunicorn-web stdout | 2024-09-16 13:38:56,431 [287] [DEBUG] [data.model.health] Checking for existence of team roles, timeout 5000 ms.
gunicorn-web stdout | 2024-09-16 13:38:56,432 [287] [DEBUG] [peewee] ('SELECT "t1"."id", "t1"."name" FROM "teamrole" AS "t1" LIMIT %s', [1])
gunicorn-web stdout | 2024-09-16 13:38:56,433 [287] [DEBUG] [peewee] ('SET statement_timeout=0', None)
gunicorn-web stdout | 2024-09-16 13:38:56,434 [287] [DEBUG] [app] Ending request: urn:request:d039265b-414e-4d03-b29f-3e481286bf0f (/health/instance)...
~~~

* Fix generator function
2024-09-17 09:05:11 -04:00
Brandon Caton
6da65c5003 api: adding tag_pattern to autoprune API (PROJQUAY-7668) (#3188)
Allows users to specify a regex tag pattern when creating namespace/repository autoprune policies via the new UI. Users will have the option to prune tags that only match the tag pattern or exclude tags that match the tag pattern.
2024-09-13 09:48:51 -04:00
Syed Ahmed
bb054bfefa storage: prevent registry worker crash for large layers (PROJQUAY-7603) (#3123)
during manifest push, we generate a map of blobs which
are part of the manifest layers. This is done using a
UNION query which can overload the worker if the
number of layers is too large. Instead, run each
query individually to prevent the crash
2024-08-09 11:32:33 -04:00
nmaloof
4899ebd6c7 api: allow refining search with an organization (PROJQUAY-7244) (#2901)
This allows a more refined search than just the repo name. When two
organizations contain the same name repo, e.g: org1/python and
org2/python, you can now search via org1/python to get the specific
result instead of both.
2024-08-09 11:19:55 -04:00
Ivan Bazulic
62e42f8f54 storage: Disable pushes on registry (PROJQUAY-6870) (#2755)
* storage: Disable pushes on registry (PROJQUAY-6870)

The current read-only option for Quay is not sometimes feasible, since it requires an insert of the service key and other manual config changes. For instance, if you want to just recalculate quota on the registry, but would like to allow all registry operations (including UI) without the possibility of pushes until recalculation is done, setting the whole registry `read-only` cannot be done since it makes the database read only as well.

This PR introduces a new flag called `DISABLE_PUSHES` which allows all registry operations to continue (changing tags, repo editing, robot account creation/deletion, user creation etc.) but will disable pushes of new images to the registry (i.e. backend storage will not change). If a registry already contains the image and a new tag is simply being added, that operation should succeed.

The following message would appear in the logs:

~~~
gunicorn-registry stdout | 2024-03-13 20:19:49,414 [369] [DEBUG] [endpoints.v2] sending response: b'{"errors":[{"code":"METHOD NOT ALLOWED","detail":{},"message":"Pushes to the registry are currently disabled. Please contact the administrator for more information."}]}\n'
gunicorn-registry stdout | 2024-03-13 20:19:49,414 [369] [INFO] [gunicorn.access] 172.17.0.1 - - [13/Mar/2024:20:19:49 +0000] "PUT /v2/ibazulic/mariadb/manifests/sha256:c4694ba424e0259694a5117bbb510d67340051f0bdb7f9fa8033941a2d66e53e HTTP/1.1" 405 169 "-" "skopeo/1.9.3"
nginx stdout | 172.17.0.1 (-) - - [13/Mar/2024:20:19:49 +0000] "PUT /v2/ibazulic/mariadb/manifests/sha256:c4694ba424e0259694a5117bbb510d67340051f0bdb7f9fa8033941a2d66e53e HTTP/1.1" 405 169 "-" "skopeo/1.9.3" (0.002 3813 0.002)
~~~

The flag defaults to `False` (pushes enabled), unless set otherwise.

* Removed constraint on storage replication when pushes are disabled

* Rebase

* Fix isort sorting

* Fix isort sorting #2

* Removed constraint on storage replication when pushes are disabled

* Rebase

* Remove constraint on storage replication worker

* Fix linting on config.py
2024-08-07 15:40:10 -04:00
Daniel Messer
9d37de42fe Revert "audit: fix auto-prune audit logging (PROJQUAY-7423)" (#3065)
Revert "audit: fix auto-prune audit logging (PROJQUAY-7423) (#3056)"

This reverts commit 6318be721d.
2024-07-22 16:35:48 +02:00
Daniel Messer
6318be721d audit: fix auto-prune audit logging (PROJQUAY-7423) (#3056)
* use logs_model
---------

Signed-off-by: dmesser <dmesser@redhat.com>
2024-07-22 15:36:13 +02:00
Sunandadadi
6dbfdf05c5 events: fix notification methods for image expiry events (PROJQUAY-7487) (#3054) 2024-07-19 18:55:48 +00:00
Kenny Lee Sin Cheong
32890207da registry: index manifest artifact type for filtering (PROJQUAY-7471) (#3035)
Previous assumption made use of the config media type only, which is not the case
if a manifest's artifact type is explicitly set. i.e the config's media type and
artifact type are different, and the artifact type take precedence for filtering.
2024-07-16 22:33:38 +00:00
Brandon Caton
916aff690c oauth: logging assign oauth action to audit logs (PROJQUAY-7431) (#3033)
logging assign oauth action to audit logs
2024-07-16 14:24:17 -04:00
Sunandadadi
261f62a598 autoprune: autoprune model changes for image expiry events (PROJQUAY-7076) (#2985)
* database: adding subject_backfilled index to manifest table (PROJQUAY-7360) (#2963)

adding subject_backfilled index to manifest table

* Rebasing with main

* updating cypress data

* Rebasing with latest

* Forcing an empty commit.

* minor fixes

* Autoprune model changes

* fixing failing tests

* format fix

---------

Co-authored-by: Brandon Caton <bcaton@redhat.com>
2024-06-27 17:34:33 -04:00
Sunandadadi
6688bcca09 backend: implement basic functionality (PROJQUAY-7076) (#2984)
* database: adding subject_backfilled index to manifest table (PROJQUAY-7360) (#2963)

adding subject_backfilled index to manifest table

* Rebasing with main

* updating cypress data

* fixing conflicts and rebasing with latest code

* adding tests

* Forcing an empty commit.

* Forcing an empty commit.

* skip_locked test fix

* adding tests

* minor fixes

---------

Co-authored-by: Brandon Caton <bcaton@redhat.com>
2024-06-27 16:48:39 -04:00
Brandon Caton
7ef664a646 autoprune: Registry level autopruning (PROJQUAY-7392) (#2950)
Allows for adding a default autopruning policy that will be applied to all namespaces.
2024-06-26 16:43:31 -04:00
Brandon Caton
e4f05583c1 oauth: allowing to assign token to user (PROJQUAY-7074) (#2869)
Allow organization administrators to assign Oauth token to another user.
2024-06-25 09:23:51 -04:00
Daniel Messer
99d571a4a6 logs: allow without strict logging (PROJQUAY-7116) (#2846)
* allow to disable strict logging in general

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

* add strict logging exceptions for log kinds during reads

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

* add strict logging exceptions for log kinds during reads

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

* formatting

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

---------

Signed-off-by: dmesser <dmesser@redhat.com>
2024-06-17 21:17:39 +02:00
Daniel Messer
e73d096b28 api: OCI compliant tag listing and pagination (PROJQUAY-6931) (#2884)
implement OCI compliant pagination and tag listing

Signed-off-by: dmesser <dmesser@redhat.com>
2024-06-13 11:28:02 +02:00