MAD-I-T / magento-actions

Github deployment actions for Magento 2
MIT License
102 stars 36 forks source link

Connection "default" is not defined #9

Closed alexjamesbrown closed 3 years ago

alexjamesbrown commented 3 years ago

I get the following when trying to run the build script

[Progress: 1377 / 1383] Enabling caches: Current status: layout: 1 block_html: 1 full_page: 1 [Progress: 1378 / 1383] Installing admin user... [Progress: 1379 / 1383] Caches clearing: Cache cleared successfully [Progress: 1380 / 1383] Disabling Maintenance Mode:

In ResourceConnection.php line 148:

Connection "default" is not defined

setup:install [--backend-frontname BACKEND-FRONTNAME] [--enable-debug-logging ENABLE-DEBUG-LOGGING] [--enable-syslog-logging ENABLE-SYSLOG-LOGGING] [--remote-storage-driver REMOTE-STORAGE-DRIVER] [--remote-storage-prefix REMOTE-STORAGE-PREFIX] [--remote-storage-bucket REMOTE-STORAGE-BUCKET] [--remote-storage-region REMOTE-STORAGE-REGION] [--remote-storage-key REMOTE-STORAGE-KEY] [--remote-storage-secret REMOTE-STORAGE-SECRET] [--consumers-wait-for-messages CONSUMERS-WAIT-FOR-MESSAGES] [--amqp-host AMQP-HOST] [--amqp-port AMQP-PORT] [--amqp-user AMQP-USER] [--amqp [--amqp-virtualhost AMQP-VIRTUALHOST] [--amqp-ssl AMQP-SSL] [--amqp-ssl-options AMQP-SSL-OPTIONS] [--key KEY] [--db-host DB-HOST] [--db-name DB-NAME] [--db-user DB-USER] [--db-engine DB-ENGINE] [--db [--db-prefix DB-PREFIX] [--db-model DB-MODEL] [--db-init-statements DB-INIT-STATEMENTS] [-s|--skip-db-validation] [--http-cache-hosts HTTP-CACHE-HOSTS] [--db-ssl-key DB-SSL-KEY] [--db-ssl-cert DB-SSL-CERT] [--db-ssl-ca DB-SSL-CA] [--db-ssl-verify] [--session-save SESSION-SAVE] [--session-save-redis-host SESSION-SAVE-REDIS-HOST] [--session-save-redis-port SESSION-SAVE-REDIS-PORT] [--session-save-redis [--session-save-redis-timeout SESSION-SAVE-REDIS-TIMEOUT] [--session-save-redis-persistent-id SESSION-SAVE-REDIS-PERSISTENT-ID] [--session-save-redis-db SESSION-SAVE-REDIS-DB] [--session-save-redis-compression-threshold SESSION-SAVE-REDIS-COMPRESSION-THRESHOLD] [--session-save-redis-compression-lib SESSION-SAVE-REDIS-COMPRESSION-LIB] [--session-save-redis-log-level SESSION-SAVE-REDIS-LOG-LEVEL] [--session-save-redis-max-concurrency SESSION-SAVE-REDIS-MAX-CONCURRENCY] [--session-save-redis-break-after-frontend SESSION-SAVE-REDIS-BREAK-AFTER-FRONTEND] [--session-save-redis-break-after-adminhtml SESSION-SAVE-REDIS-BREAK-AFTER-ADMINHTML] [--session-save-redis-first-lifetime SESSION-SAVE-REDIS-FIRST-LIFETIME] [--session-save-redis-bot-first-lifetime SESSION-SAVE-REDIS-BOT-FIRST-LIFETIME] [--session-save-redis-bot-lifetime SESSION-SAVE-REDIS-BOT-LIFETIME] [--session-save-redis-disable-locking SESSION-SAVE-REDIS-DISABLE-LOCKING] [--session-save-redis-min-lifetime SESSION-SAVE-REDIS-MIN-LIFETIME] [--session-save-redis-max-lifetime SESSION-SAVE-REDIS-MAX-LIFETIME] [--session-save-redis-sentinel-master SESSION-SAVE-REDIS-SENTINEL-MASTER] [--session-save-redis-sentinel-servers SESSION-SAVE-REDIS-SENTINEL-SERVERS] [--session-save-redis-sentinel-verify-master SESSION-SAVE-REDIS-SENTINEL-VERIFY-MASTER] [--session-save-redis-sentinel-connect-retries SESSION-SAVE-REDIS-SENTINEL-CONNECT-RETRIES] [--cache-backend CACHE-BACKEND] [--cache-backend-redis-server CACHE-BACKEND-REDIS-SERVER] [--cache-backend-redis-db CACHE-BACKEND-REDIS-DB] [--cache-backend-redis-port CACHE-BACKEND-REDIS-PORT] [--cache-backend-redis [--cache-backend-redis-compress-data CACHE-BACKEND-REDIS-COMPRESS-DATA] [--cache-backend-redis-compression-lib CACHE-BACKEND-REDIS-COMPRESSION-LIB] [--cache-id-prefix CACHE-ID-PREFIX] [--allow-parallel-generation] [--page-cache PAGE-CACHE] [--page-cache-redis-server PAGE-CACHE-REDIS-SERVER] [--page-cache-redis-db PAGE-CACHE-REDIS-DB] [--page-cache-redis-port PAGE-CACHE-REDIS-PORT] [--page-cache-redis [--page-cache-redis-compress-data PAGE-CACHE-REDIS-COMPRESS-DATA] [--page-cache-redis-compression-lib PAGE-CACHE-REDIS-COMPRESSION-LIB] [--page-cache-id-prefix PAGE-CACHE-ID-PREFIX] [--lock-provider LOCK-PROVIDER] [--lock-db-prefix LOCK-DB-PREFIX] [--lock-zookeeper-host LOCK-ZOOKEEPER-HOST] [--lock-zookeeper-path LOCK-ZOOKEEPER-PATH] [--lock-file-path LOCK-FILE-PATH] [--document-root-is-pub DOCUMENT-ROOT-IS-PUB] [--base-url BASE-URL] [--language LANGUAGE] [--timezone TIMEZONE] [--currency CURRENCY] [--use-rewrites USE-REWRITES] [--use-secure USE-SECURE] [--base-url-secure BASE-URL-SECURE] [--use-secure-admin USE-SECURE-ADMIN] [--admin-use-security-key ADMIN-USE-SECURITY-KEY] [--admin-user [ADMIN-USER]] [--admin [--admin-email [ADMIN-EMAIL]] [--admin-firstname [ADMIN-FIRSTNAME]] [--admin-lastname [ADMIN-LASTNAME]] [--search-engine SEARCH-ENGINE] [--elasticsearch-host ELASTICSEARCH-HOST] [--elasticsearch-port ELASTICSEARCH-PORT] [--elasticsearch-enable-auth ELASTICSEARCH-ENABLE-AUTH] [--elasticsearch-username ELASTICSEARCH-USERNAME] [--elasticsearch*** [--elasticsearch-index-prefix ELASTICSEARCH-INDEX-PREFIX] [--elasticsearch-timeout ELASTICSEARCH-TIMEOUT] [--cleanup-database] [--sales-order-increment-prefix SALES-ORDER-INCREMENT-PREFIX] [--use-sample-data] [--enable-modules [ENABLE-MODULES]] [--disable-modules [DISABLE-MODULES]] [--convert-old-scripts [CONVERT-OLD-SCRIPTS]] [-i|--interactive] [--safe-mode [SAFE-MODE]] [--data-restore [DATA-RESTORE]] [--dry-run [DRY-RUN]] [--magento-init-params MAGENTO-INIT-PARAMS]

seyuf commented 3 years ago

Hi @alexjamesbrown, Could you also drop, if possible, your action's config (e.g the content of the main.yml). I'll check out the error asap.

Many thanks

alexjamesbrown commented 3 years ago

@seyuf thanks for getting back to me so quickly.

Below is the workflow yml

I'm only getting as far as build for now - I'll deploy via SCP later (without deployer - our host has some custom scripts that'll do the actual prod deployment)

name: Build and deploy

on:
  push:
    branches: [ master ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    services:
      mysql:
        image: docker://mysql:8.0
        env:
          MYSQL_ROOT_PASSWORD: magento
          MYSQL_DATABASE: magento
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      elasticsearch:
        image: docker://elasticsearch:7.1.0
        ports:
          - 9200:9200
        options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
    env: 
      COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
      BUCKET_COMMIT: bucket-commit-${{github.sha}}.tar.gz
      MYSQL_ROOT_PASSWORD: magento
      MYSQL_DATABASE: magento

    steps:

      - uses: actions/checkout@v2

      - name: 'Build Magento2'
        if: always()
        uses: MAD-I-T/magento-actions@v2.0
        env:
          COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
        with:
          php: '7.4'
          process: 'build'
          elasticsearch: 1
alexjamesbrown commented 3 years ago

I've just noticed i forgot to add env MYSQL_ROOT_PASSWORD: magento MYSQL_DATABASE: magento

to the build step... added that and trying again

alexjamesbrown commented 3 years ago

Sadly, same result

seyuf commented 3 years ago

Humm the latest release is v3.3.1 or @master (instead of v2.0 uses: MAD-I-T/magento-actions@v2.0). Also, what's your magento version?

seyuf commented 3 years ago

Also are you using this extension ? https://github.com/YotpoLtd/magento2-module-yotpo-reviews/issues/148

alexjamesbrown commented 3 years ago

oh, i'll try that - i had copy/pasted this from one of the examples - I think an old example it's magento 2.4.3

not using Yotpo (yet)

seyuf commented 3 years ago

:+1: i'll test the deployer on a fresh 2.4.3 and get back to you. But it does looks like the error is due to some custom extension as it is awfully similar to the issue mentioned above.

alexjamesbrown commented 3 years ago

we're not using the deployer (yet) It fails at the build step

I've changed the step to

 - name: 'Build Magento2'
        if: always()
        uses: MAD-I-T/magento-actions@master
        env:
          COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
          MYSQL_ROOT_PASSWORD: magento
          MYSQL_DATABASE: magento
        with:
          php: '7.4'
          process: 'build'
          elasticsearch: 1

but still get the same error

alexjamesbrown commented 3 years ago

also, i should mention that this is a new install of magento - nothing else installed yet

alexjamesbrown commented 3 years ago

disabled yotpo, but still same issue yotpo is also included by default it seems: https://docs.magento.com/user-guide/marketing/yotpo-reviews-intro.html

seyuf commented 3 years ago

Hi @alexjamesbrown , Just tested a clean 2.4.3 installed through composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.3 /installation/directory/path. I've gotten no errors (see screenshot below) with config:

On the other hand, i found this link potentially related to your issue https://githubmemory.com/repo/davidalger/warden-env-magento2/issues/16.

seyuf commented 3 years ago

Also are you using a selfhosted runner or standard github runners?

alexjamesbrown commented 3 years ago

@seyuf standard github runner

seyuf commented 3 years ago

So... how did you install the magento? From the magento docs or from something like warden?

alexjamesbrown commented 3 years ago

that's a good question - I'm pretty sure it's from the magento docs I've copied it into a public repo https://github.com/alexjamesbrown/magento2-mad-i-t-actions

My PR last night was me trying to fix it (one of the local paths had a space in it) Unfortunately, it wasn't this

seyuf commented 3 years ago

There should be no spaces in the path, if you're using github runner. I'll check the install against your magento instance (I.e the repo linked above) and keep you posted.

seyuf commented 3 years ago

I can confirm, i just reproduced the error from git clone of your repo. Which confirms that the issue is coming from your code not from a fresh magento 2.4.3 install. I'll try to investigate further when i get 5 min tomorrow.

Capture d’écran 2021-10-24 à 22 46 50

In the mean while could you empty your magento dir and make a fresh install using php7.4 like the following ?

rm -rf magento/*
cd magento
php composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.3 .

EDIT

you can also just drop your composer.lock. Everything seem to be working fine after rm of that file. You surely inherited a some already fixed bug but not updated because of the lock. Let me know, if that worked.

alexjamesbrown commented 3 years ago

hmm, i tried removing composer.lock, but stil have the same issue https://github.com/alexjamesbrown/magento2-mad-i-t-actions/actions/runs/1378744182

I'll try removing and reinstall with composer

alexjamesbrown commented 3 years ago

https://github.com/alexjamesbrown/magento2-mad-i-t-actions/runs/3996042551?check_suite_focus=true

re-install worked

I wonder what the cause was https://github.com/alexjamesbrown/magento2-mad-i-t-actions/commit/6ae593d7058ee51108caf759f87c86d0a3ff5d4e

seyuf commented 3 years ago

Glad it worked. IMO the error is coming from one of the modules in your old composer.lock. Also i understand you also want to achieve a custom deploy process? So as a reminder, you can override any build/deploy scripts in the action by puting your updated scripts in some scripts dir in your root project as in here, and then enable the override argument in the action (override_settings: 1). Take care

seyuf commented 3 years ago

Re-openning this due to another report of the error occuring after upgrading from 2.4.0 to 2.4.3 using https://github.com/magento/composer-root-update-plugin (v 2.2) error-after-upgrading-2 4-to-2 4 3

alexjamesbrown commented 3 years ago

nice! I'll give this a go! Thanks

seyuf commented 1 year ago

https://forum.madit.fr/t/magento-error-connection-default-is-not-defined-at-install/86