fabric8-services / fabric8-tenant-jenkins

Generates Jenkins tenant namespace YAML
Apache License 2.0
2 stars 14 forks source link

Add content-repository boot dependency to Jenkins #91

Closed concaf closed 6 years ago

concaf commented 6 years ago

This commit adds a hard dependency on the Jenkins deployment such that Jenkins will not be brought up unless content-repository is not up and running.

This is done by adding init containers to the Jenkins' Kubernetes Deployment files which check every 2 seconds if content-repository is up or not. The check is set to timeout at 2 seconds. Once the check returns a 0 exit code and the init container exits, only then the Jenkins pod is brought up.

concaf commented 6 years ago

This should fix https://github.com/openshiftio/openshift.io/issues/3469

fabric8cd commented 6 years ago

PR now available for testing: Launch in OpenShift.io and click the update tenant button

concaf commented 6 years ago

ping @jaseemabid @rupalibehera

jfchevrette commented 6 years ago

Very clever. Do you know if the init container will timeout after some time? Let's say the content-repository deployment never comes up for some reason...

jfchevrette commented 6 years ago

Something like this may be better so it eventually times

for i in {1..100}; do sleep 1; if curl... ; then exit 0; fi; done; exit 1
concaf commented 6 years ago

@jfchevrette makes sense, trying with for i in {1..100}; do sleep 1; if curl -L -m 4 content-repository; then exit 0; else echo waiting for content-repository ...; fi; done; exit 1

fabric8cd commented 6 years ago

PR now available for testing: Launch in OpenShift.io and click the update tenant button

concaf commented 6 years ago

This works for me, would help if more folks can test this out to move forward with this -

Steps to test -

  1. Idle both content-repository and jenkins oc idle jenkins content-repository
  2. Send a request to Jenkins route - curl -L jenkins-username-jenkins.xyz.openshiftapps.com
  3. Wait for the :tada:, Jenkins pod will start the init container which will generate traffic to content-repository which will be unidled. Once content-repository is up, the init container will go down and Jenkins will be started.
piyush-garg commented 6 years ago

Patch looks good to me, works for me.

hrishin commented 6 years ago

It worked for me. 3 trials : 3 success, 0 failed

rupalibehera commented 6 years ago

@containscafeine I added my observations here https://github.com/openshiftio/openshift.io/issues/3469#issuecomment-387064855, I can merge this is PR, let me know if you don't have the merge rights.

jfchevrette commented 6 years ago

LGTM

ldimaggi commented 6 years ago

Looks good here too!

rupalibehera commented 6 years ago

https://github.com/openshiftio/saas-openshiftio/pull/874 PR raised to deploy to prod