Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit 45cfd91

Browse files
committed
v2.46.0-04: Fix bug while docker stop ; supervisor not getting SIGINT properly
1 parent a1c93db commit 45cfd91

File tree

7 files changed

+86
-63
lines changed

7 files changed

+86
-63
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ Note sha256 digests are generated after pushing the image to the registry theref
44

55
Note image ids also change after scm-source.json has being updated which triggers a cyclic problem so value TBD will be set here and updated in the [release][] page by navigating into any release tag.
66

7-
## v2.46.0-03 (2015-07-18)
7+
## v2.46.0-04 (2015-07-18)
88
+ Fix bug openbox X manager not waiting for Xvfb. (Leo Gallucci)
99
+ Fix entry.sh exiting immediately and not checking DISABLE_ROLLBACK.
1010
+ Allow to choose X manager flavor via `-e XMANAGER=openbox|fluxbox`
11+
+ Fix bug in wait-docker-selenium.sh
12+
+ Fix bug while docker stop $NAME; supervisor not getting SIGINT properly.
1113
+ Image tag details:
1214
+ Selenium: v2.46.0 (87c69e2)
1315
+ Chrome stable: 43.0.2357.134
@@ -23,8 +25,8 @@ Note image ids also change after scm-source.json has being updated which trigger
2325
+ Built with: Docker version 1.7.1, build 786b29d
2426
+ FROM ubuntu:wily-20150708
2527
+ Python: 2.7.10
26-
+ Digest: sha256:7839b7e1a84471352f135815d55f4f9835c54e23e9555c2e5d5d818910c429fb
27-
+ Image ID: 6763523b770c6504b381231b499e4e71fccd440c86bc83aff1e207c23a5327a3
28+
+ Digest: sha256:TBD
29+
+ Image ID: TBD
2830

2931
## v2.46.0-02 (2015-07-17)
3032
+ Add DISABLE_ROLLBACK so when true users can troubleshoot. (Leo Gallucci)

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ ENV FIREFOX_VERSIONS="${FIREFOX_VERSIONS1}, ${FIREFOX_VERSIONS2}, ${FIREFOX_VERS
704704
VIDEO_FILE_EXTENSION="mkv" \
705705
VIDEO_FILE_NAME="test" \
706706
VIDEOS_DIR="${NORMAL_USER_HOME}/videos" \
707+
FLUSH_VIDEO_SECS="0.5" \
707708
# You can choose what X manager to use
708709
XMANAGER="fluxbox" \
709710
#===============================

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Note SeleniumHQ/docker-selenium project is more useful for building selenium gri
1919
In general: add `sudo` only if needed in your environment and `--privileged` if you really need it.
2020

2121
sudo docker run --privileged -p 4444:24444 -p 5920:25900 \
22-
-e VNC_PASSWORD=hola elgalu/selenium:v2.46.0-03
22+
-e VNC_PASSWORD=hola elgalu/selenium:v2.46.0-04
2323

2424
### Non-privileged
2525
### Run
@@ -31,7 +31,7 @@ If your setup is correct, privileged mode and sudo should not be necessary:
3131
-e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1080 \
3232
-e VNC_PASSWORD=hola \
3333
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" \
34-
elgalu/selenium:v2.46.0-03
34+
elgalu/selenium:v2.46.0-04
3535

3636
Make sure `docker run` finishes with **selenium all done and ready for testing** else you won't be able to start your tests. To perform this check programatically please use this command where `ch` is the name of the container:
3737

@@ -96,7 +96,7 @@ You can lunch a grid only container via environment variables:
9696

9797
docker run --rm --name=hub -p 4444:24444 -p 5930:25900 -p 2223:22222 \
9898
-p=6081:26080 -e CHROME=false -e FIREFOX=false \
99-
elgalu/selenium:v2.46.0-03
99+
elgalu/selenium:v2.46.0-04
100100

101101
The important part above is `-e CHROME=false -e FIREFOX=false` which tells the docker image not run run default chorme and firefox nodes turning the container into a grid-only one.
102102

