mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(codeartifact): serve the pypi sidecar under gunicorn (#9146)
The PyPI sidecar ran pypiserver's plain gevent server, one bare gevent.pywsgi process, which could wedge silently under concurrent first requests against a fresh repository: every later connection hung until Floci's proxy deadline turned it into a 500 instead of the 404 AWS answers. It now runs under gunicorn, already in the pinned image, with two gevent workers and no worker timeout (GUNICORN_CMD_ARGS), so a health probe is still served while one worker streams a multi-GB publish. The simple-dir backend lists the package directory on every request, so a publish served by one worker is visible to the other at once. Closes #9138
This commit is contained in:
1 parent
858bf8d2db
commit
d9914bfb93
1 file changed
+32
-3
@@ -118,6 +118,7 @@ public class PypiserverSidecarManager implements ContainerTeardown {
|
||||
// PID 1 it would ignore the stop request, and every reset, repository delete and
|
||||
// shutdown would wait out the whole stop timeout for each repository's container.
|
||||
.withInit()
|
||||
.withEnv("GUNICORN_CMD_ARGS", "--workers 2 --worker-class gevent --timeout 0")
|
||||
.withCmd(List.of(
|
||||
"run",
|
||||
"-p", String.valueOf(PYPISERVER_PORT),
|
||||
@@ -132,9 +133,37 @@ public class PypiserverSidecarManager implements ContainerTeardown {
|
||||
// pypiserver's own default server selection ("auto") lands on a
|
||||
// single-threaded synchronous fallback that cannot reliably receive a
|
||||
// real multi-GB publish body, discovered by hand-testing one end to end
|
||||
// (the connection was dropped mid-upload); gevent is already present in
|
||||
// the pinned image and handles a large body correctly.
|
||||
"--server", "gevent",
|
||||
// (the connection was dropped mid-upload). The pinned image's plain
|
||||
// "gevent" server (one bare gevent.pywsgi process) took that job but
|
||||
// wedges silently under concurrent first requests against a fresh
|
||||
// repository: every connection after the health probe hangs for the
|
||||
// client's whole timeout, even ones sent from inside the container,
|
||||
// and the process stays up at 0% CPU serving nothing (issue #9138).
|
||||
// "gunicorn" runs the same gevent WSGI handler behind gunicorn's own
|
||||
// master process, which serves concurrent first use and multi-GB
|
||||
// bodies alike; gunicorn is already present in the pinned image.
|
||||
//
|
||||
// GUNICORN_CMD_ARGS above does the gunicorn-side configuration, and
|
||||
// --backend simple-dir below keeps multi-worker consistency: with the
|
||||
// default "auto" backend, the pinned image's CachingFileBackend keeps
|
||||
// the package index in memory per worker process, so a publish served
|
||||
// by one worker leaves the other worker's index stale and a simple
|
||||
// index read randomly 404s right after a 200 publish (hand-tested
|
||||
// against the pinned image with two workers). The stateless
|
||||
// simple-dir backend lists the package directory per request, so both
|
||||
// workers always agree on what has been published.
|
||||
//
|
||||
// Two gevent workers rather than the default one: a single gevent
|
||||
// worker can spend its whole life inside one continuously-readable
|
||||
// large transfer, starving every other connection it accepted,
|
||||
// health probes included (17 of 30 probes timed out against a 1.2 GB
|
||||
// upload at local speed; with two, and the stateless backend, all
|
||||
// 30 pass). --worker-class gevent makes that choice explicit instead
|
||||
// of relying on the image's default selection, and --timeout 0 keeps
|
||||
// gunicorn's arbiter from killing a worker in the middle of a
|
||||
// multi-GB transfer.
|
||||
"--backend", "simple-dir",
|
||||
"--server", "gunicorn",
|
||||
PACKAGES_DIR))
|
||||
.build();
|
||||
String containerId = lifecycleManager.create(spec);
|
||||
|
||||
Reference in new issue
Block a user