Skip to content

Commit

Permalink
MGMT-18628: fix better waiting for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
eifrach committed Sep 30, 2024
1 parent 0fde766 commit c94b595
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions deploy/operator/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ function wait_for_pod() {
pod="$1"
namespace="${2:-}"
selector="${3:-}"

{
wait_for_condition "pod" "Ready" "30m" "${namespace}" "${selector}"
}

function wait_for_pods(){
NAMESPACE=${$1:-}
SELECTOR=${$2:-}

while [[ $(oc get pods -n $1 -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}'| tr ' ' '\n' | sort -u) != "True" ]]; do
echo "Waiting for pods in namespace $1 to be ready"
oc get pods -n $1 -o 'jsonpath={..status.containerStatuses}' | jq "."
Expand All @@ -72,9 +75,15 @@ function wait_for_deployment() {
for i in {1..40}; do
oc get deployment "${deployment}" --namespace="${namespace}" |& grep -ivE "(no resources found|not found)" && break || sleep 10
done
if [ $i -eq 40 ]; then
echo "ERROR: failed Waiting for (deployment) on namespace (${namespace}) with name (${deployment}) to be created..."
exit 1
fi

echo "Waiting for (deployment) on namespace (${namespace}) with name (${deployment}) to rollout..."
oc rollout status "deploy/${deployment}" -n "${namespace}" --timeout="${timeout}"
REPLICAS=$(oc get deployments.apps -n assisted-installer assisted-service -o json | jq .status.replicas)
oc --namespace "${namespace}" wait --for=jsonpath='{.status.availableReplicas}'=$REPLICAS \
--timeout=5m "deployment.apps/${deployment}"
}

function hash() {
Expand Down

0 comments on commit c94b595

Please sign in to comment.