weixin_39730801
weixin_39730801
2020-12-28 07:57

BLT post-code-deploy hook failing on ACSF

BLT version: 8.9.14

We've been referred to report a BLT issue we're encountering on D8 an Acquia Sitefactory deployment. As a result of this post-deploy hook the ACSF deployment is failing.

This is the portion of the stacktrace that is failing in BLT:


<< [Acquia\Blt\Robo\Tasks\DrushTask]  Exit code 1  Time 0.732s
<< [error]  Failed to import configuration!
<< [error]  Command `setup:config-import ` exited with code 1.
<< [2018-03-20 18:17:31] WARN: Command returned exit code 1: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git executing hook post-code-deploy

Full error log output:


[Acquia Cloud Site Factory Task 12833433]
- Description: Deploy code to 02devup
- Body:        {"repo":"asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git","repo_id":"1221","from_vcs_type":"git","to_site":"asf802devup","to_stage":"02devup","from_path":"8.x-1.x-dev","no_create":true}
- Sender:      58cf3f52-544c-487f-a76b-efbce6c6f282
- Server:      task-388.enterprise-g1.hosting.acquia.com
- Queue:       code-push
- State:       failed
- Created:     2018-03-20 18:17:19 UTC
- Started:     2018-03-20 18:17:20 UTC (1s)
- Completed:   2018-03-20 18:17:31 UTC (11s from start, 12s total)

[snip]

