Skip to content

Commit 471aa1f

Browse files
committed
fix(ci): replace sleep with readiness polling, fix K8s test networking
- tests-deploy.yml: Replace all `sleep 60s`/`sleep 120s` with polling loop that checks for `/var/www/html/version.php` in the Julius Docker container. The bootstrap now takes >120s due to larger 3rdparty submodule, causing race conditions with fixed sleeps. - tests-deploy-k8s.yml: Pass `--k8s_upstream_host` with the actual k3s node IP to the daemon registration. Without this, HaRP's NodePort upstream resolution returns an IP that HAProxy can't route to from the CI host network. Also switched from building HaRP from dev branch to pulling the published ghcr.io image (K8s PR is now merged). Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
1 parent ef3005c commit 471aa1f

2 files changed

Lines changed: 81 additions & 12 deletions

File tree

.github/workflows/tests-deploy-k8s.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
--admin-user admin --admin-pass admin
8585
./occ config:system:set loglevel --value=0 --type=integer
8686
./occ config:system:set debug --value=true --type=boolean
87-
./occ config:system:set overwrite.cli.url --value http://127.0.0.1 --type=string
87+
./occ config:system:set overwrite.cli.url --value http://${NODE_IP} --type=string
8888
./occ app:enable --force ${{ env.APP_NAME }}
8989
9090
- name: Install k3s
@@ -97,6 +97,9 @@ jobs:
9797
run: |
9898
kubectl wait --for=condition=Ready node --all --timeout=120s
9999
kubectl create namespace nextcloud-exapps
100+
NODE_IP=$(kubectl get node -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
101+
echo "NODE_IP=${NODE_IP}" >> $GITHUB_ENV
102+
echo "k3s node IP: $NODE_IP"
100103
101104
- name: Create K8s service account for HaRP
102105
run: |
@@ -119,7 +122,7 @@ jobs:
119122
run: |
120123
docker run --net host --name appapi-harp \
121124
-e HP_SHARED_KEY="${{ env.HP_SHARED_KEY }}" \
122-
-e NC_INSTANCE_URL="http://127.0.0.1" \
125+
-e NC_INSTANCE_URL="http://${{ env.NODE_IP }}" \
123126
-e HP_LOG_LEVEL="debug" \
124127
-e HP_K8S_ENABLED="true" \
125128
-e HP_K8S_API_SERVER="https://127.0.0.1:6443" \
@@ -136,12 +139,12 @@ jobs:
136139
-d nginx
137140
138141
- name: Start Nextcloud
139-
run: PHP_CLI_SERVER_WORKERS=2 php -S 127.0.0.1:8080 &
142+
run: PHP_CLI_SERVER_WORKERS=2 php -S 0.0.0.0:8080 &
140143

141144
- name: Wait for HaRP K8s readiness
142145
run: |
143146
for i in $(seq 1 30); do
144-
if curl -sf http://127.0.0.1:8780/exapps/app_api/info \
147+
if curl -sf http://${{ env.NODE_IP }}:8780/exapps/app_api/info \
145148
-H "harp-shared-key: ${{ env.HP_SHARED_KEY }}" 2>/dev/null | grep -q '"kubernetes"'; then
146149
echo "HaRP is ready with K8s backend"
147150
exit 0
@@ -156,8 +159,8 @@ jobs:
156159
- name: Register K8s daemon
157160
run: |
158161
./occ app_api:daemon:register \
159-
k8s_test "K8s Test" "kubernetes-install" "http" "127.0.0.1:8780" "http://127.0.0.1" \
160-
--harp --harp_shared_key "${{ env.HP_SHARED_KEY }}" --harp_frp_address "127.0.0.1:8782" \
162+
k8s_test "K8s Test" "kubernetes-install" "http" "${{ env.NODE_IP }}:8780" "http://${{ env.NODE_IP }}" \
163+
--harp --harp_shared_key "${{ env.HP_SHARED_KEY }}" --harp_frp_address "${{ env.NODE_IP }}:8782" \
161164
--k8s --k8s_expose_type=nodeport --set-default
162165
./occ app_api:daemon:list
163166

.github/workflows/tests-deploy.yml

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,18 @@ jobs:
152152
docker network create master_bridge
153153
docker run --net master_bridge --name nextcloud --rm -d -v /var/run/docker.sock:/var/run/docker.sock ${{ env.docker-image }}
154154
sudo chmod 766 /var/run/docker.sock
155-
sleep 120s
155+
156+
- name: Wait for Nextcloud bootstrap
157+
run: |
158+
for i in $(seq 1 60); do
159+
if docker exec nextcloud test -f /var/www/html/version.php 2>/dev/null; then
160+
echo "Nextcloud source ready after ${i}0s"
161+
break
162+
fi
163+
echo "Waiting for Nextcloud bootstrap... ($i/60)"
164+
sleep 10
165+
done
166+
docker exec nextcloud test -f /var/www/html/version.php || (echo "Bootstrap timed out" && exit 1)
156167
157168
- name: Install AppAPI
158169
run: |
@@ -241,7 +252,18 @@ jobs:
241252
--net master_bridge --name nextcloud-appapi-dsp -h nextcloud-appapi-dsp \
242253
--privileged -d ghcr.io/nextcloud/nextcloud-appapi-dsp:latest
243254
docker run --net master_bridge --name nextcloud --rm -d ${{ env.docker-image }}
244-
sleep 60s
255+
256+
- name: Wait for Nextcloud bootstrap
257+
run: |
258+
for i in $(seq 1 60); do
259+
if docker exec nextcloud test -f /var/www/html/version.php 2>/dev/null; then
260+
echo "Nextcloud source ready after ${i}0s"
261+
break
262+
fi
263+
echo "Waiting for Nextcloud bootstrap... ($i/60)"
264+
sleep 10
265+
done
266+
docker exec nextcloud test -f /var/www/html/version.php || (echo "Bootstrap timed out" && exit 1)
245267
246268
- name: Install AppAPI
247269
run: |
@@ -340,7 +362,18 @@ jobs:
340362
--net host --name nextcloud-appapi-dsp -h nextcloud-appapi-dsp \
341363
--privileged -d ghcr.io/nextcloud/nextcloud-appapi-dsp:latest
342364
docker run --net master_bridge --name nextcloud --rm -d ${{ env.docker-image }}
343-
sleep 60s
365+
366+
- name: Wait for Nextcloud bootstrap
367+
run: |
368+
for i in $(seq 1 60); do
369+
if docker exec nextcloud test -f /var/www/html/version.php 2>/dev/null; then
370+
echo "Nextcloud source ready after ${i}0s"
371+
break
372+
fi
373+
echo "Waiting for Nextcloud bootstrap... ($i/60)"
374+
sleep 10
375+
done
376+
docker exec nextcloud test -f /var/www/html/version.php || (echo "Bootstrap timed out" && exit 1)
344377
345378
- name: Debug information
346379
run: |
@@ -469,7 +502,18 @@ jobs:
469502
--net host --name nextcloud-appapi-dsp -h nextcloud-appapi-dsp \
470503
--privileged -d ghcr.io/nextcloud/nextcloud-appapi-dsp:latest
471504
docker run --net=bridge --name=nextcloud -p 8080:80 --rm -d ${{ env.docker-image }}
472-
sleep 60s
505+
506+
- name: Wait for Nextcloud bootstrap
507+
run: |
508+
for i in $(seq 1 60); do
509+
if docker exec nextcloud test -f /var/www/html/version.php 2>/dev/null; then
510+
echo "Nextcloud source ready after ${i}0s"
511+
break
512+
fi
513+
echo "Waiting for Nextcloud bootstrap... ($i/60)"
514+
sleep 10
515+
done
516+
docker exec nextcloud test -f /var/www/html/version.php || (echo "Bootstrap timed out" && exit 1)
473517
474518
- name: Debug information
475519
run: |
@@ -1028,9 +1072,20 @@ jobs:
10281072
-v $(pwd)/tests/simple-nginx-NOT-FOR-PRODUCTION.conf:/etc/nginx/conf.d/default.conf:ro \
10291073
-d nginx
10301074
1075+
- name: Wait for Nextcloud bootstrap
1076+
run: |
1077+
for i in $(seq 1 60); do
1078+
if docker exec nextcloud-docker test -f /var/www/html/version.php 2>/dev/null; then
1079+
echo "Nextcloud source ready after ${i}0s"
1080+
break
1081+
fi
1082+
echo "Waiting for Nextcloud bootstrap... ($i/60)"
1083+
sleep 10
1084+
done
1085+
docker exec nextcloud-docker test -f /var/www/html/version.php || (echo "Bootstrap timed out" && exit 1)
1086+
10311087
- name: Install AppAPI
10321088
run: |
1033-
sleep 60s
10341089
docker exec -w /var/www/html/apps nextcloud-docker git clone https://github.com/nextcloud/${{ env.APP_NAME }}.git
10351090
docker exec -w /var/www/html/apps/${{ env.APP_NAME }} nextcloud-docker git fetch origin $GITHUB_REF
10361091
docker exec -w /var/www/html/apps/${{ env.APP_NAME }} nextcloud-docker git checkout FETCH_HEAD
@@ -1122,9 +1177,20 @@ jobs:
11221177
-v $(pwd)/tests/simple-nginx-NOT-FOR-PRODUCTION.conf:/etc/nginx/conf.d/default.conf:ro \
11231178
-d nginx
11241179
1180+
- name: Wait for Nextcloud bootstrap
1181+
run: |
1182+
for i in $(seq 1 60); do
1183+
if docker exec nextcloud-docker test -f /var/www/html/version.php 2>/dev/null; then
1184+
echo "Nextcloud source ready after ${i}0s"
1185+
break
1186+
fi
1187+
echo "Waiting for Nextcloud bootstrap... ($i/60)"
1188+
sleep 10
1189+
done
1190+
docker exec nextcloud-docker test -f /var/www/html/version.php || (echo "Bootstrap timed out" && exit 1)
1191+
11251192
- name: Install AppAPI
11261193
run: |
1127-
sleep 60s
11281194
docker exec -w /var/www/html/apps nextcloud-docker git clone https://github.com/nextcloud/${{ env.APP_NAME }}.git
11291195
docker exec -w /var/www/html/apps/${{ env.APP_NAME }} nextcloud-docker git fetch origin $GITHUB_REF
11301196
docker exec -w /var/www/html/apps/${{ env.APP_NAME }} nextcloud-docker git checkout FETCH_HEAD

0 commit comments

Comments
 (0)