Scenario:

1. Add a remote server.
2. Add a platform for that server.
3. Add a site for that platform. > Taslk fails.

Below is the output of the task running again in command line (look for the word "error"). It can be seen that the database user is being created before the database and hence the process crashes.

aegir@ideupd1:/usr/share/drush/commands$ drush @hostmaster hosting-task 593 --debug
Bootstrap to phase 0. [0.01 sec, 2.21 MB]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.02 sec, 2.44 MB] [bootstrap]
Load alias @hostmaster [0.02 sec, 2.45 MB]                                                                                                           [notice]
Loading drushrc "/var/aegir/hostmaster-6.x-1.2/sites/aegir.ideupdev.com/drushrc.php" into "site" scope. [0.02 sec, 2.46 MB]                       [bootstrap]
Bootstrap to phase 5. [0.06 sec, 9.8 MB]                                                                                                          [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.06 sec, 9.81 MB]                                                                        [bootstrap]
Loading drushrc "/var/aegir/hostmaster-6.x-1.2/drushrc.php" into "drupal" scope. [0.06 sec, 9.81 MB]                                              [bootstrap]
Initialized Drupal 6.22 root directory at /var/aegir/hostmaster-6.x-1.2 [0.07 sec, 11.03 MB]                                                         [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.07 sec, 11.04 MB]                                                                       [bootstrap]
Initialized Drupal site aegir.ideupdev.com at sites/aegir.ideupdev.com [0.07 sec, 11.04 MB]                                                          [notice]
Loading drushrc "/var/aegir/hostmaster-6.x-1.2/sites/aegir.ideupdev.com/drushrc.php" into "site" scope. [0.07 sec, 11.04 MB]                      [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.07 sec, 11.05 MB]                                                              [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.07 sec, 11.09 MB]                                                                   [bootstrap]
Successfully connected to the Drupal database. [0.07 sec, 11.09 MB]                                                                               [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.08 sec, 11.47 MB]                                                                       [bootstrap]
Bootstrap to phase 5. [0.14 sec, 21.09 MB]                                                                                                        [bootstrap]
Found command: hosting-task (commandfile=hosting) [0.14 sec, 21.09 MB]                                                                            [bootstrap]
Initializing drush commandfile: drush_make [0.14 sec, 21.09 MB]                                                                                   [bootstrap]
Initializing drush commandfile: drush_make_d_o [0.14 sec, 21.09 MB]                                                                               [bootstrap]
Initializing drush commandfile: provision [0.14 sec, 21.09 MB]                                                                                    [bootstrap]
Load alias @server_localhost [0.14 sec, 21.09 MB]                                                                                                    [notice]
Load alias @server_master [0.15 sec, 21.09 MB]                                                                                                       [notice]
Loading apache driver for the http service [0.15 sec, 21.12 MB]                                                                                      [notice]
Loading mysql driver for the db service [0.15 sec, 21.13 MB]                                                                                         [notice]
Load alias @platform_hostmaster [0.15 sec, 21.14 MB]                                                                                                 [notice]
Initializing drush commandfile: user [0.15 sec, 21.14 MB]                                                                                         [bootstrap]
Including profiles/hostmaster/modules/hosting/task.hosting.inc [0.15 sec, 21.14 MB]                                                               [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_login() [0.15 sec, 21.2 MB]                                                                       [bootstrap]
Successfully logged into Drupal as admin (uid=1) [0.15 sec, 21.21 MB]                                                                             [bootstrap]
Task starts processing [0.16 sec, 21.94 MB]                                                                                                           [queue]
Running: /usr/share/drush/drush.php  --context_type='site' --master_url='http://aegir.ideupdev.com/' --uri='test.com'                               [command]
--db_server='@server_ns38738ovhnet' --platform='@platform_Kommerling' --language='en' --profile='default' --client_name='admin' provision-save
'@test.com' --backend  2>&1 [0.17 sec, 23.16 MB]
Bootstrap to phase 0. [0.25 sec, 23.18 MB]                                                                                                        [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.25 sec, 23.18 MB]                                                                             [bootstrap]
Bootstrap to phase 0. [0.25 sec, 23.18 MB]                                                                                                        [bootstrap]
Found command: provision-save (commandfile=provision) [0.25 sec, 23.18 MB]                                                                        [bootstrap]
Initializing drush commandfile: drush_make [0.25 sec, 23.18 MB]                                                                                   [bootstrap]
Initializing drush commandfile: drush_make_d_o [0.25 sec, 23.18 MB]                                                                               [bootstrap]
Initializing drush commandfile: provision [0.26 sec, 23.19 MB]                                                                                    [bootstrap]
Load alias @self [0.26 sec, 23.19 MB]                                                                                                                [notice]
Load alias @server_ns38738ovhnet [0.26 sec, 23.19 MB]                                                                                                [notice]
Load alias @server_master [0.26 sec, 23.19 MB]                                                                                                       [notice]
Loading apache driver for the http service [0.26 sec, 23.19 MB]                                                                                      [notice]
Loading mysql driver for the db service [0.26 sec, 23.19 MB]                                                                                         [notice]
Loading apache driver for the http service [0.26 sec, 23.19 MB]                                                                                      [notice]
Load alias @platform_Kommerling [0.26 sec, 23.19 MB]                                                                                                 [notice]
Initializing drush commandfile: user [0.26 sec, 23.19 MB]                                                                                         [bootstrap]
Load alias @test.com [0.26 sec, 23.19 MB]                                                                                                            [notice]
Template loaded: /usr/share/drush/commands/provision/provision_drushrc_alias.tpl.php [0.26 sec, 23.19 MB]                                            [notice]
Changed permissions of /var/aegir/.drush/test.com.alias.drushrc.php to 600 [0.26 sec, 23.19 MB]                                                     [message]
Generated config Drush configuration file [0.26 sec, 23.19 MB]                                                                                      [message]
Changed permissions of /var/aegir/.drush/test.com.alias.drushrc.php to 400 [0.26 sec, 23.2 MB]                                                      [message]
Command dispatch complete [0.26 sec, 23.2 MB]                                                                                                        [notice]
Peak memory usage was 9.61 MB [0.26 sec, 23.2 MB]                                                                                                    [memory]
Running: /usr/share/drush/drush.php  --profile='default' --client_email='juanpablo.novillo@ideup.com' @test.com provision-install --backend  2>&1   [command]
[0.26 sec, 23.19 MB]
Bootstrap to phase 0. [2.16 sec, 23.48 MB]                                                                                                        [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [2.16 sec, 23.49 MB]                                                                             [bootstrap]
Load alias @test.com [2.16 sec, 23.49 MB]                                                                                                            [notice]
Bootstrap to phase 1. [2.16 sec, 23.49 MB]                                                                                                        [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [2.16 sec, 23.49 MB]                                                                       [bootstrap]
Loading drushrc "/var/aegir/platforms/kommerling/drushrc.php" into "drupal" scope. [2.16 sec, 23.5 MB]                                            [bootstrap]
Initialized Drupal 6.20 root directory at /var/aegir/platforms/kommerling [2.16 sec, 23.5 MB]                                                        [notice]
Found command: provision-install (commandfile=provision) [2.17 sec, 23.5 MB]                                                                      [bootstrap]
Initializing drush commandfile: drush_make [2.17 sec, 23.5 MB]                                                                                    [bootstrap]
Initializing drush commandfile: drush_make_d_o [2.17 sec, 23.5 MB]                                                                                [bootstrap]
Initializing drush commandfile: provision [2.17 sec, 23.5 MB]                                                                                     [bootstrap]
Load alias @server_ns38738ovhnet [2.17 sec, 23.5 MB]                                                                                                 [notice]
Load alias @server_master [2.17 sec, 23.51 MB]                                                                                                       [notice]
Loading apache driver for the http service [2.17 sec, 23.51 MB]                                                                                      [notice]
Loading mysql driver for the db service [2.17 sec, 23.51 MB]                                                                                         [notice]
Loading apache driver for the http service [2.17 sec, 23.51 MB]                                                                                      [notice]
Load alias @platform_Kommerling [2.17 sec, 23.51 MB]                                                                                                 [notice]
Initializing drush commandfile: user [2.17 sec, 23.51 MB]                                                                                         [bootstrap]
Including /usr/share/drush/commands/provision/db/install.provision.inc [2.17 sec, 23.51 MB]                                                       [bootstrap]
Including /usr/share/drush/commands/provision/dns/install.provision.inc [2.17 sec, 23.52 MB]                                                      [bootstrap]
Including /usr/share/drush/commands/provision/http/install.provision.inc [2.17 sec, 23.52 MB]                                                     [bootstrap]
Including /usr/share/drush/commands/provision/platform/install.provision.inc [2.17 sec, 23.52 MB]                                                 [bootstrap]
Granting privileges to testcom@ns38738.ovh.net on testcom [2.17 sec, 23.52 MB]                                                                       [notice]
Could not create database user testcom [2.17 sec, 23.52 MB]                                                                                       [error]
Granting privileges to testcom@91.205.174.35 on testcom [2.17 sec, 23.52 MB]                                                                         [notice]
Could not create database user testcom [2.17 sec, 23.53 MB]                                                                                       [error]
Created testcom database [2.17 sec, 23.53 MB]                                                                                                     [success]
Dropping database testcom [2.17 sec, 23.53 MB]                                                                                                       [notice]
Revoking privileges of testcom@ns38738.ovh.net from testcom [2.17 sec, 23.53 MB]                                                                     [notice]
Failed to revoke user privileges [2.17 sec, 23.53 MB]                                                                                             [warning]
Revoking privileges of testcom@91.205.174.35 from testcom [2.17 sec, 23.53 MB]                                                                       [notice]
Failed to revoke user privileges [2.17 sec, 23.53 MB]                                                                                             [warning]
Changes made in drush_db_pre_provision_install have been rolled back. [2.17 sec, 23.54 MB]                                                         [rollback]
Command dispatch complete [2.17 sec, 23.54 MB]                                                                                                       [notice]
Peak memory usage was 10.73 MB [2.17 sec, 23.54 MB]                                                                                                  [memory]
Command dispatch complete [2.18 sec, 23.47 MB]                                                                                                       [notice]
 Timer  Cum (sec)  Count  Avg (msec) 
 page   2.106      1      2106.18    

Peak memory usage was 23.54 MB [2.18 sec, 23.47 MB]                                                                                                  [memory]

Comments

anarcat’s picture

Title: Aegir attempts to create database user before creating database on a remote site » Aegir fails to create remote database user on a remote site

clarifying issue title... i have personally witnessed this bug with juampy so I can confirm this exists, at least on his setup.

thanks for the bug report!

juampynr’s picture

Title: Aegir fails to create remote database user on a remote site » Aegir attempts to create database user before creating database on a remote site
Status: Active » Fixed

Got it. It was mainly my lack of knowledge in user administration in MySQL. It is basically that, I gave aegir a mysql user which cannot grant to other users in the remote server.

In order to avoid this to happen to more people, I suggest to add the following to http://community.aegirproject.org/node/30:

Aegir needs root access to the remote database. Create a root user in the remote server with the following command (the grant option is needed):

GRANT ALL PRIVILEGES ON *.* TO root@IP_OF_AEGIR_HOST identified by 'SOME_PASSWORD' with grant option;

The above user is the one that you must give to aegir when adding a remote server.

Finally, it could be nice if the verify server task tests that Aegir can grant rights to a user to a database.

juampynr’s picture

Title: Aegir attempts to create database user before creating database on a remote site » Aegir fails to create remote database user on a remote site
Status: Fixed » Needs review
StatusFileSize
new1.95 KB

Here is a patch that adds a check to verify that Aegir can create users on remote servers.

Please let me know if the patch applies or if it needs further work. I have verified that after adding the option "WITH GRANT OPTION" to the mysql user that aegir uses to access to the remote db of the server, the check passes.

juampynr’s picture

Updated patch after removing a missing debug call.

anarcat’s picture

Status: Needs review » Patch (to be ported)

committed to 2.x, waiting for jenkins to go green before merging.

anarcat’s picture

Status: Patch (to be ported) » Fixed

merged, thanks for the excellent patch juan! hoping to see you around in the queue soon again :)

juampynr’s picture

Here is an improved version of the patch, it adds the following:

* Changed wording from "Provision can create database users" to "Provision can grant privileges on database users", as the command used by Aegir is GRANT ALL PRIVILEGES... rather than CREATE USER. This is to avoid confusion to the fact that a user created with no GRANT OPTION can create users but cannot grant privileges.
* Once Aegir tests that it can grant permissions to a user, it revokes them and deletes it.

Finally, I have updated the documentation by adding a MySQL section. I feel that the two child pages of this one are a bit redundant, and therefore should be reviewed.

Cheers

juampynr’s picture

Status: Fixed » Needs review

Changed status to "needs review".

steven jones’s picture

Status: Needs review » Fixed

Thanks for the follow up patch, added the fixes to all branches.

steven jones’s picture

Project: Hostmaster (Aegir) » Provision

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

  • Commit d02b5e3 on 6.x-1.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x authored by juampy, committed by Steven Jones:
    Issue #1261006 - Follow up: Tidy docs and add missing parent method.
    
    
  • Commit a2601b4 on 7.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x authored by juampy, committed by Steven Jones:
    Issue #1261006 - Follow up: Tidy docs and add missing parent method.