<< [2018-03-20 18:17:23] asf8.02devup: updating web_servers[staging-2112].
<< Updating asf8.02devup to deploy 8.x-1.x-dev
<< Deploying 8.x-1.x-dev on asf8.02devup
<< [2018-03-20 18:17:28] Starting hook: post-code-deploy
<< [2018-03-20 18:17:29] Executing: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git < /dev/null (as asf8.02devup-2112})
<<
<< site="$1"
<< target_env="$2"
<< source_branch="$3"
<< deployed_tag="$4"
<< repo_url="$5"
<< repo_type="$6"
<<
<<
<<   . /var/www/html/$site.$target_env/vendor/acquia/blt/scripts/cloud-hooks/functions.sh
<< #!/bin/bash
<< # Common functions for cloud hooks.
<<
<< status=0
<<
<< drush_alias=${site}'.'${target_env}
<<
<< deploy_updates() {
<<
<<   case $target_env in
<<     01dev|01test|01live)
<<       acsf_deploy
<<       ;;
<<     01devup|01testup|01update)
<<       ;;
<<     *)
<<       ace_deploy
<<       ;;
<<     esac
<< }
<<
<< acsf_deploy() {
<<   sites=()
<<   # Prep for BLT commands.
<<   repo_root="/var/www/html/$site.$target_env"
<<   export PATH=$repo_root/vendor/bin:$PATH
<<   cd $repo_root
<<
<<   # Clear drush cache to make sure it can find ACSF tools.
<<   echo "Clearing Drush cache"
<<   drush cc drush
<<
<<   echo "Running updates for environment: $target_env"
<<
<<   # Generate an array of all site URIs on the Factory from parsed output of Drush utility.
<<   while IFS=$'\n' read -r line; do
<<       sites[i++]="$line"
<<       done <  setup:config-import
<< Executing pre-config-import target hook...
<< [ExecStack] echo 'No pre-config-import configured.'
<< [ExecStack] Running echo 'No pre-config-import configured.' in /var/www/html/asf8.02devup/docroot
<< No pre-config-import configured.
<< [ExecStack] Done in 0.002s
<< [Acquia\Blt\Robo\Tasks\DrushTask] Running /var/www/html/asf8.02devup/vendor/bin/drush cc drush --uri=simpletest --yes in /var/www/html/asf8.02devup/docroot
<< 'drush' cache was cleared.                                             [success]
<< [Acquia\Blt\Robo\Tasks\DrushTask] Done in 0.236s
<< [Acquia\Blt\Robo\Tasks\DrushTask] Running /var/www/html/asf8.02devup/vendor/bin/drush cache-rebuild --uri=simpletest --yes in /var/www/html/asf8.02devup/docroot
<< Drupal\Core\Database\ConnectionNotDefinedException: The specified        [error]
<< database connection is not defined: default in
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Core/Database/Database.php:361
<< Stack trace:
<< #0
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Core/Database/Database.php(166):
<< Drupal\Core\Database\Database::openConnection('default', 'default')
<< #1 [internal function]:
<< Drupal\Core\Database\Database::getConnection('default')
<< #2
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(248):
<< call_user_func_array(Array, Array)
<< #3
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
<< Drupal\Component\DependencyInjection\Container->createService(Array,
<< 'database')
<< #4
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(480):
<< Drupal\Component\DependencyInjection\Container->get('database', 1)
<< #5
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(230):
<< Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
<< #6
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
<< Drupal\Component\DependencyInjection\Container->createService(Array,
<< 'cache.backend.c...')
<< #7
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Core/Cache/CacheFactory.php(83):
<< Drupal\Component\DependencyInjection\Container->get('cache.backend.c...')
<< #8 [internal function]:
<< Drupal\Core\Cache\CacheFactory->get('bootstrap')
<< #9
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(248):
<< call_user_func_array(Array, Array)
<< #10
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
<< Drupal\Component\DependencyInjection\Container->createService(Array,
<< 'cache.bootstrap')
<< #11
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(480):
<< Drupal\Component\DependencyInjection\Container->get('cache.bootstrap',
<< 1)
<< #12
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(230):
<< Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
<< #13
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
<< Drupal\Component\DependencyInjection\Container->createService(Array,
<< 'module_handler')
<< #14
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Core/DrupalKernel.php(549):
<< Drupal\Component\DependencyInjection\Container->get('module_handler')
<< #15
<< /mnt/www/html/asf802devup/docroot/core/lib/Drupal/Core/DrupalKernel.php(710):
<< Drupal\Core\DrupalKernel->preHandle(Object(Symfony\Component\HttpFoundation\Request))
<< #16 /mnt/www/html/asf802devup/docroot/core/includes/utility.inc(43):
<< Drupal\Core\DrupalKernel->prepareLegacyRequest(Object(Symfony\Component\HttpFoundation\Request))
<< #17
<< /mnt/www/html/asf802devup/vendor/drush/drush/commands/core/cache.drush.inc(302):
<< drupal_rebuild(Object(Composer\Autoload\ClassLoader),
<< Object(Symfony\Component\HttpFoundation\Request))
<< #18
<< /mnt/www/html/asf802devup/vendor/drush/drush/includes/command.inc(422):
<< drush_cache_rebuild()
<< #19
<< /mnt/www/html/asf802devup/vendor/drush/drush/includes/command.inc(231):
<< _drush_invoke_hooks(Array, Array)
<< #20
<< /mnt/www/html/asf802devup/vendor/drush/drush/includes/command.inc(199):
<< drush_command()
<< #21
<< /mnt/www/html/asf802devup/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):
<< drush_dispatch(Array)
<< #22
<< /mnt/www/html/asf802devup/vendor/drush/drush/includes/preflight.inc(66):
<< Drush\Boot\BaseBoot->bootstrap_and_dispatch()
<< #23 /mnt/www/html/asf802devup/vendor/drush/drush/drush.php(12):
<< drush_main()
<< #24 {main}
<< [Acquia\Blt\Robo\Tasks\DrushTask]  Exit code 1  Time 0.732s
<< [error]  Failed to import configuration!
<< [error]  Command `setup:config-import ` exited with code 1.
<< 0.852s total time elapsed.
<< [2018-03-20 18:17:31] Finished hook: post-code-deploy
<<
<< [2018-03-20 18:17:31] Sending webhook hook: 'post-code-deploy' revision: ''!
<< [2018-03-20 18:17:31] WARN: Command returned exit code 1: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git executing hook post-code-deploy
<< zlib(finalizer): the stream was freed prematurely.

该提问来源于开源项目:acquia/blt

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

