magento / magento-cloud-docker

All Submissions you make to Magento Inc. (“Magento") through GitHub are subject to the following terms and conditions: (1) You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submission") you submit through GitHub. (2) Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above. (3) You agree to the Contributor License Agreement found here: https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html
Open Software License 3.0
253 stars 191 forks source link

OpenSearch docker images broken #350

Open zakisaad opened 2 years ago

zakisaad commented 2 years ago

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.

BaDos commented 2 years ago

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:

2.4.4 template uses OS 1.2 by default

kanojiyadhaval commented 2 years ago

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

BaDos commented 2 years ago

Hello @kanojiyadhaval

How much memory do you provide for Docker Desktop?

kanojiyadhaval commented 2 years ago

Hi @BaDos

currently, it's 8gb.

AngelBS commented 1 year ago

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?

BaDos commented 1 year ago

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.

gcampedelli commented 1 year ago

@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?