mcoia / eg-docker

Evergreen on Google container Docker
13 stars 8 forks source link

"Bad hostname 'private.localhost'" at Ansible Start Opensrf task #18

Closed terroirman closed 1 year ago

terroirman commented 1 year ago

Hi @bmagic007 ,

Trying to docker-compose up the generic-dockerhub folder and I'm getting this error "Jabber Exception: Could not open TCP socket to Jabber server: IO::Socket::INET: Bad hostname 'private.localhost'" (see details below).

Any idea how to solve this issue ?

I haven't changed much to the project vars, just the following:

--- a/generic-dockerhub/.env
+++ b/generic-dockerhub/.env
@@ -1,5 +1,5 @@

-HOST='app.brick.com'
+HOST='evergreen.lan'
 IMAGE='evergreen'
 SSL_PORT='32'
 HTTP_PORT='80'

and

--- a/generic-dockerhub/vars.yml
+++ b/generic-dockerhub/vars.yml
@@ -5,7 +5,7 @@
 # NOTE: xenial is not supported due to the nodejs stack issues, but left here for reference in case you want to ha
ck it
 # Evergreen didn't support ubuntu bionic until version 3.3
   ubuntu_version: focal
-  evergreen_version: 3.9.1
+  evergreen_version: 3.10.3

Detailled log:

347.1 TASK [Start Opensrf] ***********************************************************
347.7 fatal: [127.0.0.1]: FAILED! => {
    "changed": true,
    "cmd": "osrf_control --localhost --start-all",
    "delta": "0:00:00.380109",
    "end": "2023-11-07 08:17:58.334091",
    "msg": "non-zero return code",
    "rc": 25,
    "start": "2023-11-07 08:17:57.953982",
    "stderr": "Exception: OpenSRF::EX::Jabber 2023-11-07T08:17:58 OpenSRF::Transport::SlimJabber::Client /usr/local/share/perl/5.30.0/OpenSRF/Transport/SlimJabber/Client.pm:155 Jabber Exception: Could not open TCP socket to Jabber server: IO::Socket::INET: Bad hostname 'private.localhost'",
    "stderr_lines": [
        "Exception: OpenSRF::EX::Jabber 2023-11-07T08:17:58 OpenSRF::Transport::SlimJabber::Client /usr/local/share/perl/5.30.0/OpenSRF/Transport/SlimJabber/Client.pm:155 Jabber Exception: Could not open TCP socket to Jabber server: IO::Socket::INET: Bad hostname 'private.localhost'"
    ],
    "stdout": "",
    "stdout_lines": []
}
347.7 
347.7 PLAY RECAP *********************************************************************
347.7 127.0.0.1                  : ok=43   changed=37   unreachable=0    failed=1    skipped=9    rescued=0    ignored=3   
347.7 
------
Dockerfile:52
--------------------
  50 |     ADD evergreen_restart_services.yml /egconfigs/evergreen_restart_services.yml
  51 |     ADD restart_post_boot.yml /egconfigs/restart_post_boot.yml
  52 | >>> RUN cd /egconfigs && ansible-playbook install_evergreen.yml -v -e "hosts=127.0.0.1"
  53 |     ENTRYPOINT cd /egconfigs && ansible-playbook evergreen_restart_services.yml -vvvv -e "hosts=127.0.0.1" && while true; do sleep 1; done
  54 |     #ENTRYPOINT while true; do sleep 1; done
--------------------
ERROR: failed to solve: process "/bin/sh -c cd /egconfigs && ansible-playbook install_evergreen.yml -v -e \"hosts=127.0.0.1\"" did not complete successfully: exit code: 2
ERROR: Service 'web' failed to build : Build failed
bmagic007 commented 1 year ago

Jerome,

This issue is related to how Docker handles the hosts file. Evergreen requires some manual entries into the /etc/hosts file for ejabberd, and the container attempts to set those up. Docker doesn't allow editing /etc/hosts (anymore) - so instead we have to pass the entries during the build. Like this:

docker build \ --add-host public.localhost:127.0.1.2 \ --add-host public:127.0.1.2 \ --add-host private.localhost:127.0.1.3 \ --add-host private:127.0.1.3 \ . --no-cache

But it sounds like you're using docker compose. Which isn't very well tested. A little reading on the matter, and I think we have a clause missing in our .env file:

extra_hosts:

Try adding that to .env

bmagic007 commented 1 year ago

Ugh - This comment form mangled my lines. Let see if this comes through

extra_hosts: - "public.localhost:127.0.1.2" - "public:127.0.1.2" - "private.localhost:127.0.1.3" - "private:127.0.1.3"

bmagic007 commented 1 year ago

Jerome,

I went ahead and pushed a change to the repo illustrating the .env change.

terroirman commented 1 year ago

Jerome,

I went ahead and pushed a change to the repo illustrating the .env change.

Thanks a lot for the quick answer! I actually tried the extra_hosts section in docker-compose.yml but didn't realize it was for building (not at runtime).

Unless there is something I don't know, I don't think you can put the extra_hosts in the .env file. See merge request here that worked for me: https://github.com/mcoia/eg-docker/pull/19.

Side note: I had to disable docker buildx as it was reaching the maximum output log size (error was [output clipped, log limit 1MiB reached]). Suggestion: reduce Ansible log level (at least in the non-dev folder).