@@ -112,7 +112,7 @@ You can lunch a node only container via environment variables:
112112
-p 25550:25550 -p 25551:25551 \
113113
-e GRID=false -e CHROME=true -e FIREFOX=true \
114114
-v $(pwd)/videos:/videos \
115-
elgalu/selenium:v2.46.0-03
115+
elgalu/selenium:v2.46.0-04
116116

117117
The important part above is `-e GRID=false` which tells the container to be a node-only node, this this case with 2 browsers `-e CHROME=true -e FIREFOX=true` but could be just 1.
118118

@@ -136,17 +136,17 @@ There are also additional steps you can take to ensure you're using the correct
136136
### Option 1 - Use immutable image digests
137137
Given docker.io currently allows to push the same tag image twice this represent a security concern but since docker >= 1.6.2 is possible to fetch the digest sha256 instead of the tag so you can be sure you're using the exact same docker image every time:
138138

139-
# e.g. sha256 for tag v2.46.0-03
140-
export SHA=7839b7e1a84471352f135815d55f4f9835c54e23e9555c2e5d5d818910c429fb
139+
# e.g. sha256 for tag v2.46.0-04
140+
export SHA=TBD
141141
docker pull elgalu/selenium@sha256:${SHA}
142142

143143
### Option 2 - Check the Full Image Id
144144

145145
Verify that image id is indeed correct
146146

147-
# e.g. full image id for tag v2.46.0-03
148-
export IMGID=6763523b770c6504b381231b499e4e71fccd440c86bc83aff1e207c23a5327a3
149-
if docker inspect -f='{{.Id}}' elgalu/selenium:v2.46.0-03 |grep ${IMGID} &> /dev/null; then
147+
# e.g. full image id for tag v2.46.0-04
148+
export IMGID=TBD
149+
if docker inspect -f='{{.Id}}' elgalu/selenium:v2.46.0-04 |grep ${IMGID} &> /dev/null; then
150150
echo "Image ID tested ok"
151151
else
152152
echo "Image ID doesn't match"
@@ -168,7 +168,7 @@ Host machine, terminal 2:
168168
docker run --rm --name=ch -p=4470:24444 \
169169
-e SCREEN_WIDTH -e SCREEN_HEIGHT -e XE_DISP_NUM \
170170
-v /tmp/.X11-unix/X${XE_DISP_NUM}:/tmp/.X11-unix/X${XE_DISP_NUM} \
171-
elgalu/selenium:v2.46.0-03
171+
elgalu/selenium:v2.46.0-04
172172

173173
Now when you run your tests instead of connecting. If docker run fails try `xhost +`
174174

