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

117 Commits

Author SHA1 Message Date
OpenShift Cherrypick Robot
1239477f54 [redhat-3.9] api: Adding ignore timezone flag when parsing datetime (PROJQUAY-5360) (#2079)
* api: Removing parsing of datetime (PROJQUAY-5360)

* added ignoretz flag to date util parser

* added removed extra line

---------

Co-authored-by: Sunandadadi <sunanda.3094@gmail.com>
2023-08-01 10:19:34 -04:00
OpenShift Cherrypick Robot
81dc79668c [redhat-3.9] Pagination: Fixing paginate for /api/v1/superuser/logs API (PROJQUAY-5360) (#2011)
* Pagination: Fixing paginate for /api/v1/superuser/logs API

* using offset to fetch next page items

* adding datetime parsing

* using black to format code

* removing use_offset

* Removing redundant declaration

---------

Co-authored-by: Sunandadadi <sunanda.3094@gmail.com>
2023-07-11 23:38:55 +02:00
Brandon Caton
ba29a40b80 proxy: allowing expiring tags with timemachine set to 0 (PROJQUAY-5558) (#1907)
Adds the following changes:
- Allows remove_tag_from_timemachine to expire tags even if the time machine window is set to 0, immediately marking them for deletion. This allows the quota proxy pruner to expire tags with the same method call. This wasn't required for normal push/pulls as the user would just call the DELETE /tag endpoint.
- Remove hidden = true when expiring tags. For proxy Quay will attempt to lookup the tag referenced by the manifest in order to extend it's lifetime_end_ms. Hiding this tag prevents that logic from running correctly.
2023-05-26 15:04:06 -04:00
Marcus Kok
b911d480cf api: allow manifests to be pulled by digest (PROJQUAY-5467) (#1877)
Add new parameter `allow_hidden` to `lookup_manifest_by_digest` method and set this to true on the manifest v2 endpoint.

Enables manifests to be pulled by digest, and fixes issues with recent versions of conftest being unable to push to quay.
2023-05-26 09:43:27 -04:00
Brandon Caton
cf50901159 quota: moving resetting of child manifest temporary tags to delete endpoint (PROJQUAY-5512) (#1894)
Moves the resetting of child manifest temporary tags to happen on deletion instead of on push/pull. Resetting child manifest temporary tags caused issues in other portions of the code like proxy cache where temporary tags were deleted too early.
2023-05-23 09:05:32 -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
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
Sunandadadi
5c34296920 API/UI: Filtering of tags API through query parameter (PROJQUAY-5362) (#1839)
* API/UI: Filtering of tags API through query parameter (PROJQUAY-5362)

* Changing syntax of query param to add operation + added propagation of filtering from new UI

* added exception to return 400 on incorrect syntax

* Added tests to test filtering of /tags endpoint

* Minor fixes
2023-04-28 16:16:41 -04:00
Harish Govindarajulu
8a7aeec7c6 Evict LRU proxied images when quota limit is reached (PROJQUAY-3063) (#1493)
Signed-off-by: harishsurf <hgovinda@redhat.com>
2022-09-23 11:22:32 -04:00
Kenny Lee Sin Cheong
2b3c3cc584 api: feature to limit org creation to superusers (PROJQUAY-1245) (#1516)
* api: feature to limit org creation to superusers

Introduces the following configuration flags:

FEATURE_SUPERUSERS_ORG_CREATION_ONLY:
    Limit org creation to superusers only

FEATURE_SUPERUSERS_FULL_ACCESS:
    Grant superusers read/write access to registry content in all namespaces

FEATURE_RESTRICTED_USERS:
    Users considered as restricted are not anle to create organization

RESTRICTED_USERS_WHITELIST:
    Whitelist for FEATURE_RESTRICTED_USERS

RESTRICTED_USER_INCLUDE_ROBOTS:
    Whether or not to include the user namespace's robots

RESTRICTED_USER_READ_ONLY:
    Only allow read-only operations for restricted users

* Revert superuser repositorylist endpoint
2022-09-23 09:41:23 -04:00
Sunandadadi
1e136d6dd0 User: Added function to fetch users public repositories count (PROJQUAY-0000) (#1540)
* User: Added function to fetch users public repositories count (PROJQUAY-0000)

* Fixing Formatting (Flake8)
2022-09-22 13:14:14 -04:00
Sunandadadi
adf709568e Export Compliance: Fetching quay user data from federated login username (PROJQUAY-0000) (#1530)
* Fetching quay.io user data from federated login username (PROJQUAY-0000)

* Adding tests
2022-09-20 10:39:22 -04:00
Jonathan King
c36945b836 healthcheck: Use db_kwargs in health check (PROJQUAY-4222) (#1507)
- The database health check is currently not using the db_kwargs and not using ssl settings
- This is causing health check failures for MySQL behind SSL
2022-08-31 14:20:56 -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
Oleg Bulatov
4e1a985e70 Initialize model.config on its import (PROJQUAY-4006) (#1412)
* Initialize model.config on its import

* Initialze registry_model and secscan_model on import

Co-authored-by: Dave O'Connor <1656866+HammerMeetNail@users.noreply.github.com>
2022-07-12 01:15:30 +02: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
Brandon Caton
a0df895005 quota: Fix calculating org size (PROJQUAY-3889) (#1391)
Fixing database call which will now match on manifest vs repository to correctly calculate org size.
2022-06-16 13:58:27 -04:00
Oleg Bulatov
ed8f12ba34 Enable some flake8 checks in CI (#1389) 2022-06-16 18:22:16 +02:00
Brandon Caton
f28b35cc31 quota: Fix join on caching repo size (PROJQUAY-3889) (#1378)
Method for calculating size of repo joined on repo id instead of manifest id. This causes deleted manifests to be counted. Change updates call to join on manifest id.
2022-06-14 11:15:22 -04:00
Flavian Missi
f2c4375f65 fix: enable non-admins to cache images via pull-thru (PROJQUAY-3806) (#1366)
introduces a check of the OrganizationMemberPermission for pulls
against a proxy org.

if the proxy cache feature is disabled, or the org is not a proxy org
the check is not performed and Quay will behave normally.

this check does not mean pulls will work transparently though -
non-admin users need to be added to a team in the proxy org with the
member role, and default read and write permissions need to be given to
that team so that non-admin users can pull and update the cache for
images they do not own (the user who first pulls an image ends up
owning the repository since that is when the repo gets created).
2022-06-14 07:43:05 +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
kwestpharedhat
1e4871eca2 Quota: Add Cache To Tag Delete (PROJQUAY-3828) (#1345)
Add quota cache to delete tag
2022-05-27 10:04:21 -05:00
Sunandadadi
59d586c4c6 Quota Management: Adding default quota check for image push (PROJQUAY-3789) (#1316)
* Quota Management: Adding default quota check for image push (PROJQUAY-3789)

* Removing redundant if else check

* Fixing formatting

* Setting default quota bytes to 0
2022-05-11 14:20:38 -04:00
Kenny Lee Sin Cheong
9d8ff6b1c1 quota: address possible integrity exception if computing size concurrently (PROJQUAY-3752) (#1303) 2022-05-09 15:28:01 -04:00
Kenny Lee Sin Cheong
c2ceda5a26 chore: various small changes to fix exceptions, remove unused code (#1295) 2022-04-29 15:11:15 -04:00
Sunandadadi
1e65bff9fc Quota: Raising exception when entered quota size is too big (PROJQUAY-3702) (#1290)
* Quota: Raising exception when entered quota size is too big (PROJQUAY-3702)

* fixing formatting

* Updated error message
2022-04-27 15:28:36 -04:00
Kenny Lee Sin Cheong
3739c1fc21 notification: fix user ref when creating notification for quota (PROJQUAY-3711) (#1288) 2022-04-27 14:49:53 -04:00
Sunandadadi
eea7389a24 Quota: Show system default on UI when quota configuration for the org is not set (PROJQUAY-3518) (#1280)
* Quota: Show system default on UI when quota configuration for the org is not set (PROJQUAY-3518)

* Fixing formatting

* Added function to reduce redundancy and shortened warning message

* added missing parameter to function call

* Fixed organization quota consumption view

* Fixing formatting

* Checking for None before calling function
2022-04-22 16:34:04 -04:00
kwestpharedhat
79a3627a64 fix default system reject (#1277) 2022-04-21 14:07:43 -05:00
Sunandadadi
923fc72a28 Quota UI: Showing percent consumed if quota is configured on an organization (PROJQUAY-0000) (#1249)
* Tracking aws ip ranges.json

* Reverting change

* Quota UI: Showing percent consumed if quota is configured on an organization (PROJQUAY-0000)
2022-04-18 15:13:17 -04:00
Sunandadadi
3d6545b9da UI: Quota UI enhancements (PROJQUAY-0000) (#1242)
* Tracking aws ip ranges.json

* Reverting change

* Added default quota limit + added error display div + fixed indentation + minor restructuring of html

* Add check for non-negative or zero quota

* Added Limit percent check. numbers between 1-100 only acceptable

* Show warning note if no quota limit is set

* Show warning if no Reject type limit is selected

* Adding Remove button to delete quota configuration

* If Reject does not exist add default reject quota limit + css

* Throw error if more than one Reject Limit Type

* Throw error on identical limits

* Fixing showing default limits

* Added Organization view settings

* Show Remove btn only if quota exists

* Fixing Remove modal pop up

* Quota Reporting if quota is not set

* Fixing Removing Quota for org

* Fixing super user and org admin permissions

* fix to checking default quota

* Added super user perms check on put, delete endpoints

* Fixing formatting

* Fixing multiple rejects checks + returing empty list instead of None

* Using super user API calls + hiding policy div till quota is set

* Added require_scpe and show_if decorators for super user permissions

* fixing configured quota check after return type changed from None to list
2022-04-14 10:33:20 -04:00
Flavian Missi
61f4bd4252 namespacequota: return 0 when namespace has no size yet (#1237)
for non-cache orgs, get_namespace_size will almost never be called for
an org with no manifests.
for cache orgs, get_namespace_size is garanteed to be called once when
the org doesn't have any manifests: a first pull from a cache org will
ensure that.

this change does not negatively affect callers, as no callers rely on
get_namespace_size to return None.

fixes PROJQUAY-3538
2022-04-12 08:02:25 +02:00
Kenny Lee Sin Cheong
896a3aab3a api: update the quota api so that it's more consistent with the other apis endpoints (PROJQUAY-2936) (#1221)
* api: update the quota api so that it's more consistent with the other apis (PROJQUAY-2936)

- Uodate the quota api to be more consistent with the rest of the
endpoints
- Handles some uncaught exceptions, such as division by zero
- Update some of the quota data models used by the api to take object
  references instead of names to make it easier to use
- Update table model naming conventions
- swagger operationid multiple nicknames
- Added more test cases for api
- Remove unused functions
- Update the UI for better UX, based on the api changes made

* quota: fix ui input form value

* quota: join quota type query

* Remove unused functions
2022-04-07 14:11:55 -04:00
Flavian Missi
514bc6f1ba registry_proxy_model: count repository size when caching images (PROJQUAY-3464) (#1215)
also check if the org is within its quota limits before caching an image
from the upstream registry.
2022-03-31 16:38:13 +02:00
Sunandadadi
7524171ac8 Proxy Cache: Interface and UI for Proxy cache Configuration (PROJQUAY-3029) (#1204) 2022-03-31 10:48:59 +02: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
Flavian Missi
fe4d66b030 feat: pull-thru proxy cache (#1053)
introduces the possibility to pull images from external registries
through Quay, storing them locally for faster subsequent pulls.

Closes PROJQUAY-3030 and PROJQUAY-3033
2022-03-23 17:20:00 +01:00
kwestpharedhat
15fa20a115 QuotaManagement: Reporting (PROJQUAY-2936) (#1048)
* initial commit

* fixing some bugs

* create quota management

Fix json request json type

Creation of quota is working

All quota crud operations

crud for quota limits

repository size reporting

adding registry model

error levels

namespacequota

remove holdover from user file

finalizing refactor to namespace over organization

finalization of functionality

fixing formatting to match with black style

missed some files in formatting

fixing access to attribute

add single test to verify its working

fix some bugs and add defensive catching

bug fixes and code resiliency

Bug fixes and making quota limits detect properly where necessary

remove transitive delete and other bug fixes

fix formatting and trasnitive deletion issues

fix repositorysize does not exist error

fix not nul constraint and add security tests

fix security tests and bug

more security test fixes

reorder security tests

put docker file back and adjust security testing

security tests reduced

Missed changes for status 200

missed additional 201 responses getting 200

security bypass for now

Another tweak to security testing

forgot 1 endpoint

bug fix for parsing dictionary

remove unnecessary check at blob head

add initdb for quota

Incorrect syntax repair

mysql only supports decimal

adding quota specific notifications

optimization

add permission checks

adjust security and add configuration parameter

fix security test for new security levels

Fix logic errors and improve caching

fix logic issue and error reporting

adjust things according to PR comments

fix refactor left overs

miscapitilazation

missed refactor location

refactor code to remove quota limit groupings

fix refactor errors

remove transitive deletion

fix transitive deletes

Transitive deletion work

Transitive deletion work

refactor registry model and remove it

place api behind feature flag

patch feature enabledment for tests

patch feature enabledment for tests

testing to see if the config is the problem

remove patch

fix new org bug

fixing notifications

mismatched parameters

fix org not exists

fixed paramter mismatch

fix nonetype access

fix nonetype access

new tables created user deletion issues

new tables created user deletion issues

parameter mismatch

fix transitive delete

fix model access error

record does not exist missing catch

fix quota deletion to always delete limits

quotalimits deletion on quota deletion

mistake

fix quota limits deletion

patch tests and disable feature

typo

switch to toggle feature

add feature patch to top of file

change testconfigpy

* change permissions

* adjust permissions

* change config access

* fix formatting

* gether feature information differently

* duplicate function name

* fix config name

* type conversion

* config adjustments

* incorrect keyword

* Update security api tests

* duplicate naming

* fix config schema

* revert files and fix error

* QuotaManagement: UI (PROJQUAY-2936) (#1)

* [WIP]: Quota Reporting on Quay UI

* Integrating quota reporting UI with backend

* Humanizing bytes on UI

* Quota Reporting UI on repo table view

* Taking pull and updating code

* Adding quota management view

* Added support for CRUD operations for org quota

* create quota management

Fix json request json type

Creation of quota is working

All quota crud operations

crud for quota limits

repository size reporting

adding registry model

error levels

namespacequota

remove holdover from user file

finalizing refactor to namespace over organization

finalization of functionality

fixing formatting to match with black style

missed some files in formatting

fixing access to attribute

add single test to verify its working

fix some bugs and add defensive catching

bug fixes and code resiliency

Bug fixes and making quota limits detect properly where necessary

remove transitive delete and other bug fixes

fix formatting and trasnitive deletion issues

fix repositorysize does not exist error

fix not nul constraint and add security tests

fix security tests and bug

more security test fixes

reorder security tests

put docker file back and adjust security testing

security tests reduced

Missed changes for status 200

missed additional 201 responses getting 200

security bypass for now

Another tweak to security testing

forgot 1 endpoint

bug fix for parsing dictionary

remove unnecessary check at blob head

add initdb for quota

Incorrect syntax repair

mysql only supports decimal

adding quota specific notifications

optimization

add permission checks

adjust security and add configuration parameter

fix security test for new security levels

Fix logic errors and improve caching

fix logic issue and error reporting

adjust things according to PR comments

fix refactor left overs

miscapitilazation

missed refactor location

refactor code to remove quota limit groupings

fix refactor errors

remove transitive deletion

fix transitive deletes

Transitive deletion work

Transitive deletion work

refactor registry model and remove it

place api behind feature flag

patch feature enabledment for tests

patch feature enabledment for tests

testing to see if the config is the problem

remove patch

fix new org bug

fixing notifications

mismatched parameters

fix org not exists

fixed paramter mismatch

fix nonetype access

fix nonetype access

new tables created user deletion issues

new tables created user deletion issues

parameter mismatch

fix transitive delete

fix model access error

record does not exist missing catch

fix quota deletion to always delete limits

quotalimits deletion on quota deletion

mistake

fix quota limits deletion

patch tests and disable feature

typo

switch to toggle feature

add feature patch to top of file

change testconfigpy

* Removing quota and state conf from repo-list and user-view

* Removing quota and state conf form app list page

* Removing quota conf from repo-list.html

* minor fixes

* Added Quota Repoting and configuring quota from UI

* Making quota configuration component reusable + added support to read bytes via KB, MB, etc + Added reporting for total org consumption + Added org consumption for super user panel + Added quota configurable support on super user panel

* Adding older quota management component

* Removing not reusable quota management component

* Adding % consumption for repo quotas

* Adding % consumption for organization level quota

* Adding check to verify request.args

* Removing todo

* Adding default 0 to quota

* Formatting with black

* Fixing params for tests

* Formatting test file

Co-authored-by: Keith Westphal <kwestpha@redhat.com>

* remove migration

* add migration back

* repair formatting

* QuotaManagement: Moving the logic for bytes conversion to human friendly units to the frontend  (PROJQUAY-2936) (#3)

* Moving the logic for bytes conversion to human friendly units to the frontend

* Reading updates from quota_limit_id

* Formatting using black

* remote unused function

* Adding quota configuring on super user panel (#4)

* Converting quota bytes to human friendly format (#5)

* PR refactors

* invalid reference

* bad return value

* fix bad reference

* bad reference

* fix tests

* Quota Config: UI improvements (#6)

* Quota UI Improvements

* Rendering table for quota limit config

* Removing proxy cache files

* Disabling quota config for org view

* Removing redundant get

* Fixing PR requests

* repair formatting

Co-authored-by: Sunandadadi <Sunandadadi@users.noreply.github.com>
2022-03-08 12:02:03 -06:00
Kenny Lee Sin Cheong
639833cc15 teams: admin team deletion (PROJQUAY-2080) (#1077) 2022-02-08 10:52:46 -05: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
Syed Mushtaq Ahmed
0033f9b851 auth: Fix oauth code flow (PROJQUAY-781) (#1044)
OAuth Authorization Code Flow is broken in quay. Code
Flow is more secure than implicit flow and is used
by server side applications to get the access token
2021-12-23 14:17:36 -05:00
Oleg Bulatov
885b8c122c Implementation parameters should have same names as interface (#1011)
AuthorizationProvider uses explicit parameter names when it calls its
methods. Therefore methods of derivative classes, i.e. the methods of
the class DatabaseAuthorizationProvider, should have the same parameter
names.
2021-12-10 18:26:11 +01:00
Kenny Lee Sin Cheong
563d04aa00 gc: remove orphaned storage on repository purge (PROJQUAY-2313) (#961)
Make sure to remove orphaned storage blob when purging a repository's
uploadedblob.
2021-11-08 14:21:04 -05:00
thomasmckay
6470248be1 api: /v1/user/initialize to create first user (PROJQUAY-1926) (#771)
Add an unauthenticated API endpoint to create the initial user in the database. Usage is primarily intended for deployment automation.
2021-07-23 12:03:47 -04:00
Kenny Lee Sin Cheong
8591caf037 db: remove transaction from empty layer upload (PROJQUAY-1946) (#775)
Decouples blob upload and db row creation when uploading the empty
layer. This avoids the transaction blocking on non-db/S3 related issues.
2021-05-12 10:59:57 -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
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
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