Skip to content

Commit

Permalink
Add check for service to be ready also
Browse files Browse the repository at this point in the history
  • Loading branch information
piyush-garg committed Feb 8, 2019
1 parent d3fb745 commit 9e26b33
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions vars/deploy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def call(Map args = [:]) {
spawn(image: image) {
def userNS = usersNamespace();
def deployNS = userNS + "-" + args.env;
deployResource(deployNS, res.DeploymentConfig) {
deployResource(deployNS, res) {
tagImageToDeployEnv deployNS, userNS, res.ImageStream, tag
applyResources deployNS, res
}
Expand All @@ -69,11 +69,12 @@ def askForInput(String version, String environment, int duration) {
}
}

def deployResource(ns, dcs, body) {
pauseDeployments ns, dcs
def deployResource(ns, res, body) {
pauseDeployments ns, res.DeploymentConfig
body()
resumeDeployments ns, dcs
verifyDeployments ns, dcs
resumeDeployments ns, res.DeploymentConfig
verifyDeployments ns, res.DeploymentConfig
verifyServices ns, res.Service
}

def tagImageToDeployEnv(ns, userNamespace, imageStreams, tag) {
Expand Down Expand Up @@ -127,6 +128,7 @@ def verifyDeployments(ns, dcs) {
openshift.withProject("${ns}") {
def latestDeploymentVersion = openshift.selector('dc', "${dc.metadata.name}").object().status.latestVersion
def pods = openshift.selector('pods', [deployment: "${dc.metadata.name}-${latestDeploymentVersion}"])
echo "Waiting for deployment ${dc.metadata.name} to be ready"
pods.untilEach(1) {
it.object().status.containerStatuses.every {
it.ready
Expand All @@ -137,6 +139,18 @@ def verifyDeployments(ns, dcs) {
}
}

def verifyServices(ns, svcs) {
svcs.each { svc ->
openshift.withCluster() {
openshift.withProject() {
while (!openshift.verifyService(svc.metadata.name)) {
echo "Waiting for service ${svc.metadata.name} to be ready"
}
}
}
}
}

def annotateRoutes(ns, env, routes, version) {
if (!routes) {
return
Expand Down

0 comments on commit 9e26b33

Please sign in to comment.