Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Travis CI Drupal site install failing (as of today) #720

Closed
geerlingguy opened this issue Dec 1, 2016 · 18 comments
Closed

Travis CI Drupal site install failing (as of today) #720

geerlingguy opened this issue Dec 1, 2016 · 18 comments
Assignees
Labels
Bug Something isn't working

Comments

@geerlingguy
Copy link
Contributor

My system information:

  • Operating system type: macOS
  • Operating system version: 10.12.1
  • BLT version: 8.5.2

When I run this command:

  • Travis CI build/test.

I get the following output:

blt > setup:drupal:install:
     [echo] Installing Drupal.
You are about to DROP all tables in your 'drupal' database. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a while. Consider using the [ok]
--notify global option.
exception 'Drupal\Core\Installer\Exception\AlreadyInstalledException'[error]
with message '<ul>
<li>To start over, you must empty your existing database and copy
<em>default.settings.php</em> over <em>settings.php</em>.</li>
<li>To upgrade an existing installation, proceed to the <a
href="/update.php">update script</a>.</li>
<li>View your <a href="http://default">existing site</a>.</li>
</ul>' in
/home/travis/build/acquia-pso/project/docroot/core/includes/install.core.inc:493
Stack trace:
#0
/home/travis/build/acquia-pso/project/docroot/core/includes/install.core.inc(112):
install_begin_request(Object(Composer\Autoload\ClassLoader), Array)
#1
/home/travis/build/acquia-pso/project/vendor/drush/drush/includes/drush.inc(726):
install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#2
/home/travis/build/acquia-pso/project/vendor/drush/drush/includes/drush.inc(711):
drush_call_user_func_array('install_drupal', Array)
#3
/home/travis/build/acquia-pso/project/vendor/drush/drush/commands/core/drupal/site_install.inc(80):
drush_op('install_drupal', Object(Composer\Autoload\ClassLoader),
Array)
#4
/home/travis/build/acquia-pso/project/vendor/drush/drush/commands/core/site_install.drush.inc(247):
drush_core_site_install_version('lightning', Array)
#5 [internal function]: drush_core_site_install('lightning',
'install_configu...')
#6
/home/travis/build/acquia-pso/project/vendor/drush/drush/includes/command.inc(366):
call_user_func_array('drush_core_site...', Array)
#7
/home/travis/build/acquia-pso/project/vendor/drush/drush/includes/command.inc(217):
_drush_invoke_hooks(Array, Array)
#8 [internal function]: drush_command('lightning',
'install_configu...')
#9
/home/travis/build/acquia-pso/project/vendor/drush/drush/includes/command.inc(185):
call_user_func_array('drush_command', Array)
#10
/home/travis/build/acquia-pso/project/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(72):
drush_dispatch(Array)
#11
/home/travis/build/acquia-pso/project/vendor/drush/drush/includes/preflight.inc(68):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12
/home/travis/build/acquia-pso/project/vendor/drush/drush/drush.php(12):
drush_main()
#13 {main}
[phingcall] /home/travis/build/acquia-pso/project/vendor/acquia/blt/phing/tasks/setup.xml:157:19: Drush exited with code 1

And I expected this to happen:

  • The site should install successfully.

This seemed to start happening today, and I can't get a successful build anymore.

@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

I'm wondering if this is related to recent changes in the Drush 9.x branch—I know there were a few small changes that started breaking people's builds on Drupal VM... maybe there's something similar going on here.

Locally I have 9.0.0-alpha1 (released March 9), and installs succeed.

@trwill
Copy link

trwill commented Dec 1, 2016

+1 seeing the same, also have drush 9.0.0-alpha1 locally and clean installs are fine.

@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

I'm going to try downgrading with:

$ composer remove drush/drush && composer require drush/drush ^8.1

I'll report back whether this works on Travis... Still fails at the same spot.

@trwill
Copy link

trwill commented Dec 1, 2016

Note, I also see a version difference of ubuntu between old passing builds and new failing ones in Travis. May be unrelated, but I'll see if there's any way to roll it back (cant find an obvious way).

Passing: Ubuntu 14.04.4 LTS
Failing: Ubuntu 14.04.5 LTS

@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

Maybe Drush is no longer able to connect to the database? See drush-ops/drush#511 and Add detail to AlreadyInstalledException

I know Ubuntu 14.04 had some issues with ufw at some point or another, maybe there's some internal access control blocking Drush?

I am in debug mode on Travis, connected via SSH, and if I run mysql -u root I can see the drupal database and connect to it without an issue. But Drush seems to not be connecting.

@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

Drush status seems to say otherwise:

