WSDOT / wsdot-website

Codebase for WSDOT's public Drupal 7 website hosted on Acquia.
0 stars 4 forks source link

Migrate local development to Lando and Acquia CLI #578

Closed waynedyck closed 3 years ago

waynedyck commented 3 years ago

On Wednesday, 30 June 2021, Acquia will end support for Acquia Dev Desktop. After 30 June 2021, support will no longer be provided for Dev Desktop and related documentation will no longer be updated.

Acquia offers Acquia CLI integration with Lando. This integration facilitates pushing and pulling code, databases, and files to and from Acquia Cloud applications from within a Lando environment.

Lando does offer a Drupal 7 recipe, however, I need to confirm if this is compatible with Acquia CLI or if the above integration is only meant for Drupal 8 and 9.

waynedyck commented 3 years ago

The Acquia recipe integration with Lando is currently in beta. The latest integration is only available in a v3.1.4 pre-release from May 10, 2021.

I am running the latest stable v3.0.26 release which does not include the Acquia recipe.

waynedyck commented 3 years ago

Updated Lando to v3.1.4 pre-release

Running the command lando init --source acquia initially produced the following output followed by an error:

? Enter an Acquia API key
? Enter an Acquia API secret [hidden]
? Which site? Washington State Department of Transportation - Hosting (wsdot)
Docker Compose is now in the Docker CLI, try `docker compose up`

Creating network "landoinit50827660d16840c8b3de0e9a6fa88a8f_default" with the default driver
Creating volume "landoinit50827660d16840c8b3de0e9a6fa88a8f_data_init" with default driver
Creating volume "landoinit50827660d16840c8b3de0e9a6fa88a8f_home_init" with default driver
Creating landoinit50827660d16840c8b3de0e9a6fa88a8f_init_1 ... done
<email_address_hidden>.acquia.lando.id_rsa does not yet exist, generating one...
No user exists for uid 33
Killing landoinit50827660d16840c8b3de0e9a6fa88a8f_init_1 ... done
Removing landoinit50827660d16840c8b3de0e9a6fa88a8f_init_1 ... done
Removing network landoinit50827660d16840c8b3de0e9a6fa88a8f_default
Removing volume landoinit50827660d16840c8b3de0e9a6fa88a8f_data_init
Removing volume landoinit50827660d16840c8b3de0e9a6fa88a8f_home_init
ERROR ==>

Running the lando init --source acquia command again appears to correctly create the docker containers and clones the repository.

waynedyck commented 3 years ago

Lando install sets the environment variable, AH_SITE_ENVIRONMENT="LANDO" which causes problems with the way our sites/default/settings.php file is configured to work with Dev Desktop.

Dev Desktop does not set the AH_SITE_ENVIRONMENT variable as it is normally only set when the site is operating within Acquia's cloud environment.

Docker is basically mimicking Acquia's cloud environment so I will likely just need to modify the settings.php file to account for this.

waynedyck commented 3 years ago

When pulling the latest database and files with the command, lando pull --code=none I receive the following error message,

In PullCommandBase.php line 843:

  Unable to rebuild Drupal caches via Drush. Executing: mysql --defaults-extra-file=/tmp/drush_dSLLrZ --database=acquia --host=database --port=3306 --silent  < /tmp/drush_o2dFAI                                                                             
  Executing: mysql --defaults-extra-file=/tmp/drush_PCUNex --database=acquia --host=database --port=3306 --silent  < /tmp/drush_uHiglg                                                                                                                        
  Command cache-rebuild requires Drupal core version 8+ to run.                                                                                                                                                                                        39;49m
  0m[error]                                                                                                                                                                                                                                             
  The drush command 'cache:rebuild' could not be executed.                                                                                                                                                                                             39;49m
  0m[error]                                                                                                                                                                                                                                             

pull:database [--no-scripts] [-od|--on-demand] [--] [<environmentId> [<site>]]

Code does not appear to check what version of Drupal we are using and is defaulting to Drupal 8.

waynedyck commented 3 years ago

The above error is not coming from Lando. It is instead coming from Acquia CLI. The runDrushCacheClear function is defaulting to Drupal 8 / 9.

waynedyck commented 3 years ago

After pulling the database and files from PROD one needs to clear the MySQL cache tables manually, otherwise the site refuses to load without an error.

Use the following MySQL snippet:

TRUNCATE TABLE cache;
TRUNCATE TABLE cache_block;
TRUNCATE TABLE cache_bootstrap;
TRUNCATE TABLE cache_field;
TRUNCATE TABLE cache_filter;
TRUNCATE TABLE cache_form;
TRUNCATE TABLE cache_image;
TRUNCATE TABLE cache_menu;
TRUNCATE TABLE cache_page;
TRUNCATE TABLE cache_path;
TRUNCATE TABLE cache_token;
TRUNCATE TABLE cache_update;
waynedyck commented 3 years ago

This seems to be working fairly well so far. The one thing I need to research is how it works when trying to access the database and files while performing a migration. Because both the source and destination sites would now be in Docker containers the Drupal 7 source container may need to expose specific ports if not already accessible.