Repository navigation
Description
Problem
On a nightly build, every ee command (except cli, config and help) runs the whole update pipeline again, even when nothing changed since the last command. Running it once per nightly build is enough.
Runner::maybe_trigger_migration() has a branch that triggers the pipeline whenever the version string contains nightly, even when the stored version already matches:
} elseif ( $db_version !== $current_version ) {
EE::log( 'Executing migrations. This might take some time.' );
$this->trigger_migration( $current_version );
} elseif ( false !== strpos( $current_version, 'nightly' ) ) {
$this->trigger_migration( $current_version );
}Nightly versions already carry the build's commit, for example 4.16.0-nightly-6a42cf2. The $db_version !== $current_version branch above therefore already runs the pipeline once for each new nightly build, and the extra nightly branch only adds re-runs of the same build.
What runs again on every command
- Disk check:
disk_free_space()on the EE root, plusdocker infoto find the Docker root and check it too. That's a Docker call on every command. ee-db-migrationsandee-custom-container-migrations: these scan every core and package migration directory (no new migrations run, since executed ones are recorded).ee-docker-image-migrations: images listed inimg-versions.jsonthat never get anoptionsrow aredocker pulled on every run. Today that'seasyengine/mailhogandeasyengine/php. Without Docker Hub access, or when rate-limited, the pull fails, and with it every command on a nightly build.ee-after-docker-image-migrations: theafter_docker_image_migrationhooks run again.ee-update-docker-compose: checks the docker-compose version again.ee-update-cron-config: cron-command'supdate_cron_config()rewritesservices/cron/conf/config.iniand runsdocker restarton the global cron container every time. Each job id gets a fresh random suffix (random_password( 5 )), so the file always differs even when no cron job changed. Any job running at that moment, such as awp cronrun, is killed.ee-setup-logrotate: until fix(logrotate): set up rotation once instead of force-rotating on every migration run #1985 this force-rotated every EE log (logrotate -f) on every run, renamingee.logaway mid-command. fix(logrotate): set up rotation once instead of force-rotating on every migration run #1985 fixed this: an existing setup is no longer touched.
Steps 3 and 6 also cost something on a real update, since they run once per update even when nothing changed for them.
Proposed fix
- Core: drop the
elseif ( false !== strpos( $current_version, 'nightly' ) )branch, so a nightly build runs the pipeline once, when its version first differs from the stored one. If there's a reason to re-run within one build (for example a dev checkout whoseVERSIONdoesn't change), gate it behind an explicit flag or env var instead of every command. - cron-command: make job ids deterministic (derive them from the cron row id instead of a random suffix). Write
config.inionly when its content changed, and restart the scheduler only then, or start it when it isn't running.ee cron create/update/deleteand site enable/disable still restart when a job actually changes. - Core, image migration: record an
optionsrow for images pulled outside the install migration (mailhog, php), or skip pulling an image that's already present locally at the pinned tag, so they aren't pulled on every run. - Core, disk check: skip the
docker info/ free-space check when there's nothing to migrate, or run it only before steps that pull images or recreate containers.
How to see it
On a host running the nightly, run any command twice, for example ee site list, and compare docker inspect -f '{{.State.StartedAt}}' services_global-cron_1 before and after: the cron container restarts on each command. With --debug, every command prints the full Executing ee-... step list.
Activity