Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve localhost #21

Closed
ekho opened this issue Jan 16, 2020 · 13 comments
Closed

Cannot resolve localhost #21

ekho opened this issue Jan 16, 2020 · 13 comments

Comments

@ekho
Copy link

ekho commented Jan 16, 2020

export WAIT_HOST=localhost:3000
/wait && echo 'Ok' || echo 'Fail'

> Host localhost:3000 not yet available...

But

export WAIT_HOST=127.0.0.1:3000
/wait && echo 'Ok' || echo 'Fail'

> --------------------------------------------------------
 docker-compose-wait 2.7.2
---------------------------
Starting with configuration:
 - Hosts to be waiting for: [127.0.0.1:3000]
 - Timeout before failure: 30 seconds
 - TCP connection timeout before retry: 5 seconds
 - Sleeping time before checking for hosts availability: 0 seconds
 - Sleeping time once all hosts are available: 0 seconds
 - Sleeping time between retries: 1 seconds
--------------------------------------------------------
Checking availability of 127.0.0.1:3000
Host 127.0.0.1:3000 is now available!
--------------------------------------------------------
docker-compose-wait - Everything's fine, the application can now start!
--------------------------------------------------------
OK
@ufoscout
Copy link
Owner

@ekho
Releases 2.7.0 and 2.7.1 had this bug. This was fixed in 2.7.2, did you perform both the tests with this last version?

Here is my failed attempt to reproduce your bug:

With localhost:

$ WAIT_HOSTS=localhost:5432 ./wait && echo 'Ok' || echo 'Fail'
--------------------------------------------------------
 docker-compose-wait 2.7.2
---------------------------
Starting with configuration:
 - Hosts to be waiting for: [localhost:5432]
 - Timeout before failure: 30 seconds 
 - TCP connection timeout before retry: 5 seconds 
 - Sleeping time before checking for hosts availability: 0 seconds
 - Sleeping time once all hosts are available: 0 seconds
 - Sleeping time between retries: 1 seconds
--------------------------------------------------------
Checking availability of localhost:5432
Host localhost:5432 is now available!
--------------------------------------------------------
docker-compose-wait - Everything's fine, the application can now start!
--------------------------------------------------------
Ok

With 127.0.0.1:

$ WAIT_HOSTS=127.0.0.1:5432 ./wait && echo 'Ok' || echo 'Fail'
--------------------------------------------------------
 docker-compose-wait 2.7.2
---------------------------
Starting with configuration:
 - Hosts to be waiting for: [127.0.0.1:5432]
 - Timeout before failure: 30 seconds 
 - TCP connection timeout before retry: 5 seconds 
 - Sleeping time before checking for hosts availability: 0 seconds
 - Sleeping time once all hosts are available: 0 seconds
 - Sleeping time between retries: 1 seconds
--------------------------------------------------------
Checking availability of 127.0.0.1:5432
Host 127.0.0.1:5432 is now available!
--------------------------------------------------------
docker-compose-wait - Everything's fine, the application can now start!
--------------------------------------------------------
Ok

@ufoscout
Copy link
Owner

Uhm... no sorry, this was not the bug of 2.7.0 and 2.71. That was different.

Anyway, I am still not able to reproduce it.

@ekho
Copy link
Author

ekho commented Jan 16, 2020

docker run -d --rm -it --name=redmine redmine:3.4

docker exec -it redmine bash

apt-get update -qq && apt-get install -qqy curl net-tools

curl -fSL -o /wait https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.2/wait && chmod +x /wait

# Note: wait sometime while redmine is starting (~1 min)
netstat -lnptu
# Active Internet connections (only servers)
# Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
# tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      - 


WAIT_HOSTS=127.0.0.1:3000 /wait && echo 'Ok' || echo 'Fail'
#--------------------------------------------------------
# docker-compose-wait 2.7.2
#---------------------------
#Starting with configuration:
# - Hosts to be waiting for: [127.0.0.1:3000]
# - Timeout before failure: 30 seconds
# - TCP connection timeout before retry: 5 seconds
# - Sleeping time before checking for hosts availability: 0 seconds
# - Sleeping time once all hosts are available: 0 seconds
# - Sleeping time between retries: 1 seconds
#--------------------------------------------------------
#Checking availability of 127.0.0.1:3000
#Host 127.0.0.1:3000 is now available!
#--------------------------------------------------------
#docker-compose-wait - Everything's fine, the application can now start!
#--------------------------------------------------------
#Ok


