1
0
mirror of https://github.com/quay/quay.git synced 2025-12-19 14:02:30 +03:00
Commit Graph

19 Commits

Author SHA1 Message Date
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
Kenny Lee Sin Cheong
5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -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
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
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
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
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
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
Joseph Schorr
51adbb9920 Have the GC workers raise a "go to sleep" exception to workers when (#447)
they fail to acquire a lock

This will ensure that the queue item gets re-queued and the worker is
put to sleep, rather than thrashing on retries
2020-06-18 14:36:35 -04:00
Kurtis Mullins
f1237bdb29 [PROJQUAY-753] Reduce logging noise (#445) 2020-06-18 13:54:20 -04:00
Joseph Schorr
1399c54432 Add feature flags to selectively disable namespace and repo GC workers (#390) 2020-05-26 11:46:28 -04:00
Joseph Schorr
388b97922f Remove the use of a transaction for User and Repository delete (#273)
While a transaction is obviously safer, with the number of tables
and rows referencing these tables now, a transaction is potentially
locking up a significant chunk of the database. Since we're already
performing cleanup before calling the delete, including disabling
new data being written for the User or Repository, deletion without
a transaction should (usually) be sufficient; if it isn't, an
IntegrityError will be raised, and the workers can retry continuing
the GC operation
2020-05-12 12:22:25 -04:00
Joseph Schorr
3f8221f74d GC query improvements (#356)
* Change storage GC to process a single row at a time

This should remove the deadlock under the transaction and be much less
heavy on the DB

* Ensure we don't select repositories for GC from those already marked
for deletion or those under to-be-deleted namespaces

* Ensure that GC operations occur under global locks, to prevent
concurrent GC of the same repositories, which should reduce lock
contention on the database
2020-05-12 11:56:03 -04:00
alecmerdler
3dd5f045ff fix all the docstrings 2020-02-05 19:55:07 -08:00
Tom McKay
e6ae94db8b 'make black' results 2019-12-02 12:23:08 -05:00
Jimmy Zelinskie
9c0dd3b722 initial import for Open Source 🎉 2019-11-12 11:09:47 -05:00