Skip to content

Commit a211a30

Browse files
authored
Merge pull request #2580 from 89luca89/fix_restart_alpine
fix: make restart script compatible with non-GNU userlands
2 parents b7014db + c74d784 commit a211a30

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

e2e/tests/replacepods/replacepods.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ var _ = DevSpaceDescribe("replacepods", func() {
6868
}()
6969

7070
// check if file is there
71-
framework.ExpectRemoteFileContents("ubuntu", ns, "/app/test2.txt", "Hello World 123")
71+
framework.ExpectRemoteFileContents("alpine", ns, "/app/test2.txt", "Hello World 123")
7272

7373
// check if file is there
74-
framework.ExpectRemoteFileContents("ubuntu", ns, "/test.txt", "Hello World\n")
74+
framework.ExpectRemoteFileContents("alpine", ns, "/test.txt", "Hello World\n")
7575

7676
// upload a file and restart the container
7777
err = os.WriteFile("test1.txt", []byte("Hello World2!"), 0777)
7878
framework.ExpectNoError(err)
7979

8080
// wait for uploaded
81-
framework.ExpectRemoteFileContents("ubuntu", ns, "/app/test1.txt", "Hello World2!")
81+
framework.ExpectRemoteFileContents("alpine", ns, "/app/test1.txt", "Hello World2!")
8282

8383
// wait for restarted
84-
framework.ExpectRemoteFileContents("ubuntu", ns, "/test.txt", "Hello World\nHello World\n")
84+
framework.ExpectRemoteFileContents("alpine", ns, "/test.txt", "Hello World\nHello World\n")
8585

8686
cancel()
8787
err = <-done

e2e/tests/replacepods/testdata/restart-helper/devspace.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ name: attach
44
pipelines:
55
dev:
66
run: |-
7-
create_deployments test --set helm.values.containers[0].image=ubuntu
8-
9-
start_dev test --set imageSelector=ubuntu \
7+
create_deployments test --set helm.values.containers[0].image=alpine
8+
9+
start_dev test --set imageSelector=alpine \
1010
--set 'command={sh,-c,echo Hello World >> /test.txt; sleep 100000}' \
1111
--set logs.enabled=true \
1212
--set sync[0].path=.:/app \

pkg/devspace/build/builder/restart/restart.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ quit() {
5454
if [ -f "$pidFile" ]; then
5555
pidToKill="$(cat $pidFile)"
5656
kill -2 $((0-$pidToKill)) >/dev/null 2>&1
57-
timeout 5 tail --pid=$pidToKill -f /dev/null 2>&1
57+
timeout 5 sh -c "while [ -e /proc/$pidToKill ]; do sleep 1; done"
5858
kill -15 $((0-$pidToKill)) >/dev/null 2>&1
59-
timeout 5 tail --pid=$pidToKill -f /dev/null 2>&1
59+
timeout 5 sh -c "while [ -e /proc/$pidToKill ]; do sleep 1; done"
6060
kill -9 $((0-$pidToKill)) >/dev/null 2>&1
61-
timeout 5 tail --pid=$pidToKill -f /dev/null 2>&1
61+
timeout 5 sh -c "while [ -e /proc/$pidToKill ]; do sleep 1; done"
6262
fi
6363
6464
if [ -f "$ppidFile" ]; then
@@ -104,7 +104,16 @@ while $restart; do
104104
pid="$(cat $pidFile)"
105105
106106
screen -q -S "${sid}" -X colon "logfile flush 1^M"
107-
tail --pid=$pid -f "$screenLogFile"
107+
108+
tail -f "$screenLogFile" &
109+
tailPid=$!
110+
# This is a workaround on tail --pid not supported in all
111+
# minimal shells
112+
while [ -e /proc/$pid ]; do
113+
# Until $pid exist, let's wait
114+
sleep 1
115+
done
116+
kill $tailPid
108117
else
109118
setsid "$@" &
110119
pid=$!

0 commit comments

Comments
 (0)