WAIT_HOSTS=localhost:3000 /wait && echo 'Ok' || echo 'Fail'
#--------------------------------------------------------
# docker-compose-wait 2.7.2
#---------------------------
#Starting with configuration:
# - Hosts to be waiting for: [localhost:3000]
# - Timeout before failure: 30 seconds
# - TCP connection timeout before retry: 5 seconds
# - Sleeping time before checking for hosts availability: 0 seconds
# - Sleeping time once all hosts are available: 0 seconds
# - Sleeping time between retries: 1 seconds
#--------------------------------------------------------
#Checking availability of localhost:3000
#Host localhost:3000 not yet available...
#Host localhost:3000 not yet available...
#Host localhost:3000 not yet available...
#Host localhost:3000 not yet available...
#^C

@ufoscout
Copy link
Owner

@ekho
that's so strange, at first glance, I would say that it depends on the local network configuration.

Could you please try with telnet, something like telnet localhost 3000 and telnet 127.0.0.1 3000, and check if everything's working?

@ekho
Copy link
Author

ekho commented Jan 16, 2020

root@90d4de343afb:/usr/src/redmine# telnet 127.0.0.1 3000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
^]
telnet> Connection closed.

root@90d4de343afb:/usr/src/redmine# telnet localhost 3000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> Connection closed.

@ufoscout
Copy link
Owner

ufoscout commented Jan 16, 2020

Ok, sorry then, I really have no idea about this behavior.

The wait tool internally performs a simple call to the rust TCP client implementation, there is no manipulation of the domain name.

@ekho
Copy link
Author

ekho commented Jan 16, 2020

You can reproduce using my steps: #21 (comment)

@ekho
Copy link
Author

ekho commented Jan 16, 2020

It is not critical problem because I can use WAIT_HOST=127.0.0.1:3000

@ekho
Copy link
Author

ekho commented Jan 16, 2020

v2.6.0 has no this problem

@ekho
Copy link
Author

ekho commented Jan 16, 2020

root@90d4de343afb:/usr/src/redmine# curl -fSL -o /wait https://github.com/ufoscout/docker-compose-wait/releases/download/2.6.0/wait && chmod +x /wait
#  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#                                 Dload  Upload   Total   Spent    Left  Speed
#100   594    0   594    0     0   1682      0 --:--:-- --:--:-- --:--:--  1682
#100  269k  100  269k    0     0   204k      0  0:00:01  0:00:01 --:--:-- 1351k

root@90d4de343afb:/usr/src/redmine# WAIT_HOSTS=localhost:3000 /wait && echo 'Ok' || echo 'Fail'
#--------------------------------------------------------
#docker-compose-wait - starting with configuration:
# - Hosts to be waiting for: [localhost:3000]
# - Timeout before failure: 30 seconds
# - Sleeping time before checking for hosts availability: 0 seconds
# - Sleeping time once all hosts are available: 0 seconds
#--------------------------------------------------------
#Checking availability of localhost:3000
#Host localhost:3000 is now available!
#--------------------------------------------------------
#docker-compose-wait - Everything's fine, the application can now start!
#--------------------------------------------------------
#Ok

@ufoscout
Copy link
Owner

@ekho
I maybe have found something. Could you please check with version 2.7.3?

@ekho
Copy link
Author

ekho commented Jan 16, 2020

Yes. 2.7.3 fixes issue:

root@90d4de343afb:/usr/src/redmine# curl -fSL -o /wait https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait && chmod +x /wait
#  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#                                 Dload  Upload   Total   Spent    Left  Speed
#100   594    0   594    0     0   1503      0 --:--:-- --:--:-- --:--:--  1503
#100  269k  100  269k    0     0   194k      0  0:00:01  0:00:01 --:--:--  692k
root@90d4de343afb:/usr/src/redmine# WAIT_HOSTS=localhost:3000 /wait && echo 'Ok' || echo 'Fail'
#--------------------------------------------------------
# docker-compose-wait 2.7.3
#---------------------------
#Starting with configuration:
# - Hosts to be waiting for: [localhost:3000]
# - Timeout before failure: 30 seconds
# - TCP connection timeout before retry: 5 seconds
# - Sleeping time before checking for hosts availability: 0 seconds
# - Sleeping time once all hosts are available: 0 seconds
# - Sleeping time between retries: 1 seconds
#--------------------------------------------------------
#Checking availability of localhost:3000
#Host localhost:3000 is now available!
#--------------------------------------------------------
#docker-compose-wait - Everything's fine, the application can now start!
#--------------------------------------------------------
#Ok

@ufoscout
Copy link
Owner

@ekho
great.
Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants