Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-65471

Optionally allow cli php upgrade.php --no-outage

    XMLWordPrintable

Details

    • MOODLE_402_STABLE
    • MDL-65471-outageless
    • Hide

      Pre-requisites
      Site setup with at least 2 containers/servers, container 1 used for CLI administration, container 2 for web access.

      Run a clean upgrade to setup initial component hash state

      1. Edit top level version.php and bump it by .01
      2. In container 1, execute `php admin/cli/upgrade.php` and complete the upgrade.

      Test upgrade status with existing options - /db/ unchanged
      3. Edit mod/assign/version.php and bump it by 1
      4. In container 1, execute `php admin/cli/upgrade.php --is-pending`
      5. Confirm upgrade is pending.

      Test upgrade status with new options - /db/ unchanged
      6. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required`
      7. Confirm maintenance is NOT required for this upgrade, and an upgrade is still pending.
      8. In browser, visit admin/index.php on container 2, as a site administrator.
      9. Confirm you are prompted to upgrade, but do not do it.

      Test upgrade UI locking.
      10. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required --set-ui-upgrade-lock`
      11. In browser, visit admin/index.php on container 2, as a site administrator.
      12. Confirm your are NOT prompted to upgrade, and can click around as normal.
      13. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required --unset-ui-upgrade-lock`
      14. In browser, visit admin/index.php on container 2, as a site administrator.
      15. Confirm you ARE prompted to upgrade, but do not do it.

      Test upgrade status with no existing options - /db/ changed
      16. Edit /mod/assign/db/tasks.php and  change anything in the file, such as setting the minute to '1' instead of '*'
      17. In container 1, execute `php admin/cli/upgrade.php --is-pending`
      18. Confirm an upgrade IS pending.

      Test upgrade status with new options - /db/ changed
      19. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required`
      20. Confirm maintenance IS required for this upgrade.

      Test upgrade blocking still works
      21. Edit lib/upgradelib.php. Find function upgrade_noncore, and add a line immediately after the line `upgrade_started();`
          `sleep(10000);`
      22. In container 1, execute `php admin/cli/upgrade.php`, then accept the upgrade. This will enter an long sleep while the site upgrades.
      23. In browser, visit admin/index.php on container 2, as a site administrator.
      24. Confirm you see the 'Site is being upgraded' error message.
      25. Cancel the upgrade in CLI with the cancel command for the OS.

      26. Revert the change to /mod/assign/db/tasks.php

      Test upgrade isn't blocked with new options - /db/ unchanged
      27. In container 1, run `php admin/cli/upgrade.php --no-maintenance --set-ui-upgrade-lock`, the accept the upgrade.
      28. In browser, visit admin/index.php and confirm the site is not in maintenance, and you can click around.
      29. Cancel the upgrade in CLI with the cancel command for the OS.

      Test upgrade is blocked with new options - /db/ changed
      30. Edit /mod/assign/db/tasks.php and  change anything in the file, such as setting the minute to '1' instead of '*'
      31. In container 1, run `php admin/cli/upgrade.php --no-maintenance`
      32. Confirm that you are informed the upgrade WILL need maintenance, and no upgrade is started or performed.
      33. Revert the change to /mod/assign/db/tasks.php

      Test upgrade completes without maintenance.
      34. Remove the `sleep(10000);` line from lib/upgradelib.php
      35. In container 1, run `php admin/cli/upgrade.php --no-maintenance --set-ui-upgrade-lock`, and accept the upgrade.
      36. Confirm the upgrade successfully completes.
      37. Confirm that the command to purge caches are displayed.

      Show
      Pre-requisites Site setup with at least 2 containers/servers, container 1 used for CLI administration, container 2 for web access. Run a clean upgrade to setup initial component hash state 1. Edit top level version.php and bump it by .01 2. In container 1, execute `php admin/cli/upgrade.php` and complete the upgrade. Test upgrade status with existing options - /db/ unchanged 3. Edit mod/assign/version.php and bump it by 1 4. In container 1, execute `php admin/cli/upgrade.php --is-pending` 5. Confirm upgrade is pending. Test upgrade status with new options - /db/ unchanged 6. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required` 7. Confirm maintenance is NOT required for this upgrade, and an upgrade is still pending. 8. In browser, visit admin/index.php on container 2, as a site administrator. 9. Confirm you are prompted to upgrade, but do not do it. Test upgrade UI locking. 10. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required --set-ui-upgrade-lock` 11. In browser, visit admin/index.php on container 2, as a site administrator. 12. Confirm your are NOT prompted to upgrade, and can click around as normal. 13. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required --unset-ui-upgrade-lock` 14. In browser, visit admin/index.php on container 2, as a site administrator. 15. Confirm you ARE prompted to upgrade, but do not do it. Test upgrade status with no existing options - /db/ changed 16. Edit /mod/assign/db/tasks.php and  change anything in the file, such as setting the minute to '1' instead of '*' 17. In container 1, execute `php admin/cli/upgrade.php --is-pending` 18. Confirm an upgrade IS pending. Test upgrade status with new options - /db/ changed 19. In container 1, execute `php admin/cli/upgrade.php --is-maintenance-required` 20. Confirm maintenance IS required for this upgrade. Test upgrade blocking still works 21. Edit lib/upgradelib.php. Find function upgrade_noncore, and add a line immediately after the line `upgrade_started();`     `sleep(10000);` 22. In container 1, execute `php admin/cli/upgrade.php`, then accept the upgrade. This will enter an long sleep while the site upgrades. 23. In browser, visit admin/index.php on container 2, as a site administrator. 24. Confirm you see the 'Site is being upgraded' error message. 25. Cancel the upgrade in CLI with the cancel command for the OS. 26. Revert the change to /mod/assign/db/tasks.php Test upgrade isn't blocked with new options - /db/ unchanged 27. In container 1, run `php admin/cli/upgrade.php --no-maintenance --set-ui-upgrade-lock`, the accept the upgrade. 28. In browser, visit admin/index.php and confirm the site is not in maintenance, and you can click around. 29. Cancel the upgrade in CLI with the cancel command for the OS. Test upgrade is blocked with new options - /db/ changed 30. Edit /mod/assign/db/tasks.php and  change anything in the file, such as setting the minute to '1' instead of '*' 31. In container 1, run `php admin/cli/upgrade.php --no-maintenance` 32. Confirm that you are informed the upgrade WILL need maintenance, and no upgrade is started or performed. 33. Revert the change to /mod/assign/db/tasks.php Test upgrade completes without maintenance. 34. Remove the `sleep(10000);` line from lib/upgradelib.php 35. In container 1, run `php admin/cli/upgrade.php --no-maintenance --set-ui-upgrade-lock`, and accept the upgrade. 36. Confirm the upgrade successfully completes. 37. Confirm that the command to purge caches are displayed.

    Description

      There are various classes of upgrades that don't need an outage. For instance a couple lines of css, or a trivial php changes which are more about syntax and fixing log spam. Anything where there is no real impact of old code and new code running side by side on different frontends at the same time. As long as within a single session or series of requests you don't toggle and only ever move forward (eg cache busting url params)

      At the moment there is always a glitch during an upgrade when $CFG->upgraderunning is set even when there is no maintenance mode.

      We want to get to a point where we have the option to do a full blue / green with two sets of fronts and cut traffic across without any downtime.

      Obviously this isn't for all releases, but deciding when to use this is out of scope, this just gives us the ability to run a cli upgrade without the outage, eg

       

      $ php admin/cli/upgrade.php --non-interactive --no-outage

       

      There is a lot of logic scattered around which depends on $CFG->upgraderunning so I don't intend to touch that, I think I'll just make a second $CFG which when set allows requests to be served as normal.

       

       

       

      Attachments

        1. 2023-01-13_13-15-missing-block-of-code-MDL-65471.png
          2023-01-13_13-15-missing-block-of-code-MDL-65471.png
          44 kB
        2. 65471-5.png
          65471-5.png
          1.72 MB
        3. mdl65471-02.png
          mdl65471-02.png
          1.61 MB
        4. mdl65471-05.png
          mdl65471-05.png
          1.64 MB
        5. mdl65471-07.png
          mdl65471-07.png
          1.50 MB
        6. mdl65471-09.png
          mdl65471-09.png
          1.45 MB
        7. mdl65471-10.png
          mdl65471-10.png
          1.79 MB
        8. mdl65471-12.png
          mdl65471-12.png
          1.94 MB
        9. mdl65471-13.png
          mdl65471-13.png
          1.83 MB
        10. mdl65471-15.png
          mdl65471-15.png
          1.45 MB
        11. mdl65471-18.png
          mdl65471-18.png
          1.29 MB
        12. mdl65471-20.png
          mdl65471-20.png
          1.30 MB
        13. mdl65471-22.png
          mdl65471-22.png
          1.52 MB
        14. mdl65471-24.png
          mdl65471-24.png
          1.14 MB
        15. mdl65471-27.png
          mdl65471-27.png
          1.40 MB
        16. mdl65471-29.png
          mdl65471-29.png
          1.96 MB
        17. mdl65471-32.png
          mdl65471-32.png
          1.02 MB
        18. mdl65471-36.png
          mdl65471-36.png
          1.89 MB
        19. mdl65471-999.png
          mdl65471-999.png
          1.90 MB

        Issue Links

          Activity

            People

              peterburnett Peter Burnett
              brendanheywood Brendan Heywood
              Kevin Pham Kevin Pham
              Andrew Lyons Andrew Lyons
              Andrew Lyons Andrew Lyons
              Votes:
              2 Vote for this issue
              Watchers:
              25 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 6 hours
                  1d 6h

                  Clockify

                    Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.