Skip to content

Commit 0ec7432

Browse files
feat: improved wait
1 parent 66aa9cd commit 0ec7432

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

0_install.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ mkdir -p ./kube
55

66
if [ ! -f ./kube/config.yaml ]; then
77
kind create cluster -n 5min-idp --kubeconfig ./kube/config.yaml --config ./setup/kind/cluster.yaml
8-
fi
98

10-
# connect current container to the kind network
11-
docker network connect "kind" "5min-idp"
9+
# connect current container to the kind network
10+
docker network connect "kind" "5min-idp"
11+
fi
1212

1313
# used by humanitec-agent / inside docker to reach the cluster
1414
kubeconfig_docker=$(pwd)/kube/config-internal.yaml

1_demo.sh

+40-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,52 @@ set -eo pipefail
33

44
if ! humctl get application 5min-idp; then
55
humctl create application 5min-idp
6+
echo "App created"
67
fi
78

9+
echo "Deploying workload"
10+
811
humctl score deploy --app 5min-idp --env development -f ./score.yaml
912

10-
echo "Waiting for deploy"
13+
echo "Waiting for deployment"
14+
15+
sleep 1
16+
17+
DEPLOYMENT_ID=$(humctl get deployment . -o json \
18+
--app 5min-idp \
19+
--env development \
20+
| jq -r .metadata.id)
21+
22+
IS_DONE=false
23+
CURRENT_STATUS=""
1124

12-
# TODO Use humctl to wait for deploy to finish once GA
13-
sleep 20
25+
while [ "$IS_DONE" = false ]; do
26+
CURRENT_STATUS=$(humctl get deployment "${DEPLOYMENT_ID}" -o json \
27+
--app 5min-idp \
28+
--env development \
29+
| jq -r .status.status)
30+
31+
if [ "$CURRENT_STATUS" = "in progress" ]; then
32+
echo "Deployment still in progress..."
33+
sleep 2
34+
elif [ "$CURRENT_STATUS" = "failed" ]; then
35+
echo "Deployment failed!"
36+
IS_DONE=true
37+
else
38+
echo "Deployment complete!"
39+
IS_DONE=true
40+
fi
41+
done
42+
if [ "$CURRENT_STATUS" = "failed" ]; then
43+
humctl get deployment-error --app 5min-idp --env development
44+
exit 1
45+
fi
1446

1547
workload_host=$(humctl get active-resources --app 5min-idp --env development -o yaml | yq '.[] | select(.metadata.type == "route") | .status.resource.host')
1648

49+
echo "Waiting for workload to be available"
50+
51+
# manually change the host here as the workload host resolves to localhost, which is not reachable from the container
52+
curl -I --retry 10 --retry-delay 3 --connect-to "$workload_host:30080:5min-idp-control-plane:30080" "http://$workload_host:30080"
53+
1754
echo "Workload available at: http://$workload_host:30080"

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RUN curl -fsSL https://github.com/mikefarah/yq/releases/latest/download/yq_linu
4343

4444
# install humctl (https://github.com/humanitec/cli/releases)
4545
RUN mkdir /tmp/humctl && \
46-
curl -fsSL https://github.com/humanitec/cli/releases/download/v0.21.0/cli_0.21.0_linux_${TARGETARCH}.tar.gz > /tmp/humctl/humctl.tar.gz && \
46+
curl -fsSL https://github.com/humanitec/cli/releases/download/v0.21.1/cli_0.21.1_linux_${TARGETARCH}.tar.gz > /tmp/humctl/humctl.tar.gz && \
4747
tar -zxvf /tmp/humctl/humctl.tar.gz -C /tmp/humctl && \
4848
install -o root -g root -m 0755 /tmp/humctl/humctl /usr/local/bin/humctl && \
4949
humctl completion bash > /etc/bash_completion.d/humctl && \

0 commit comments

Comments
 (0)