magento-cloud-docker icon indicating copy to clipboard operation
magento-cloud-docker copied to clipboard

OpenSearch docker images broken

Open zakisaad opened this issue 2 years ago • 7 comments

Preconditions

Magento Cloud Docker - local development with latest 1.3.2 package

Steps to reproduce

  1. Create .magento.docker.yml file
  2. Specify elasticsearch service with:
    • image: "magento/magento-cloud-docker-opensearch"
    • version: "1.2"
  3. Generate docker-compose.yml file
  4. Attempt to bring up services

Expected result

Local Magento environment with OpenSearch

Actual result

OpenSearch container fails healthcheck. Upon review, OS_HOST is used for both the URL and port, unlike the Elasticsearch image which correctly uses ES_HOST and ES_PORT. However, even when fixing this issue, the healthcheck still fails.

We use the docker dev setup quite extensively, historically with ES. We are exploring OS, but are blocked on this issue.

zakisaad avatar Jun 02 '22 01:06 zakisaad

Hi @zakisaad

Thank you for your contribution.

You're right, OS_PORT should be there:

#!/bin/bash
set -eo pipefail

if health="$(curl -fsSL "http://${OS_HOST:-opensearch}:${OS_PORT:-9200}/_cat/health?h=status")"; then
  health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")
  if [ "$health" = 'green' ] || [ "$health" = 'yellow' ]; then
    exit 0
  fi
  echo >&2 "Unexpected health status: $health"
fi

exit 1

And we will fix it in the next release.

But it is not a root cause. OS_HOST and OS_PORT are used when they are provided. So, the default value is opensearch:9200

I tried to reproduce it, but it works fine. I tried it on Mac OS and Linux.

Could you provide more information about your system (OS, Docker version, etc)?

Try to use the next steps:

  • clone 2.4.4 template
  • run composer update
  • run ./vendor/bin/ece-docker build:compose
  • run docker-compose up -d

2.4.4 template uses OS 1.2 by default

BaDos avatar Jun 23 '22 18:06 BaDos

Hello @BaDos

I am also facing same issue on Mac machine only. I following the same steps you were mention :

clone 2.4.4 template
run composer update
run ./vendor/bin/ece-docker build:compose 
run docker-compose up -d

system information :

MacBook Pro M1 chip 32 gb ram

MicrosoftTeams-image

kanojiyadhaval avatar Aug 29 '22 18:08 kanojiyadhaval

Hello @kanojiyadhaval

How much memory do you provide for Docker Desktop?

BaDos avatar Aug 30 '22 15:08 BaDos

Hi @BaDos

currently, it's 8gb.

kanojiyadhaval avatar Aug 30 '22 18:08 kanojiyadhaval

I'm facing the same problem, working on:

Macbook air M1 8 gb ram Magento Cloud CLI 1.40.0 Magento 2.4.5 clean install

all the docker environment worked on first install, i stopped the containers and when i try to star them again it says the OpenSearch container is unhealthy, it is running but i can't run magento commands due to unhealthy container

any progress on this?

AngelBS avatar Oct 13 '22 23:10 AngelBS

Did you just use an image from Docker Hub? Or did you build own image using this sources https://github.com/magento/magento-cloud-docker/tree/develop/images/opensearch ?

Docker Hub does not contain any images for M1, please build you own images and try again to reproduce it.

BaDos avatar Oct 16 '22 00:10 BaDos

@here I fixed Opensearch but I get OOM in Java. Using images from the source you provided @BaDos Here is my Dockerfile for MAcbook M1. Magento version 2.4.5-p1 - Magento cloud docker installed via composer. Images build manually

FROM opensearchproject/opensearch:1.2.1

USER root
RUN yum -y install zip && \
    zip -q -d /usr/share/opensearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \
    yum remove -y zip && \
    yum -y clean all && \
    rm -rf /var/cache
USER opensearch

RUN bin/opensearch-plugin install -b analysis-icu && \
    bin/opensearch-plugin install -b analysis-phonetic

ADD docker-healthcheck.sh /docker-healthcheck.sh
ADD docker-entrypoint.sh /docker-entrypoint.sh

HEALTHCHECK --retries=3 CMD ["bash", "/docker-healthcheck.sh"]

ENTRYPOINT ["bash", "/docker-entrypoint.sh"]

EXPOSE 9200 9300

The main change was here "ENTRYPOINT ["bash", "/docker-entrypoint.sh"]". But Im working in a large site and Im getting these errors in Opensearch logs - java.lang.OutOfMemoryError: Java heap space

And setting are now 8G for memory. Maybe a problem in the code. I don't know. Would you guys please test my fix and see if you can reindex without issues?

gcampedelli avatar May 08 '23 18:05 gcampedelli