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

not working on alpine 3.10 with bash installed #71

Open
JoshuaC215 opened this issue Jul 21, 2019 · 17 comments · May be fixed by #81
Open

not working on alpine 3.10 with bash installed #71

JoshuaC215 opened this issue Jul 21, 2019 · 17 comments · May be fixed by #81

Comments

@JoshuaC215
Copy link

JoshuaC215 commented Jul 21, 2019

we use wait-for-it.sh heavily in CI for docker integration testing in golang. Recently a job broke due to wait-for-it.sh error. I believe the issue may have to do with something changing in timeout from alpine3.9 (works) to alpine 3.10 (not working). In both cases we were installing bash with apk.

Repro (note in vi I am copying wait-for-it from current master)

$ docker run -it --rm golang:1.12-alpine
/go # vi wait-for-it.sh
/go # chmod +x wait-for-it.sh 
/go # apk update && apk add --no-cache bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
v3.10.1-11-g89d0862481 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.1-12-ga885fe876c [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
OK: 10327 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.1_p20190518-r0)
(2/5) Installing ncurses-terminfo (6.1_p20190518-r0)
(3/5) Installing ncurses-libs (6.1_p20190518-r0)
(4/5) Installing readline (8.0.0-r0)
(5/5) Installing bash (5.0.0-r0)
Executing bash-5.0.0-r0.post-install
Executing busybox-1.30.1-r2.trigger
OK: 15 MiB in 20 packages
/go # ./wait-for-it.sh docker:5432
timeout: unrecognized option: t
BusyBox v1.30.1 (2019-06-12 17:51:55 UTC) multi-call binary.

Usage: timeout [-s SIG] SECS PROG ARGS

Runs PROG. Sends SIG to it if it is not gone in SECS seconds.
Default SIG: TERM.
wait-for-it.sh: timeout occurred after waiting 15 seconds for docker:5432

Workaround: I was able to work around this issue by installing coreutils as well which updates timeout (continuing from example above)

/go # apk update && apk add --no-cache coreutils
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
v3.10.1-11-g89d0862481 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.1-12-ga885fe876c [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
OK: 10327 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libacl (2.2.52-r6)
(2/3) Installing libattr (2.4.48-r0)
(3/3) Installing coreutils (8.31-r0)
Executing busybox-1.30.1-r2.trigger
OK: 16 MiB in 23 packages
/go # ./wait-for-it.sh -t 15 docker:5432
wait-for-it2.sh: waiting 15 seconds for docker:5432
wait-for-it2.sh: timeout occurred after waiting 15 seconds for docker:5432
@arthens
Copy link

arthens commented Jul 24, 2019

I can confirm the issue, we are getting the same problem.

@fr05t1k
Copy link

fr05t1k commented Aug 9, 2019

#68

@tillkuhn
Copy link

This breaking change in BusyBox ("timeout: fix arguments to match coreutils") seems to be the reason, I just ran into the same issue after our build image was updated to alpine:3.10

@TZK-
Copy link

TZK- commented Sep 20, 2019

Thanks for the workaround @JoshKCarroll
Works well by installing coreutils 😉

@YumaInaura
Copy link

  • I needs wait-for-it sh script changing
  • maybe it is bad if statement judge busybox

how to resolve ?

  • change if statement
  • ah maybe it is bad method...
  • if help include some text then enable -t option
/ # timeout --help 2>&1 | grep '\-t SECS'
Usage: timeout [-t SECS] [-s SIG] PROG ARGS

or Specify ENV and run script

WAITFORIT_BUSYTIMEFLAG="-t" wait-for-it.sh

and use it in wait-for-it.sh script without if else match in busybox.

@YumaInaura
Copy link

  • A Trouble log I found
  • probably same trouble as other people

e.g A docker image xueshanf/awscli

  • WAITFORIT_TIMEOUT_PATH has /bin/busybox
  • But timeout command does not have -t SEC option
  • Is this a trouble of only xueshanf/awscli image?
$ docker run -it --entrypoint= xueshanf/awscli bash
bash-5.0# WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
bash-5.0# WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
bash-5.0# echo $WAITFORIT_TIMEOUT_PATH
/bin/busybox
bash-5.0# timeout
BusyBox v1.30.1 (2019-06-12 17:51:55 UTC) multi-call binary.

Usage: timeout [-s SIG] SECS PROG ARGS

Runs PROG. Sends SIG to it if it is not gone in SECS seconds.
Default SIG: TERM.
bash-5.0#

trouble

  • it happens trouble in if statement in script
# check to see if timeout is from busybox?
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
        WAITFORIT_ISBUSY=1
        WAITFORIT_BUSYTIMEFLAG="-t"

else
        WAITFORIT_ISBUSY=0
        WAITFORIT_BUSYTIMEFLAG=""
fi

@YumaInaura
Copy link

YumaInaura commented Oct 14, 2019

directly change wait-for-it.sh

# check to see if timeout is from busybox?
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
        WAITFORIT_ISBUSY=1
        WAITFORIT_BUSYTIMEFLAG="-t"

else
        WAITFORIT_ISBUSY=0
        WAITFORIT_BUSYTIMEFLAG=""
fi

+ if [[ ! -z "${WAITFORIT_NO_BUSYTIMEFLAG}" ]]; then
+         WAITFORIT_BUSYTIMEFLAG=""
+ fi
WAITFORIT_NO_BUSYTIMEFLAG=1 wait-for-it.sh

@iturgeon
Copy link
Contributor

iturgeon commented Nov 4, 2019

Hopefully #81 solves this for you guys. The script still requires the use of bash on Alpine, but it should detect newer versions of BusyBox and deal with the updated flags appropriately.

@riptusk331
Copy link

Ran into this issue and confirming @JoshKCarroll's workaround (installing coreutils) works. The maintainer @vishnubob seems to have abandoned this project...no responses to issues, last commit over a year ago, and there are 25 pull requests...2 of which try to fix this problem.

we're on our own!

@Stratus3D
Copy link

I think you are right @riptusk331 . Is there a popular fork of this repo?

@robertp-indeed
Copy link

Ah, I opened another PR that fixes the issue (but doesn't preserve backwards compat, so @iturgeon's is better) because I didn't read existing issues closely enough first.

jhender added a commit to jhender/docker-polr that referenced this issue Nov 28, 2019
see issue vishnubob/wait-for-it#71
also reduced the wait time to 30seconds
thurt added a commit to thurt/demo-blog-platform that referenced this issue Jan 20, 2020
@xtrasimplicity
Copy link

@douglas-gibbons , @vishnubob - Any chance one of the PRs that patch this issue can be merged? Has this repo been abandoned? If so, would someone else here be able to take over maintenance?

Thanks!

@pascalandy
Copy link

Anyone have a dockerfile for alpine. Would love to try this using a docker run.

Cheers!

@gioamato
Copy link

@pascalandy
Copy link

Thanks @gioamato. If I understood:

a Dockerfile for alpine

# inspiration
FROM alpine:3.12

COPY wait-for-it.sh /usr/local/bin/wait-for-it

RUN set -eux &&\
  apk --update add --no-cache bash coreutils &&\
  chmod +x /usr/local/bin/wait-for-it

@gioamato
Copy link

@pascalandy exactly. I suggest you to install dependencies first and then copy wait-for-it as the last thing. Doing so you will not invalidate docker build layers if you update wait-for-it script (Ref.: https://docs.docker.com/develop/develop-images/dockerfile_best-practices)

@pascalandy
Copy link

Got it about the layer :-p

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

Successfully merging a pull request may close this issue.

14 participants