@@ -190,7 +190,7 @@ ANYPORT=0
190190
REMOTE_DOCKER_SRV=localhost
191191
CONTAINER=$(docker run -d -p=0.0.0.0:${ANYPORT}:22222 -p=0.0.0.0:${ANYPORT}:24444 \
192192
-p=0.0.0.0:${ANYPORT}:25900 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola \
193-
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:v2.46.0-03
193+
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:v2.46.0-04
194194
195195
# -- Option 2.docker run- Running docker on remote docker server like in the cloud
196196
# Useful if the docker server is running in the cloud. Establish free local ports
@@ -200,7 +200,7 @@ ssh ${REMOTE_DOCKER_SRV} #get into the remote docker provider somehow
200200
# it acts as a jump host so my public key is already on that server
201201
CONTAINER=$(docker run -d -p=0.0.0.0:${ANYPORT}:22222 -e SCREEN_HEIGHT=1110 \
202202
-e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" \
203-
elgalu/selenium:v2.46.0-03
203+
elgalu/selenium:v2.46.0-04
204204
205205
# -- Common: Wait for the container to start
206206
./host-scripts/wait-docker-selenium.sh ch 7s
@@ -271,7 +271,7 @@ If you git clone this repo locally, i.e. cd into where the Dockerfile is, you ca
271271
272272
If you prefer to download the final built image from docker you can pull it, personally I always prefer to build them manually except for the base images like Ubuntu 14.04.2:
273273
274-
docker pull elgalu/selenium:v2.46.0-03
274+
docker pull elgalu/selenium:v2.46.0-04
275275
276276
#### 2. Use this image
277277

READMELeo.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
## Build
22

3-
time (docker build -t="elgalu/selenium:v2.46.0-03" . ;echo $?;beep)
4-
docker run --rm -ti --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -p=6080:26080 -p=29001:29001 -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" -v $(pwd)/videos:/videos -e DISABLE_ROLLBACK=true -e CHROME_FLAVOR=unstable -e FIREFOX_VERSION=38.0.6 -e VIDEO=true -e VIDEO_FILE_NAME=hola elgalu/selenium:v2.46.0-03
3+
time (docker build -t="elgalu/selenium:v2.46.0-04" . ;echo $?;beep)
4+
docker run --rm -ti --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -p=6080:26080 -p=29001:29001 -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" -v $(pwd)/videos:/videos -e DISABLE_ROLLBACK=true -e CHROME_FLAVOR=unstable -e FIREFOX_VERSION=38.0.6 -e VIDEO=true -e VIDEO_FILE_NAME=hola elgalu/selenium:v2.46.0-04
55

66
See logs
77

88
docker exec -ti ch bash -c "ls -lah /var/log/sele/"
99

1010
Testing in ssh [email protected]
1111

12-
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" -e VNC_PASSWORD=Hola3 os-registry.stups.zalan.do/tip/selenium:v2.46.0-03
12+
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -p=2222:22222 -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" -e VNC_PASSWORD=Hola3 os-registry.stups.zalan.do/tip/selenium:v2.46.0-04
1313

1414
## Transfer used browser source artifacts to keep them in the cloud
1515

@@ -32,18 +32,18 @@ List firefox versions via docker exe
3232

3333
## To update image id and digest
3434

35-
docker inspect -f='{{.Id}}' elgalu/selenium:v2.46.0-03
35+
docker inspect -f='{{.Id}}' elgalu/selenium:v2.46.0-04
3636
docker images --digests
3737

3838
## Run with shared dir
3939

4040
docker run --rm --name=ch -p=127.0.0.1:4460:24444 -p=127.0.0.1:5910:25900 \
41-
-v /e2e/uploads:/e2e/uploads elgalu/selenium:v2.46.0-03
41+
-v /e2e/uploads:/e2e/uploads elgalu/selenium:v2.46.0-04
4242
docker run --rm --name=ch -p=4460:24444 -p=5910:25900 \
43-
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) elgalu/selenium:v2.46.0-03
43+
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) elgalu/selenium:v2.46.0-04
4444

4545

46-
docker run --rm --name=ff -p=127.0.0.1:4461:24444 -p=127.0.0.1:5911:25900 -v /e2e/uploads:/e2e/uploads elgalu/selenium:v2.46.0-03
46+
docker run --rm --name=ff -p=127.0.0.1:4461:24444 -p=127.0.0.1:5911:25900 -v /e2e/uploads:/e2e/uploads elgalu/selenium:v2.46.0-04
4747

4848
## Run without shared dir and bind ports to all network interfaces
4949

@@ -66,11 +66,11 @@ List firefox versions via docker exe
6666
## Run without dir and bind to all interfaces
6767
Note anything after the image will be taken as arguments for the cmd/entrypoint
6868

69-
docker run --rm --name=ch -p=0.0.0.0:8813:8484 -p=0.0.0.0:2222:2222 -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 -e SCREEN_WIDTH=1800 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:v2.46.0-03
69+
docker run --rm --name=ch -p=0.0.0.0:8813:8484 -p=0.0.0.0:2222:2222 -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 -e SCREEN_WIDTH=1800 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:v2.46.0-04
7070

