From 50a5371ecd17f03089df1d2142b5479e86cd6479 Mon Sep 17 00:00:00 2001 From: Bryan Sullivan Date: Thu, 8 Feb 2018 18:08:32 -0800 Subject: Wait for homestead-prov to be deleted before redeploying JIRA: MODELS-2 Correct retrieval of node_port from cloudify Change-Id: Idf510667988050d586c72a4d8642aeb2803bef55 Signed-off-by: Bryan Sullivan --- tests/k8s-cloudify-clearwater.sh | 10 ++++++++++ tools/cloudify/k8s-cloudify.sh | 17 ++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/k8s-cloudify-clearwater.sh b/tests/k8s-cloudify-clearwater.sh index 9696b0b..133691f 100644 --- a/tests/k8s-cloudify-clearwater.sh +++ b/tests/k8s-cloudify-clearwater.sh @@ -137,6 +137,15 @@ kubectl cp $hpod:/usr/share/clearwater/bin/clearwater-socket-factory-sig-wrapper kubectl cp $hpod:/usr/share/clearwater/bin/clearwater-socket-factory-mgmt-wrapper ~/tmp/clearwater-socket-factory-mgmt-wrapper -c homestead kubectl delete deployment --namespace default homestead-prov kubectl delete service --namespace default homestead-prov + +hppod=$(kubectl get pods --namespace default | awk '/homestead-prov/ {print $1}') +while [[ "$hppod" != "" ]] ; do + echo "waiting 10 seconds for homestead-prov to be deleted..." + sleep 10 + hppod=$(kubectl get pods --namespace default | awk '/homestead-prov/ {print $1}') +done + +echo "Redeploying homestead-prov..." cd clearwater-docker/kubernetes kubectl apply -f homestead-prov-depl.yaml kubectl apply -f homestead-prov-svc.yaml @@ -147,6 +156,7 @@ while [[ "$hppod" == "null" ]] ; do sleep 10 hppod=$(kubectl get pods --namespace default | awk '/homestead-prov/ {print $1}') done + status=$(kubectl get pods -o json --namespace default $hppod | jq -r '.status.phase') while [[ "$status" != "Running" ]]; do echo; echo "$hppod is $status ... waiting 10 seconds" diff --git a/tools/cloudify/k8s-cloudify.sh b/tools/cloudify/k8s-cloudify.sh index 51d3558..b3780ae 100644 --- a/tools/cloudify/k8s-cloudify.sh +++ b/tools/cloudify/k8s-cloudify.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2017 AT&T Intellectual Property, Inc +# Copyright 2017-2018 AT&T Intellectual Property, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -268,20 +268,7 @@ function node_port() { while [[ "$nodePort" == "null" && $tries -gt 0 ]]; do curl -s -u admin:admin --header 'Tenant: default_tenant' \ -o ~/tmp/json http://$k8s_master/api/v3.1/node-instances - ni=$(jq -r '.items | length' ~/tmp/json) - while [[ $ni -ge 0 ]]; do - ((ni--)) - depid=$(jq -r ".items[$ni].deployment_id" ~/tmp/json) - type=$(jq -r ".items[$ni].runtime_properties.kubernetes.kind" ~/tmp/json) - if [[ "$depid" == "$name" && "$type" == "Service" ]]; then - svcId=$ni - nodePort=$(jq -r ".items[$ni].runtime_properties.kubernetes.spec.ports[0].node_port" ~/tmp/json) - if [[ "$nodePort" != "null" ]]; then - echo "nodePort=$nodePort" - export nodePort - fi - fi - done + nodePort=$(cat tmp/json | jq -r ".items[] | select(.node_id == \"${name}_service\")" | jq -r '.runtime_properties.kubernetes.spec.ports[0].node_port') sleep 10 ((tries--)) done -- cgit 1.2.3-korg