lando / platformsh

The Official Platform.sh Lando Plugin
https://docs.lando.dev/platformsh
GNU General Public License v3.0
6 stars 4 forks source link

platform.sh recipe, Elasticsearch v7.2, 7.5, and 7.7 not accessible in Lando #49

Closed gilzow closed 2 years ago

gilzow commented 3 years ago

TL;DR - elasticsearch is not reachable in lando after adding elasticsearch versions 7.2, 7.5, or 7.7 as a service in /.platform/services.yaml. Using v7.9 or 7.10 works as expected.

Lando version: 3.3.0 OS version: macOS 11.5.2

Contents of .lando.yml

name: daalder-test
recipe: platformsh

Contents of /.platform/services.yml:

db:
  type: mariadb:10.4
  disk: 1024

es:
  type: elasticsearch:7.2
  disk: 256

Contents of .platform.app.yml

# This file describes an application. You can have multiple applications
# in the same project.

# The name of this app. Must be unique within a project.
name: app

# The type of the application to build.
type: php:7.4

dependencies:
    php:
        composer/composer: '^2'

build:
    flavor: composer

# The hooks that will be performed when the package is deployed.
hooks:
    build: |
        set -e
    deploy: |
        set -e
        php artisan config:clear
        php artisan migrate --force

# The relationships of the application with services or other applications.
# The left-hand side is the name of the relationship as it will be exposed
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
    database: "db:mysql"
    essearch: 'es:elasticsearch'

# The size of the persistent disk of the application (in MB).
disk: 2048

# The mounts that will be performed when the package is deployed.
mounts:
  "storage/app/public":
      source: local
      source_path: "public"
  "storage/framework/views":
      source: local
      source_path: "views"
  "storage/framework/sessions":
      source: local
      source_path: "sessions"
  "storage/framework/cache":
      source: local
      source_path: "cache"
  "storage/logs":
      source: local
      source_path: "logs"
  "bootstrap/cache":
      source: local
      source_path: "cache"
  "/.config":
      source: local
      source_path: "config"

# The configuration of app when it is exposed to the web.
web:
    locations:
        "/":
            root: "public"
            index:
                - index.php
            allow: true
            passthru: "/index.php"
        "/storage":
            root: "storage/app/public"
            scripts: false

crons:
    # Run Laravel's scheduler every 5 minutes, which is often as crons can run.
    scheduler:
        spec: '*/5 * * * *'
        cmd: 'php artisan schedule:run'
    # Run Laravel's queue worker task every 9 minutes
    queue:
        spec: '*/9 * * * *'
        # Allow the worker to run for up to 5 minutes. That prevents
        # a long-running queue from blocking a deploy for more than 5
        # minutes.
        cmd: 'php artisan queue:work --max-time=300'

variables:
  php:
    memory_limit: "1024M"
  env:
    SCOUT_ELASTIC_HOST: 'essearch.internal'
    ELASTICSEARCH_HOST: 'essearch.internal'

Tell us about the command you were running

After bringing up lando (lando start) the application indicated it was unable to contact the elasticsearch service. Verified lando created the service

❯ lando info
<snip>
  { service: 'es',
    urls: [],
    type: 'platformsh-elasticsearch',
    healthy: true,
    creds: [ { internal_hostname: 'essearch.internal', port: 9200 } ],
    internal_connection: { host: 'es', port: '9200' },
    external_connection: { host: '127.0.0.1', port: '56240' },
    config: {},
    version: '7.2',
    meUser: 'elasticsearch',
    hasCerts: false,
    hostnames: [ 'es.daaldertest.internal' ] }

double-checked the container is up and running:

❯ docker ps
CONTAINER ID   IMAGE                                           COMMAND                  CREATED       STATUS       PORTS                                                                       NAMES
1da28e33a491   docker.registry.platform.sh/mariadb-10.4        "/lando-entrypoint.s…"   2 hours ago   Up 2 hours   127.0.0.1:56581->3306/tcp                                                   daaldertest_db_1
5c9c0c903762   docker.registry.platform.sh/elasticsearch-7.2   "/lando-entrypoint.s…"   2 hours ago   Up 2 hours   127.0.0.1:56580->9200/tcp                                                   daaldertest_es_1
7b5d98fb3946   docker.registry.platform.sh/php-7.4             "/lando-entrypoint.s…"   2 hours ago   Up 2 hours   127.0.0.1:56579->80/tcp                                                     daaldertest_app_1
db56ab4a23b6   traefik:2.2.0                                   "/lando-entrypoint.s…"   2 hours ago   Up 2 hours   127.0.0.1:443->443/tcp, 127.0.0.1:8080->80/tcp, 127.0.0.1:56506->8080/tcp   landoproxyhyperion5

SSH'ed into the app container via lando ssh and tried to connect to the service:

web@7b5d98fb3946:/app$ curl essearch.internal:9200
curl: (7) Failed to connect to essearch.internal port 9200: Connection refused
web@7b5d98fb3946:/app$ curl es.daaldertest.internal:9200
curl: (7) Failed to connect to es.daaldertest.internal port 9200: Connection refused

Set the version to 7.5, committed, ran lando stop && lando destroy -y && lando start, received the same issue and response from curl.

Did the same above but for version 7.7, received the same results. Did the same but for 7.9, but THIS time got something different:

web@037cd8b3e5bd:/app$ curl essearch.internal:9200
{
  "name" : "b64da72b2ffa",
  "cluster_name" : "elasticsearch",
<snip>
  },
  "tagline" : "You Know, for Search"
}

If this is a known issue with these versions of elasticsearch, then docs just need to be updated.

reynoldsalec commented 2 years ago

This is basically a duplicate of #3 at this point, going to clear out.