71-
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola elgalu/selenium:v2.46.0-03
72-
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola docker.io/elgalu/selenium:v2.46.0-03
73-
docker run --rm --name=ch -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 --add-host myserver.dev:172.17.42.1 elgalu/selenium:v2.46.0-03
71+
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola elgalu/selenium:v2.46.0-04
72+
docker run --rm --name=ch -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola docker.io/elgalu/selenium:v2.46.0-04
73+
docker run --rm --name=ch -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 --add-host myserver.dev:172.17.42.1 elgalu/selenium:v2.46.0-04
7474

7575
However adding a custom host IP to server-selenium.local (e.g. bsele ssh config) is more work:
7676

@@ -79,32 +79,32 @@ However adding a custom host IP to server-selenium.local (e.g. bsele ssh config)
7979

8080
vncv localhost:5920 -Scaling=60% &
8181

82-
docker run --rm --name=ff -p=0.0.0.0:4471:24444 -p=0.0.0.0:5921:25900 elgalu/selenium:v2.46.0-03
82+
docker run --rm --name=ff -p=0.0.0.0:4471:24444 -p=0.0.0.0:5921:25900 elgalu/selenium:v2.46.0-04
8383

8484
Automatic builds not working for me right now, maybe there is an issue with docker registry v1 vs v2
8585
https://registry.hub.docker.com/u/elgalu/docker-selenium/builds_history/31621/
8686

8787
## Push version
8888

8989
docker login
90-
docker push docker.io/elgalu/selenium:v2.46.0-03 ;echo $?;beep
91-
docker tag elgalu/selenium:v2.46.0-03 elgalu/selenium:latest
90+
docker push docker.io/elgalu/selenium:v2.46.0-04 ;echo $?;beep
91+
docker tag elgalu/selenium:v2.46.0-04 elgalu/selenium:latest
9292
docker push docker.io/elgalu/selenium:latest
9393

9494
Not working maybe because it has automated builds enabled but then it fails in the cloud but works locally
9595
https://registry.hub.docker.com/u/elgalu/selenium/tags/manage/
9696

97-
docker push elgalu/selenium:v2.46.0-03
98-
docker push elgalu/docker-selenium:v2.46.0-03
99-
docker push docker.io/elgalu/docker-selenium:v2.46.0-03
97+
docker push elgalu/selenium:v2.46.0-04
98+
docker push elgalu/docker-selenium:v2.46.0-04
99+
docker push docker.io/elgalu/docker-selenium:v2.46.0-04
100100

101101
## Pulling
102102

103-
docker pull registry.hub.docker.com/elgalu/selenium:v2.46.0-03
103+
docker pull registry.hub.docker.com/elgalu/selenium:v2.46.0-04
104104

105105
## Pull
106106

107-
docker run -d --name=max -p=0.0.0.0:4411:24444 -p=0.0.0.0:5911:25900 elgalu/selenium:v2.46.0-03
107+
docker run -d --name=max -p=0.0.0.0:4411:24444 -p=0.0.0.0:5911:25900 elgalu/selenium:v2.46.0-04
108108

109109
How to connect through vnc (need a vnc client)
110110

bin/entry.sh

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,42 +69,21 @@ if [ $WHOAMI_EXIT_CODE != 0 ]; then
6969
echo "-- INFO: Will try to fix uid before continuing"
7070
# TODO: fix it ...
7171
echo "-- now will try to use NORMAL_USER: '$NORMAL_USER' to continue"
72-
${RUN_PREFIX} run-supervisord.sh
72+
exec ${RUN_PREFIX} run-supervisord.sh
7373
else
7474
echo "-- WARN: You seem to be running docker -u {{some-non-existing-user-in-container}}"
7575
echo "-- will try to use NORMAL_USER: '$NORMAL_USER' instead."
76-
${RUN_PREFIX} run-supervisord.sh
76+
exec ${RUN_PREFIX} run-supervisord.sh
7777
fi
7878
elif [ "$WHOAMI" = "root" ]; then
7979
echo "-- WARN: Container running user is 'root' so switching to less privileged one"
8080
echo "-- will use NORMAL_USER: '$NORMAL_USER' instead."
81-
${RUN_PREFIX} run-supervisord.sh
81+
exec ${RUN_PREFIX} run-supervisord.sh
8282
else
8383
echo "-- INFO: Will use \$USER '$USER' and \$(whoami) is '$WHOAMI'"
84-
run-supervisord.sh
84+
exec run-supervisord.sh
8585
fi
8686

