For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits

Created on 3 May 2023, over 1 year ago
Updated 16 August 2023, over 1 year ago

Problem/Motivation

Currently we run all stages of the update life cycle in 1 cron request. This might cause timeouts in some cases. See #3357632-2: [META] Update doc comment on BatchProcessor to specify why use the batch system for background info.

Also the fact we run the complete life cycle in cron means it is not compatible in with Automated Cron which happens in kernel terminate event

Proposed resolution

Since we already have the drush command we should use that to run updates during cron

  1. Change CronUpdateStage to not extends StageBase but rather just fires off drush command to run updates.
    We should fire of the command but not wait for it to complete.

    In 📌 Add Symfony Console command to allow running cron updates via console and by a separate user, for defense-in-depth Fixed we will change this to not require drush.

  2. Change \Drupal\automatic_updates\CronUpdateStage::run to call the decorated cron service first. Since the unattended update will no longer happen directly in the web request we do not have to worry about timeouts before the update.
  3. Remove automatic_updates_cron entirely and move running of the status checks into the drush command
  4. Remove CronServerValidator because we are no longer making a sub-request to postApply
  5. Remove AutomatedCronDisabledValidator as we should be compatible with Automated Cron

    Add \Drupal\Tests\automatic_updates\Build\CoreUpdateTest::testAutomatedCron to prove we are compatible

  6. Change DrushUpdateStage to directly extend UpdateStage as CronUpdateStage won't be a stage.

    This means that most of the logic now in CronUpdateStage will be moved to DrushUpdateStage

    Likewise most coverage in CronUpdateStageTest will move to DrushUpdateStageTest

    CronUpdateStageTest will now just test that hook_cron is invoked before the terminal command is invoked

Closed out issues

This issue removes the need for

  1. 📌 For web cron updates run each stage life cycle phase in a different request Closed: won't fix
  2. 📌 Research alternatives to curl request on post apply event during cron updates Closed: outdated we won't be using curl anymore for post apply

Remaining tasks

  1. Test coverage that the drush command runs status checks.

    This will likely be a functional test because DrushTestTrait does not work with kernel tests.

Follow-up issues

  1. 📌 Rename CronUpdateStage to CronUpdateRunner Fixed just delayed to make this issue smaller
  2. 📌 Add Symfony Console command to allow running cron updates via console and by a separate user, for defense-in-depth Fixed

    since this issue will remove the requirement before beta the current issue only does simply validation for drush being available.

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024