Provision migrate doesn't put the site offline during migration

anarcat - November 14, 2009 - 22:35
Project:Provision
Version:6.x-0.4-alpha2
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

This is apparently a feature we're supposed to have, but I have never seen a site put offline during a migration.

In my opinion, the site should at least be put in "maintenance mode" before the database backup is performed. Adrian told me it was supposed to be redirected somewhere else during the migration, but I have not seen that happen while reloading regularly the site during a migration.

#1

anarcat - November 14, 2009 - 22:38

platform/migrate.provision.inc does say:

*   2. Temporarily disable the site by causing apache to redirect to a help page. Restarting apache is required.

However nothing in the code actually does that from what i can tell.

#2

anarcat - November 14, 2009 - 23:34

I tried this:

--- a/platform/migrate.provision.inc
+++ b/platform/migrate.provision.inc
@@ -31,6 +31,8 @@ function drush_provision_drupal_provision_migrate_validate($url = null, $platfor
  * Make a backup before making any changes, and add extract the file we are restoring from
  */
function drush_provision_drupal_pre_provision_migrate($url, $platform) {
+  drush_log(dt("Putting site in maintenance"));
+  drush_invoke('eval', array("'variable_set(\"site_offline\", 1);'", 'uri' => $url, 'root' => $platform));
   drush_invoke('provision backup', $url);
}

@@ -60,6 +62,8 @@ function drush_provision_drupal_post_provision_migrate($url) {
   drush_set_option('installed', FALSE);
   _provision_drupal_delete_aliases(drush_get_option('aliases', array()));
   _provision_recursive_delete(drush_get_option('sites_path') ."/$url");
+  drush_log(dt("Taking site out of maintenance"));
+  drush_invoke('eval', array("'variable_set(\"site_offline\", 0);'", 'uri' => $url, 'root' => $platform));
}

For some reason this fails with:

Parse error: syntax error, unexpected ';', expecting '(' in /usr/share/drush/commands/core/core.drush.inc(440) : eval()'d code on line 1

#3

mig5 - November 15, 2009 - 01:04

This works better, take advantage of some of drush2.1's new features

<?php
  drush_backend_invoke
("vset", array('site_offline', '1', 'uri' => "http://$url"));
?>

This puts the site into offline mode prior to migrate.

However! I put the site back online in the post_ hook but it doesn't work - drush will fail with

Could not find a Drupal settings.php file at ./sites/default/settings.php.
Command variable set needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run this command.

This is because technically the site is 'deleted' here: the site dir doesn't exist, we've just deleted it. We need to assume the site is in offline state stll after invoking 'provision deploy', and set it back online in the deploy post hook.

(I think)

#4

mig5 - November 15, 2009 - 01:19
Status:active» needs review

Please test

AttachmentSize
632984.patch 1.59 KB

#5

mig5 - November 15, 2009 - 01:21

Please test

AttachmentSize
632984.patch 1.59 KB

#6

mig5 - November 17, 2009 - 13:19

Updated patch, doesn't use vset, just writes $conf['site_offline'] = 1; to the settings.php for that fleeting moment before the site dir gets blown away prior to invoking provision deploy.

Since we use drush_set_option here, we can then accurately unset that variable on rollback and regenerate the settings.php without this setting, taking the site back out of offline mode should Migrate fail.

AttachmentSize
632984.patch 1.66 KB

#7

adrian - November 17, 2009 - 17:39

comitted a simpler version.

#8

mig5 - November 17, 2009 - 22:48
Status:needs review» fixed

#9

System Message - December 1, 2009 - 22:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.