Skip to content

Commit f65016e

Browse files
authored
Merge pull request #61 from bart0sh/PR001-demo-handle-SIGTERM
demos: handle SIGTERM to avoid long termination
2 parents 8cc427a + cdcab0c commit f65016e

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

demo/gpu-test1.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
- name: ctr0
3434
image: ubuntu:22.04
3535
command: ["bash", "-c"]
36-
args: ["export; sleep 9999"]
36+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
3737
resources:
3838
claims:
3939
- name: gpu
@@ -54,7 +54,7 @@ spec:
5454
- name: ctr0
5555
image: ubuntu:22.04
5656
command: ["bash", "-c"]
57-
args: ["export; sleep 9999"]
57+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
5858
resources:
5959
claims:
6060
- name: gpu

demo/gpu-test2.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ spec:
3535
- name: ctr0
3636
image: ubuntu:22.04
3737
command: ["bash", "-c"]
38-
args: ["export; sleep 9999"]
38+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
3939
resources:
4040
claims:
4141
- name: gpus

demo/gpu-test3.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ spec:
3131
- name: ctr0
3232
image: ubuntu:22.04
3333
command: ["bash", "-c"]
34-
args: ["export; sleep 9999"]
34+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
3535
resources:
3636
claims:
3737
- name: shared-gpu
3838
- name: ctr1
3939
image: ubuntu:22.04
4040
command: ["bash", "-c"]
41-
args: ["export; sleep 9999"]
41+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
4242
resources:
4343
claims:
4444
- name: shared-gpu

demo/gpu-test4.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
- name: ctr0
3333
image: ubuntu:22.04
3434
command: ["bash", "-c"]
35-
args: ["export; sleep 9999"]
35+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
3636
resources:
3737
claims:
3838
- name: shared-gpu
@@ -53,7 +53,7 @@ spec:
5353
- name: ctr0
5454
image: ubuntu:22.04
5555
command: ["bash", "-c"]
56-
args: ["export; sleep 9999"]
56+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
5757
resources:
5858
claims:
5959
- name: shared-gpu

demo/gpu-test5.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,31 @@ spec:
5454
- name: ts-ctr0
5555
image: ubuntu:22.04
5656
command: ["bash", "-c"]
57-
args: ["export; sleep 9999"]
57+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
5858
resources:
5959
claims:
6060
- name: shared-gpus
6161
request: ts-gpu
6262
- name: ts-ctr1
6363
image: ubuntu:22.04
6464
command: ["bash", "-c"]
65-
args: ["export; sleep 9999"]
65+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
6666
resources:
6767
claims:
6868
- name: shared-gpus
6969
request: ts-gpu
7070
- name: sp-ctr0
7171
image: ubuntu:22.04
7272
command: ["bash", "-c"]
73-
args: ["export; sleep 9999"]
73+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
7474
resources:
7575
claims:
7676
- name: shared-gpus
7777
request: sp-gpu
7878
- name: sp-ctr1
7979
image: ubuntu:22.04
8080
command: ["bash", "-c"]
81-
args: ["export; sleep 9999"]
81+
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
8282
resources:
8383
claims:
8484
- name: shared-gpus

test/e2e/e2e.sh

+8
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ if [ $gpu_test_5 != 1 ]; then
6363
exit 1
6464
fi
6565

66+
# test that deletion is fast (less than the default grace period of 30s)
67+
# see https://github.com/kubernetes/kubernetes/issues/127188 for details
68+
kubectl delete -f demo/gpu-test1.yaml --timeout=25s
69+
kubectl delete -f demo/gpu-test2.yaml --timeout=25s
70+
kubectl delete -f demo/gpu-test3.yaml --timeout=25s
71+
kubectl delete -f demo/gpu-test4.yaml --timeout=25s
72+
kubectl delete -f demo/gpu-test5.yaml --timeout=25s
73+
6674
echo "test ran successfully"

0 commit comments

Comments
 (0)