87-
# when DISABLE_ROLLBACK=true it will:
88-
# - output logs
89-
# - exec bash to permit troubleshooting
90-
if [ "$(cat ${DOCKER_SELENIUM_STATUS})" = "failed" ]; then
91-
tail /var/log/sele/*
92-
echo "" && echo "" && echo "==> errors <=="
93-
selenium-grep.sh
94-
95-
if [ "${DISABLE_ROLLBACK}" = "true" ]; then
96-
echo ""
97-
echo "DEBUGGING: to find out what happened please analyze logs or run"
98-
echo " selenium-grep.sh"
99-
echo ""
100-
101-
exec bash
102-
fi
103-
fi
104-
105-
# tells bash to wait until child processes have exited
106-
# wait
107-
10887
# Note: sudo -i creates a login shell for someUser, which implies the following:
10988
# - someUser's user-specific shell profile, if defined, is loaded.
11089
# - $HOME points to someUser's home directory, so there's no need for -H (though you may still specify it)

supervisor/bin/run-supervisord.sh

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
11
#!/usr/bin/env bash
22

3-
supervisord -c /etc/supervisor/supervisord.conf
3+
# Exit all child processes properly
4+
function shutdown {
5+
echo "Trapped SIGTERM/SIGINT/x so shutting down supervisord gracefully..."
6+
# First stop video recording because it needs some time to flush it
7+
(supervisorctl -c /etc/supervisor/supervisord.conf stop \
8+
video-rec && sleep ${FLUSH_VIDEO_SECS}) || true
9+
supervisorctl -c /etc/supervisor/supervisord.conf stop all
10+
# kill -SIGTERM $(cat ${SUPERVISOR_PIDFILE})
11+
kill -SIGTERM ${SUPERVISOR_PID}
12+
wait
13+
14+
# when DISABLE_ROLLBACK=true it will:
15+
# - output logs
16+
# - exec bash to permit troubleshooting
17+
if [ "$(cat ${DOCKER_SELENIUM_STATUS})" = "failed" ]; then
18+
tail /var/log/sele/*
19+
echo "" && echo "" && echo "==> errors <=="
20+
selenium-grep.sh
21+
22+
if [ "${DISABLE_ROLLBACK}" = "true" ]; then
23+
echo ""
24+
echo "DEBUGGING: to find out what happened please analyze logs or run"
25+
echo " selenium-grep.sh"
26+
echo ""
27+
28+
exec bash
29+
else
30+
exit 3
31+
fi
32+
else
33+
exit 0
34+
fi
35+
}
36+
37+
supervisord -c /etc/supervisor/supervisord.conf &
38+
SUPERVISOR_PID=$!
39+
40+
# Run function shutdown() when this process a killer signal
41+
trap shutdown SIGTERM SIGINT SIGKILL
42+
43+
# tells bash to wait until child processes have exited
44+
wait

video-rec/bin/start-video-rec.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ VID_TOOL_PID=$!
2828
function shutdown {
2929
echo "Trapped SIGTERM or SIGINT so shutting down ffmpeg gracefully..."
3030
sudo kill -SIGINT ${VID_TOOL_PID}
31-
sleep 0.7 #wait so the file is flushed
31+
sleep ${FLUSH_VIDEO_SECS}
3232
# sudo killall -SIGINT avconv
3333
sudo killall -SIGINT ffmpeg
34-
sleep 0.3 #wait so the file is flushed
34+
sleep ${FLUSH_VIDEO_SECS}
3535
echo "ffmpeg shutdown complete."
3636
exit 0
3737
}

0 commit comments

Comments
 (0)