Skip to content

Nightly builds re-run the whole update pipeline on every command #1986

Backlog

Description

@mrrobot47

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

  1. Disk check: disk_free_space() on the EE root, plus docker info to find the Docker root and check it too. That's a Docker call on every command.
  2. ee-db-migrations and ee-custom-container-migrations: these scan every core and package migration directory (no new migrations run, since executed ones are recorded).
  3. ee-docker-image-migrations: images listed in img-versions.json that never get an options row are docker pulled on every run. Today that's easyengine/mailhog and easyengine/php. Without Docker Hub access, or when rate-limited, the pull fails, and with it every command on a nightly build.
  4. ee-after-docker-image-migrations: the after_docker_image_migration hooks run again.
  5. ee-update-docker-compose: checks the docker-compose version again.
  6. ee-update-cron-config: cron-command's update_cron_config() rewrites services/cron/conf/config.ini and runs docker restart on 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 a wp cron run, is killed.
  7. 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, renaming ee.log away 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

  1. 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 whose VERSION doesn't change), gate it behind an explicit flag or env var instead of every command.
  2. cron-command: make job ids deterministic (derive them from the cron row id instead of a random suffix). Write config.ini only when its content changed, and restart the scheduler only then, or start it when it isn't running. ee cron create/update/delete and site enable/disable still restart when a job actually changes.
  3. Core, image migration: record an options row 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.
  4. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions