Repository navigation
Fixes on top of v0.7.2 - #5
Merged
CorentinFelten merged 11 commits intoOct 2, 2026
Merged
Conversation
config.example.yaml documents a default of 3 extensions per deployment, but cmd/root.go set 4, so a config without the key allowed one more extension than documented.
Without a job queue, the expiry scheduler marked each expired
deployment as an error ("no job queue configured for termination")
and left its containers running, while the API's own terminate
endpoint already terminates in place in that case.
ExpiryScheduler.WithDirectTermination gives the scheduler the
challenge index, config provider and deployer it needs, and serve sets
it when Redis is not configured: expired deployments are then
terminated with models.TerminateDeployment, as the API does, which
marks them as errors only if the termination fails.
middleware.Recover was commented out since the first commit, with no note on why. Without it, net/http recovers a panicking handler itself but drops the connection without a response, and the request logger never logs the request. Nothing in Galvanize panics or recovers on purpose, so enabling it changes nothing else. The middleware setup moves to useMiddleware, so it can be tested. Recover logs the panic and its stack trace through zap, and the request logger then logs the 500 response.
DeployAllAdminInstances appended an empty ChallengeCategoryResponse for
each challenge it deployed, so its challenges list held one
{"category": "", "challenge_name": ""} per challenge. It now holds
each one's category and name, as TerminateAllAdminInstances already
does. Zync only reads challenges_count, so it is unaffected.
Both endpoints also returned "challenges": null when there was
nothing to do, although the API spec requires an array: they now
return [].
ExtendDeploymentExpiration only checked the expiry, the extension window and the extensions left, so a deployment still starting, being stopped or failed could be extended, using up an extension, and ExtendInstance answered with status running regardless. It now returns ErrNotRunning first for any deployment not running, which ExtendInstance answers with a 400 like the other refusals and counts as not_running in the extension rejection metric.
The tcp playbook's compose definition declared traefik_network as an external network, but the TCP service runs with network_mode: bridge and publishes its ports, so it never joins it. Ansible failed with "'traefik_network' is undefined" when the parameter was not set, and TCP challenges do not need Traefik. Checked by rendering the compose definition with and without traefik_network and validating it with docker compose config. Instances deployed by the previous playbook still terminate: the network was external, so compose never created or removed it.
The Dockerfile's CMD ran `galvanize serve 8080 -c config.yaml`, but serve takes no arguments (cobra.NoArgs) and reads the port from --port, so the container exited with 'unknown command "8080" for "galvanize serve"' unless a command was given, as docker-compose.yml does. The default is now the same command as docker-compose.yml's: serve --port 8080 --config data/config.yaml.
max_concurrent_ansible is documented as the cap on concurrent Ansible runs without Redis (default 5), but nothing read it: each team deploy or terminate, and now each expiry, started its own unbounded run. ansible.LimitedDeployer wraps a Deployer with a fixed number of slots shared by Deploy and Terminate; further calls wait for a slot, or for their context. Without Redis, serve gives one with max_concurrent_ansible slots to the server, as ServerOpts.TeamDeployer for team requests, and to the expiry scheduler. Admin actions keep the unlimited deployer, so they are never queued behind team requests. With Redis, num_workers bounds these runs as before.
constants.go declared test = 123, used nowhere.
openPortBindingDB opened a new gorm connection pool, and ran AutoMigrate, on each of its calls: loading, reserving, saving and clearing bindings, i.e. several times per deploy and terminate. None was ever closed, so each call left a SQLite connection and its file descriptor open: 200 calls left 200 more descriptors open. The store now keeps one pool per database file, opened and migrated on first use, in a map guarded by portBindingDBMu, which every caller already holds. Checked while looking into it: these connections did not lack a busy timeout, as suspected; the glebarez driver sets busy_timeout to 5000 by default.
Coverage of the lines changed by these fixes showed what no test ran: - serve's choice of execution without Redis. It moves to configureQueueless, tested with and without a job queue: without one, team requests and expiries share one LimitedDeployer with max_concurrent_ansible slots (default 5); with one, nothing changes. ExpiryScheduler.DirectTerminationDeployer and LimitedDeployer.Limit expose what the tests check. - The config defaults, including deployment_max_extensions: 3. They move to setConfigDefaults, tested by loading a config that omits them. - A terminate call that gives up waiting for a slot, and a port bindings store that cannot be opened or migrated, which must not be cached. The lines changed by these fixes go from 61% to 74% covered; the rest are the calls in serve and initConfig, which only run at startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ten fixes on top of v0.7.2, one commit each:
deployment_max_extensionsto 3, as documented (the code used 4)/admin/deploy-allresponse (entries were empty); empty bulk lists are[], notnulltcpplaybook: no longer requirestraefik_network, which TCP services never joinserve --port 8080 --config data/config.yaml)max_concurrent_ansiblewithout Redis, for team requests and expiries only (admin actions are not limited)testconstantNotes for review:
_busy_timeout/_journal_mode=WALparameters (pkg/db.go) are ignored by the glebarez driver, so WAL is off. The busy timeout is still 5s, the driver's default. Enabling WAL would change how backups must be restored (-wal/-shmfiles), so it is left for a separate decision.