Skip to content

Commit 5fc43a4

Browse files
author
brendan
committed
Delaying after Jenkins is contactable, as get 503 errors if attempt to reload immediately. Adding curl for troubleshooting.
1 parent f62a28a commit 5fc43a4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.circleci/test-in-cluster.sh

100755100644
File mode changed.

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ RUN pip install -r requirements.txt
55
RUN groupadd -r -g 1000 jenkins && useradd -r -u 1000 -g jenkins jenkins
66
USER root
77
RUN chown -R jenkins:jenkins /app
8+
RUN apt-get update && apt-get install -y curl
89
COPY sidecar/* ./
910
RUN chmod 700 /app
1011
ENV PYTHONUNBUFFERED=1
1112
USER jenkins
12-
CMD [ "python", "-u", "/app/sidecar.py" ]
13+
CMD [ "python", "-u", "/app/sidecar.py" ]

sidecar/sidecar.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os, logging, sys
1+
import os, logging, sys, socket, time
22
from kubernetes import client, config
33

44
from resources import listResources, watchForChanges
@@ -59,6 +59,18 @@ def main():
5959
listResources(label, targetFolder, url, method, payload,
6060
namespace, folderAnnotation, res, logger)
6161
else:
62+
host = '127.0.0.1'
63+
while True:
64+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
65+
try:
66+
s.connect((host, 8080))
67+
time.sleep(12)
68+
logger.info("Jenkins is contactable, continuing.")
69+
break
70+
except Exception:
71+
logging.info("Jenkins is not up yet. Waiting...")
72+
time.sleep(5)
73+
s.close()
6274
watchForChanges(label, targetFolder, url, method,
6375
payload, namespace, folderAnnotation, resources, logger)
6476

0 commit comments

Comments
 (0)