8条回答

  • weixin_39663360 weixin_39663360 3月前

    There are two issues:

    1. The post-code-deploy Cloud Hook is deprecated and unsupported so it should not be executed on ACSF environments #2227 made this change in BLT 9.x and it was not backported to BLT 8.x. You should instead us the db-update Factory Hook such as the one in BLT 9 which will run blt deploy:update tasks on each site during a code deploy. Additional documentation and examples of using BLT with the db-update Factory Hook is available in the Acquia ACSF documentation as well: https://docs.acquia.com/index.php/site-factory/extend/hooks/dbupdate#blt.

    2. Update environments are explicitly excluded from all Cloud Hook execution because in ACSF deployment / platform code updates, this is actually your "live" environment. The BLT Cloud Hooks scripts already have this exclusion for the standard environments: https://github.com/acquia/blt/blob/8.9.14/scripts/cloud-hooks/functions.sh#L14

    BLT provides post-code-update hooks (as opposed to post-code-deploy) for default ACSF environments 01dev, 01test but not custom environments like 02dev. In your case the hook actually executed in your 02devup environment which is your update environment and since the deploy was a branch as opposed to a tag, the post-code-update executed against the 02devup environment a second time using the Acquia Cloud scripts rather than the acsf_deploy script in functions.sh. You can add environments to this list and modify your post-code-update.sh script to execute your custom fucntions.sh script. Before making these changes you should review the ACSF Hooks documentation, particularly the section "Using Acquia Cloud hooks" and the hooks which are not supported on ACSF.

    点赞 评论 复制链接分享
  • weixin_39730801 weixin_39730801 3月前

    I'm not sure I understand what the proposed resolution is. We're just using the same default hooks that were created for the previous version of the BLT project. Are they still needed in 9.x (and must be moved) or should they be removed entirely?

    Also, this custom environment is a D8 stack https://docs.acquia.com/site-factory/tiers/stacks so I feel it is reasonable to expect ACSF and BLT to fully support it.

    点赞 评论 复制链接分享
  • weixin_39663360 weixin_39663360 3月前

    I created #2676 to track your feature request. I should have clarified in my response that by "custom environment" I meant environments that are not the default 01dev, 01test, or 01live on ACSF which in your case would include Stacks.

    If you would like to use post-code-update hooks immediately to resolve your error message you can follow the recommendations above which I have pasted below to clarify that it is an action item:

    1. You should instead use the db-update Factory Hook such as the one in BLT 9 which will run blt deploy:update tasks on each site during a code deploy. Additional documentation and examples of using BLT with the db-update Factory Hook is available in the Acquia ACSF documentation as well: docs.acquia.com/index.php/site-factory/extend/hooks/dbupdate#blt.

    2. You can add environments to this list and modify your post-code-update.sh script to execute your custom functions.sh script. Before making these changes you should review the ACSF Hooks documentation, particularly the section "Using Acquia Cloud hooks" and the hooks which are not supported on ACSF.

    点赞 评论 复制链接分享
  • weixin_39730801 weixin_39730801 3月前

    So I've commented out the code from the post-code-deploy hook, however the deployment is still failing.

    
    WARN: Command returned exit code 1: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git executing hook post-code-deployzlib(finalizer): the stream was freed prematurely.[requestStatus] => 200[retryLog] => Array()[failureState] => 1)
    

    It seems like it's failing on the existing 8.x-1.x-dev branch while I'm deploying the feature/8.4.x-dev branch so removing the deploy_updates function isn't working. Can you think of any reason that would be an issue?

    点赞 评论 复制链接分享
  • weixin_39663360 weixin_39663360 3月前

    I put in #2682 which should resolve your issue and also adds some additional ACSF backports from BLT 9.x. You can patch your version of BLT with the PR or update to the latest version once it is merged and then run blt setup:cloud-hooks to update your Cloud Hooks and then blt acsf:init to update your Factory Hooks

    点赞 评论 复制链接分享
  • weixin_39730801 weixin_39730801 3月前

    I merged in the PR and ran both commands but am still getting the below error attempting to deploy our new branch.

    
    [staging-389] - Checking hosting task 12993668; stdClass Object
    ([id] => 12993668[queue] => code-push[state] => failed[description] => Deploy code to 02devup[created] => 1522098001[started] => 1522098001[completed] => 1522098013[sender] => 58cf3f52-544c-487f-a76b-efbce6c6f282[result] =>[cookie] =>[logs] => [21:00:01] [21:00:01] Started[21:00:13] [2018-03-26 21:00:05] asf8.02devup: updating web_servers[staging-2112].Updating asf8.02devup to deploy 8.x-1.x-devDeploying 8.x-1.x-dev on asf8.02devup[2018-03-26 21:00:10] Starting hook: post-code-deploy[2018-03-26 21:00:11] Executing: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git < /dev/null (as asf8.02devup-2112})site="$1"target_env="$2"source_branch="$3"deployed_tag="$4"repo_url="$5"repo_type="$6". /var/www/html/$site.$target_env/vendor/acquia/blt/scripts/cloud-hooks/functions.sh#!/bin/bash# Common functions for cloud hooks.status=0drush_alias=${site}'.'${target_env}deploy_updates() {case $target_env in01dev|01test|01live)acsf_deploy;;...endor/drush/drush/includes/command.inc(231):_drush_invoke_hooks(Array, Array)#20/mnt/www/html/asf802devup/vendor/drush/drush/includes/command.inc(199):drush_command()#21/mnt/www/html/asf802devup/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):drush_dispatch(Array)#22/mnt/www/html/asf802devup/vendor/drush/drush/includes/preflight.inc(66):Drush\Boot\BaseBoot->bootstrap_and_dispatch()#23 /mnt/www/html/asf802devup/vendor/drush/drush/drush.php(12):drush_main()#24 {main}[Acquia\Blt\Robo\Tasks\DrushTask] Exit code 1 Time 0.73s[error] Failed to import configuration![error] Command `setup:config-import ` exited with code 1.0.849s total time elapsed.[2018-03-26 21:00:13] Finished hook: post-code-deploy[2018-03-26 21:00:13] Sending webhook hook: 'post-code-deploy' revision: ''![2018-03-26 21:00:13] WARN: Command returned exit code 1: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git executing hook post-code-deployzlib(finalizer): the stream was freed prematurely.[requestStatus] => 200[retryLog] => Array()[failureState] => 1)
    
    点赞 评论 复制链接分享
  • weixin_39730801 weixin_39730801 3月前

    With the patch from #2685 I am able to apply to do a fresh deployment to our 02test environment but still getting the below error on 02dev.

    
    [staging-389] - Checking hosting task 13088487; stdClass Object
    ([id] => 13088487[queue] => code-push[state] => failed[description] => Deploy code to 02devup[created] => 1522364038[started] => 1522364039[completed] => 1522364052[sender] => 58cf3f52-544c-487f-a76b-efbce6c6f282[result] =>[cookie] =>[logs] => [22:53:59] [22:53:59] Started[22:54:12] [2018-03-29 22:54:03] asf8.02devup: updating web_servers[staging-2112].Updating asf8.02devup to deploy 8.x-1.x-devDeploying 8.x-1.x-dev on asf8.02devup[2018-03-29 22:54:09] Starting hook: post-code-deploy[2018-03-29 22:54:10] Executing: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git < /dev/null (as asf8.02devup-2112})site="$1"target_env="$2"source_branch="$3"deployed_tag="$4"repo_url="$5"repo_type="$6". /var/www/html/$site.$target_env/vendor/acquia/blt/scripts/cloud-hooks/functions.sh#!/bin/bash# Common functions for cloud hooks.status=0drush_alias=${site}'.'${target_env}deploy_updates() {case $target_env in01dev|01test|01live)acsf_deploy;;...ndor/drush/drush/includes/command.inc(231):_drush_invoke_hooks(Array, Array)#20/mnt/www/html/asf802devup/vendor/drush/drush/includes/command.inc(199):drush_command()#21/mnt/www/html/asf802devup/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):drush_dispatch(Array)#22/mnt/www/html/asf802devup/vendor/drush/drush/includes/preflight.inc(66):Drush\Boot\BaseBoot->bootstrap_and_dispatch()#23 /mnt/www/html/asf802devup/vendor/drush/drush/drush.php(12):drush_main()#24 {main}[Acquia\Blt\Robo\Tasks\DrushTask] Exit code 1 Time 0.736s[error] Failed to import configuration![error] Command `setup:config-import ` exited with code 1.0.857s total time elapsed.[2018-03-29 22:54:11] Finished hook: post-code-deploy[2018-03-29 22:54:12] Sending webhook hook: 'post-code-deploy' revision: ''![2018-03-29 22:54:12] WARN: Command returned exit code 1: /mnt/users/asf8/02devup.shell /var/www/html/asf8.02devup/hooks/common/post-code-deploy/post-code-deploy.sh asf8 02devup 8.x-1.x-dev 8.x-1.x-dev asf8-1402.enterprise-g1.hosting.acquia.com:asf8.git git executing hook post-code-deployzlib(finalizer): the stream was freed prematurely.[requestStatus] => 200[retryLog] => Array()[failureState] => 1)
    
    点赞 评论 复制链接分享
  • weixin_39603357 weixin_39603357 3月前

    is following up on this issue in an Acquia support ticket. It seems to be a project-specific issue.

    点赞 评论 复制链接分享