Skip to content

Commit d3c5aab

Browse files
committed
initial delay
1 parent 18aa10b commit d3c5aab

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

bindata/assets/deployments/downloads-deployment.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ spec:
4545
periodSeconds: 10
4646
successThreshold: 1
4747
failureThreshold: 3
48+
initialDelaySeconds: 5
4849
name: download-server
4950
securityContext:
5051
readOnlyRootFilesystem: false
@@ -63,6 +64,7 @@ spec:
6364
periodSeconds: 10
6465
successThreshold: 1
6566
failureThreshold: 3
67+
initialDelaySeconds: 5
6668
ports:
6769
- name: http
6870
containerPort: 8080
@@ -78,6 +80,8 @@ spec:
7880
7981
signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0))
8082
83+
ready = threading.Event()
84+
8185
def write_index(path, message):
8286
with open(path, 'wb') as f:
8387
f.write('\n'.join([
@@ -112,7 +116,8 @@ spec:
112116
# https://stackoverflow.com/questions/46210672/
113117
httpd.socket = self.socket
114118
httpd.server_bind = self.server_close = lambda self: None
115-
119+
if self.i == 0:
120+
ready.set()
116121
httpd.serve_forever()
117122
118123
temp_dir = tempfile.mkdtemp()
@@ -186,12 +191,13 @@ spec:
186191
addr = ('', 8080)
187192
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
188193
else:
189-
raise
194+
raise
190195
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
191196
sock.bind(addr)
192197
sock.listen(5)
193198
194199
[Thread(i, socket=sock) for i in range(100)]
200+
ready.wait()
195201
time.sleep(9e9)
196202
EOF
197203
exec python3 /tmp/serve.py

pkg/console/subresource/deployment/deployment_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,11 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
15291529
Scheme: corev1.URIScheme("HTTP"),
15301530
},
15311531
},
1532-
TimeoutSeconds: 1,
1533-
PeriodSeconds: 10,
1534-
SuccessThreshold: 1,
1535-
FailureThreshold: 3,
1532+
TimeoutSeconds: 1,
1533+
PeriodSeconds: 10,
1534+
SuccessThreshold: 1,
1535+
FailureThreshold: 3,
1536+
InitialDelaySeconds: 5,
15361537
},
15371538
LivenessProbe: &corev1.Probe{
15381539
ProbeHandler: corev1.ProbeHandler{
@@ -1542,10 +1543,11 @@ func TestDefaultDownloadsDeployment(t *testing.T) {
15421543
Scheme: corev1.URIScheme("HTTP"),
15431544
},
15441545
},
1545-
TimeoutSeconds: 1,
1546-
PeriodSeconds: 10,
1547-
SuccessThreshold: 1,
1548-
FailureThreshold: 3,
1546+
TimeoutSeconds: 1,
1547+
PeriodSeconds: 10,
1548+
SuccessThreshold: 1,
1549+
FailureThreshold: 3,
1550+
InitialDelaySeconds: 5,
15491551
},
15501552
Command: []string{"/bin/sh"},
15511553
Resources: corev1.ResourceRequirements{

0 commit comments

Comments
 (0)