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

243 Commits

Author SHA1 Message Date
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
Flavian Missi
d20542aa45 fix several warnings (#1374)
mostly invalid escape sequences
2022-06-10 11:46:56 +02:00
Kenny Lee Sin Cheong
5471d3cbcb secscan: deprecate support for Clair V2 (PROJQUAY-2837) (#951)
Removes read support for Clair V2, along with the need to package
jwtproxy with Quay.

TODO: Drop deprecate image api + image table, remove image data model.
2022-05-31 10:15:54 -04: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
Flavian Missi
d029a4652d pull-thru: bump expiration of all parent manifest lists on pull (#1336)
the previous code relied on manifests always having a single manifest
list as their parents, which is false.

fixes https://issues.redhat.com/browse/PROJQUAY-3818
2022-05-25 13:32:12 +02: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
Flavian Missi
ac6a8d2f8b PROJQUAY-3750: support registries that do not return a digest header (#1310)
The distribution spec does not require the docker-content-digest header
to be set in response to a manifest GET/HEAD request.

This changes both the proxy client and the registry proxy model to
correctly check whether a manifest is up-to-date with the upstream
registry or not when no digest header is received.

NOTE: when checking staleness against registries that do not return the
docker-content-digest header, Quay will make a GET request to the
registry and calculate the digest from the manifest itself. GET requests
usually count towards rate-limiting.

This change also sets the accept-encoding header to 'identity'. The python
requests library seems to automatically set the accept-encoding header to
'gzip'. Dockerhub ignores that header when serving blobs, but some
registries don't (namely registry.access.redhat.com). When Quay receives a
gzipped config blob (have not tested non-config blobs) for some reason it
doesn't know how to handle it. I suspect it has to do wit the fact that in
this case the content-length header will differ from the actual size of
the response body, so when Quay tries to upload the blob it cannot
correctly calculate the actual blob size, so it does a partial upload to
its object storage, which then results in a digest mismatch error
(BlobDigestMismatchException).
2022-05-10 17:56:08 +02: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
3acc55b96c secscan: split the recent manifest chunk of work into multiple batch (PROJQUAY-3501) (#1300)
Split the work of indexing the recent manifests iterator into multiple
batches. This can reduce how often duplicate work happens when
allowing multiple workers to work on the same chunk of the table.
2022-05-04 11:02:56 -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
Kenny Lee Sin Cheong
9ac30007f9 secscan: cleanup secscan interface (PROJQUAY-3501) (#1284) 2022-04-25 14:24:08 -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
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
Kenny Lee Sin Cheong
035f582075 secscan: fix check for end of table (PROJQUAY-3501) (#1270)
Correctly check for the end of the manifest table, for when the worker
needs to start over. Also add missing token to lock key.
2022-04-20 13:15:21 -04:00
Kenny Lee Sin Cheong
7d0f318baa secscan: update the secscan model interface (PROJQUAY-3501) (#1254)
Add index_manifests as part of secscan interface. index_manifests is
a superset of perform_indexing, but also indexes a batch of recent manifests.
2022-04-19 13:39:51 -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
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
Kenny Lee Sin Cheong
53aaa5493b secscan: add indexer service request duration metric (PROJQUAY-3501) (#1243)
Add histogram for request duration on indexer service. Add random
batch to manifest iterator to reduce duplicate work while manifests
are being backfilled.
2022-04-13 10:04:43 -04:00
Kenny Lee Sin Cheong
f3a8b74daf mirror: increased registry user/pass max length (PROJQUAY-2712) (#945)
Increases the maximum length of external_registry_username and
external_registry_password fields from 2048 to 4096. Some registries,
e.g ECR, issue a token to be used as password, whose length is longer
than 2048 after being encrypted and base64 encoded. Since JWT's specs
do not specify a maximum length, we set the combined max length of
these fields to approximately 8K, the default header size on most
servers (including nginx), since these credentials will be passed in a
auth header during the auth flow.
2022-04-13 08:38:13 +02:00
Flavian Missi
a4ed986608 data: increase max len for proxy cache config credentials (#1241)
fixes PROJQUAY-3521
2022-04-12 16:04:01 +02: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
a52b00263a secscan: fix database manifest allocator for securityworker (PROJQUAY-3501) (#1235)
Have the securityworker send an abort signal in the case where the
conditions for indexing a manifest are not met after running the
candidate query. This could be when:
- a manifest has a reference to a manifestsecuritystatus instance
- the manifestsecuritystatus reindex threshold is no longer
valid (because it was recently updated)

This signals that another worker overlapped, and allows the current
worker to move on to the next set.
2022-04-11 13:06:46 -04: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
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
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
Flavian Missi
5987534718 endpoints/v2: handle generic proxy related errors (#1213)
also add upstream registry to proxy cache key. if a user changes their
mind about what registry to proxy, we shouldn't try to reuse the token.
2022-03-30 15:30:05 +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
f248d885aa proxy: don't store entire blob in memory when caching (#1200)
also uses blob uploader to upload the blob to storage.

PROJQUAY-3459
2022-03-28 18:27:07 +02: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
Syed Mushtaq Ahmed
4295a8f660 secscan: scan recent manifests in addition to regular backfill (PROJQUAY-3287) (#1169)
Adds a new iterator for exclusively scanning
recent manifests
2022-03-04 12:23:42 -05:00
Syed Mushtaq Ahmed
6a8567f830 secscan: log manifest ID when indexing (PROJQUAY-3287) (#1166)
for debugging quay.io clair issues
2022-03-03 15:47:58 -05:00
Kenny Lee Sin Cheong
033c1aafa1 ui: display manifest list manifest sizes (PROJQUAY-3196) (#1115)
Display individual manifest size in manifest list view.
Also fixes a non-cluster Redis cache bug.

TODO: This requires making extra individiual requests to get the
children manifests. They should probably be cached.
2022-03-01 16:07:28 -05:00
Syed Mushtaq Ahmed
7162be3791 secscan: make batch_size configurable (PROJQUAY-3287) (#1156)
For larger databases like quay.io the default batch
size is too high to complete the job in a resonable
time. Make the batch_size configurable so we can
adjust how many scans can be in-flight for a worker
2022-02-28 14:51:28 -05:00
Kenny Lee Sin Cheong
c5608d9765 database: retry connections on stale MySQL connections (PROJQUAY-3303) (#1148)
An InterfaceError is raised by PyMySQL after a connection has
been idle for longer than the MySQL database's interactive_timeout
setting. This can happen on some workers without work to be done for a
long time. This causes Peewee to be unable to reuse its stale
connection. Instead, the peewee connection needs to be closed, and a
new session opened with MySQL.
2022-02-25 14:22:46 -05:00
Syed Mushtaq Ahmed
4db5999037 sescan: prioritize scanning new pushes (PROJQUAY-3287) (#1147)
Currently we randomly scan for entries to be indexed. This could take a
long time if we have a lot of unindexed images. Ideally, we want to
priortize scanning of newer images before we go to the old ones.

This PR creates a smaller batch of size `batch_size` from
`max_id - batch_size` to `max_id` to priortize scanning
those
2022-02-25 13:09:38 -05:00
Kenny Lee Sin Cheong
369ee78a2c secscan: clairv2 - fix datatype bug (PROJQUAY-3279) (#1138) 2022-02-22 12:08:13 -05:00
Kenny Lee Sin Cheong
b32ca3142a secscan: ClairV2 datatype compatibility (PROJQUAY-3279) (#1133)
Mormalize metadata fields when serializing from dict, if not defined.
2022-02-22 09:20:04 -05:00
Syed Mushtaq Ahmed
eb62f4e999 db: remove url unqoute from migration logic (PROJQUAY-3266) (#1126)
This causes issues with where the DB user or password can have special chars
2022-02-20 08:52:31 -05:00
Joseph Crosland
26eb7ff982 secscan: Don't save secscan result if returned state is unknown (PROJQUAY-2939) (#1047)
Currently it is possible that Clair returns a state that Quay doesn't
know about and the previous logic will save this as a completed
manifest.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
2022-02-11 10:24:11 -06:00
Syed Mushtaq Ahmed
a058235b52 realtime: decode byte to string before using split (PROJQUAY-3180) (#1107)
This fixes the crash in the `/realtime` endpoint for testing user
events
2022-02-10 09:46:32 -05:00