Skip to content

Commit

Permalink
Delaying after Jenkins is contactable, as get 503 errors if attempt t…
Browse files Browse the repository at this point in the history
…o reload immediately. Adding curl for troubleshooting.
  • Loading branch information
brendan committed Nov 25, 2019
1 parent f62a28a commit 5fc43a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Empty file modified .circleci/test-in-cluster.sh
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ RUN pip install -r requirements.txt
RUN groupadd -r -g 1000 jenkins && useradd -r -u 1000 -g jenkins jenkins
USER root
RUN chown -R jenkins:jenkins /app
RUN apt-get update && apt-get install -y curl
COPY sidecar/* ./
RUN chmod 700 /app
ENV PYTHONUNBUFFERED=1
USER jenkins
CMD [ "python", "-u", "/app/sidecar.py" ]
CMD [ "python", "-u", "/app/sidecar.py" ]
14 changes: 13 additions & 1 deletion sidecar/sidecar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, logging, sys
import os, logging, sys, socket, time
from kubernetes import client, config

from resources import listResources, watchForChanges
Expand Down Expand Up @@ -59,6 +59,18 @@ def main():
listResources(label, targetFolder, url, method, payload,
namespace, folderAnnotation, res, logger)
else:
host = '127.0.0.1'
while True:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((host, 8080))
time.sleep(12)
logger.info("Jenkins is contactable, continuing.")
break
except Exception:
logging.info("Jenkins is not up yet. Waiting...")
time.sleep(5)
s.close()
watchForChanges(label, targetFolder, url, method,
payload, namespace, folderAnnotation, resources, logger)

Expand Down

0 comments on commit 5fc43a4

Please sign in to comment.