travis@testing-gce-f4b3355f-e70e-4d48-9692-48065071fcd4:~/build/acquia-pso/project/docroot$ drush status
 Drupal version         :  8.2.3                                                                                        
 Site URI               :  http://127.0.0.1:8888                                                                        
 Database driver        :  mysql                                                                                        
 Database hostname      :  localhost                                                                                    
 Database port          :  3306                                                                                         
 Database username      :  root                                                                                         
 Database name          :  drupal                                                                                       
 PHP executable         :  /home/travis/.phpenv/versions/5.6/bin/php                                                    
 PHP configuration      :  /home/travis/.phpenv/versions/5.6.24/etc/php.ini                                             
 PHP OS                 :  Linux                                                                                        
 Drush script           :  /home/travis/build/acquia-pso/project/vendor/drush/drush/drush.php                            
 Drush version          :  8.1.5                                                                                        
 Drush temp directory   :  /tmp                                                                                         
 Drush configuration    :  /home/travis/build/acquia-pso/project/drush/drushrc.php                                       
 Drush alias files      :  /home/travis/build/acquia-pso/project/docroot/../drush/site-aliases/example.acsf.aliases.drus 
                           hrc.php                                                                                      
                           /home/travis/build/acquia-pso/project/docroot/../drush/site-aliases/example.local.aliases.dru 
                           shrc.php                                                                                     
                           /home/travis/build/acquia-pso/project/docroot/../drush/site-aliases/aliases.drushrc.php       
 Drupal root            :  /home/travis/build/acquia-pso/project/docroot                                                 
 Drupal Settings File   :  sites/default/settings.php                                                                   
 Site path              :  sites/default                                                                                
 Sync config path       :  /home/travis/build/acquia-pso/project/config/default

And drush sqlq "SHOW TABLES;" works fine, so it seems Drush can connect to the DB through the settings.php vars.

@arknoll
Copy link
Contributor

arknoll commented Dec 1, 2016

For the time being add
group: deprecated

to your travis.yml and it will work.

@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

I'm using:

<?php
try {
    $dbh = new PDO("mysql:host=127.0.0.1:3306;dbname=drupal", 'root', 'root');

    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo 'Connected to Database';

    $dbh = null;
}
catch (PDOException $e) {
    echo $e->getMessage();
}
print "\r\n";

Running from within Travis, and I get the error:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

(if I have no password)

and the error:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

(if I use the password root)

Also, I can connect using cli mysql -u root from the travis user account, but if I try from the root account (sudo su to switch), then it says MySQL can't connect to the socket, and if I run service mysql status it says it's stop/waiting... even though it's running.

Something has definitely changed in the default MySQL install on Travis!

@trwill
Copy link

trwill commented Dec 1, 2016

Thanks @arknoll, that works for me

@grasmash
Copy link
Contributor

grasmash commented Dec 1, 2016

Summary:

  • Drupal core's installer cannot connect to Travis' MySql database. Database::openConnection() fails
  • MySQL credentials are correct
  • Drush is able to connect, using settings.php variables.
  • Custom PHP scripts are able to connect using PDO
  • A Travis CI configuration change has definitely caused this.

grasmash added a commit to grasmash/bolt that referenced this issue Dec 1, 2016
@grasmash grasmash self-assigned this Dec 1, 2016
@grasmash
Copy link
Contributor

grasmash commented Dec 1, 2016

Root cause identified. $databases['default']['default']['hostname'] must be changed from localhost to 127.0.0.1.

Temporary workaround, add the following to bottom of settings.php:

if (getenv('TRAVIS')) {
  $databases['default']['default']['hostname'] = '127.0.0.1';
}

This will be the new default value in the next release of BLT.

@grasmash grasmash added the Bug Something isn't working label Dec 1, 2016
@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

Testing the temporary workaround now... seems to still hit the install failure for me :/

@grasmash
Copy link
Contributor

grasmash commented Dec 1, 2016

Seems like you may also need to create a new MySQL user with a password, grant access to the drupal db, and then use those credentials.

@geerlingguy
Copy link
Contributor Author

geerlingguy commented Dec 1, 2016

Okay, trying with adding the following to .travis.yml after the MySQL CREATE DATABASE line in before_install:

  - mysql -u root -e "CREATE USER 'blt'@'localhost' IDENTIFIED BY 'blt';"
  - mysql -u root -e "GRANT ALL ON drupal.* TO 'blt'@'localhost';"

And then adding the following at the bottom of settings.php:

// Temporary workaround for https://github.com/acquia/blt/issues/720
if (getenv('TRAVIS') && file_exists(__DIR__ . '/travis.settings.php')) {
  $databases['default']['default']['hostname'] = '127.0.0.1';
  $databases['default']['default']['username'] = 'blt';
  $databases['default']['default']['password'] = 'blt';
}

Hopefully it works!

@geerlingguy
Copy link
Contributor Author

This didn't seem to work for me, but I don't have time for further debugging right now—I'm going to switch to the group: deprecated method @arknoll mentioned previously for now.

For those wondering, stick that directive in the initial metadata at the top of the Travis file, e.g.:

sudo: required
group: deprecated
language: php
dist: trusty

...

@balsama
Copy link
Contributor

balsama commented Dec 1, 2016

FWIW, that did work for us, @geerlingguy .

The build also updates the version of jdk_switcher and we had to define the version to use in order for selenium to run properly too:

jdk_switcher use oraclejdk8 

@nickrussell
Copy link

nickrussell commented Dec 1, 2016

I found that removing the distro resolves the issue for BLT -v 8.5.2

sudo: required
group: deprecated
language: php

@balsama
Copy link
Contributor

balsama commented Dec 1, 2016

Here's our (lightning's) complete diff that got our builds passing on travis again if it helps. Lots of similarities/overlap: acquia/lightning@8415ec4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants