Skip to content

Commit 2fd169d

Browse files
committed
[preview] fix wait, diff-apply, regression-check slack
1 parent e9fcb45 commit 2fd169d

File tree

4 files changed

+44
-33
lines changed

4 files changed

+44
-33
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
# github.head_ref is set by a pull_request event - contains the name of the source branch of the PR
2020
# github.ref_name is set if the event is NOT a pull_request - it contains only the branch name.
2121
group: ${{ github.head_ref || github.ref_name }}-configuration
22-
cancel-in-progress: true
2322
outputs:
2423
is_main_branch: ${{ (github.head_ref || github.ref) == 'refs/heads/main' }}
2524
version: ${{ steps.branches.outputs.sanitized-branch-name }}-gha.${{github.run_number}}
@@ -140,7 +139,6 @@ jobs:
140139
group: ${{ github.head_ref || github.ref_name }}-build-gitpod
141140
# For the main branch we always want the build job to run to completion
142141
# For other branches we only care about the "latest" version, so it is fine to cancel in-progress builds
143-
cancel-in-progress: ${{ needs.configuration.outputs.is_main_branch == 'false' }}
144142
services:
145143
mysql:
146144
image: mysql:5.7

.github/workflows/preview-env-check-regressions.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ jobs:
122122
with:
123123
paths: "test/tests/**/TEST.xml"
124124
if: always()
125+
- id: auth
126+
uses: google-github-actions/auth@v1
127+
with:
128+
token_format: access_token
129+
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
125130
- name: Get Secrets from GCP
126131
id: 'secrets'
127132
uses: 'google-github-actions/get-secretmanager-secrets@v1'

dev/preview/workflow/lib/k8s-util.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,16 @@ function readWerftSecret {
8686
get secret "${name}" -o jsonpath="{.data.${key}}" \
8787
| base64 -d
8888
}
89+
90+
function diff-apply {
91+
local context=$1
92+
shift
93+
local yaml=$1
94+
yaml=$(realpath "${yaml}")
95+
96+
if kubectl --context "${context}" diff -f "${yaml}" > /dev/null; then
97+
echo "Skipping ${yaml}, as it produced no diff"
98+
else
99+
kubectl --context "${context}" apply --server-side -f "${yaml}"
100+
fi
101+
}

dev/preview/workflow/preview/deploy-gitpod.sh

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -134,35 +134,16 @@ EOF
134134
}
135135

136136
function installRookCeph {
137-
kubectl \
138-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
139-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
140-
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/crds.yaml" --server-side --force-conflicts
137+
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" "$ROOT/.werft/vm/manifests/rook-ceph/crds.yaml"
141138

142139
kubectl \
143140
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
144141
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
145142
wait --for condition=established --timeout=120s crd/cephclusters.ceph.rook.io
146143

147-
kubectl \
148-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
149-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
150-
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/common.yaml" -f "$ROOT/.werft/vm/manifests/rook-ceph/operator.yaml"
151-
152-
kubectl \
153-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
154-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
155-
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/cluster-test.yaml"
156-
157-
kubectl \
158-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
159-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
160-
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/storageclass-test.yaml"
161-
162-
kubectl \
163-
--kubeconfig "${PREVIEW_K3S_KUBE_PATH}" \
164-
--context "${PREVIEW_K3S_KUBE_CONTEXT}" \
165-
apply -f "$ROOT/.werft/vm/manifests/rook-ceph/snapshotclass.yaml"
144+
for file in common operator cluster-test storageclass-test snapshotclass;do
145+
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" "$ROOT/.werft/vm/manifests/rook-ceph/$file.yaml"
146+
done
166147
}
167148

168149
# Install Fluent-Bit sending logs to GCP
@@ -375,7 +356,7 @@ then
375356
yq d -i admin-login-secret.yaml metadata.creationTimestamp
376357
yq d -i admin-login-secret.yaml metadata.uid
377358
yq d -i admin-login-secret.yaml metadata.resourceVersion
378-
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f admin-login-secret.yaml
359+
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" admin-login-secret.yaml
379360
rm -f admin-login-secret.yaml
380361

381362
yq w -i "${INSTALLER_CONFIG_PATH}" adminLoginSecret.kind "secret"
@@ -390,7 +371,7 @@ yq w -i stripe-api-keys.secret.yaml metadata.namespace "default"
390371
yq d -i stripe-api-keys.secret.yaml metadata.creationTimestamp
391372
yq d -i stripe-api-keys.secret.yaml metadata.uid
392373
yq d -i stripe-api-keys.secret.yaml metadata.resourceVersion
393-
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f stripe-api-keys.secret.yaml
374+
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" stripe-api-keys.secret.yaml
394375
rm -f stripe-api-keys.secret.yaml
395376

396377
#
@@ -400,8 +381,9 @@ kubectl --kubeconfig "${DEV_KUBE_PATH}" --context "${DEV_KUBE_CONTEXT}" --namesp
400381
| yq w - metadata.namespace ${PREVIEW_NAMESPACE} \
401382
| yq d - metadata.uid \
402383
| yq d - metadata.resourceVersion \
403-
| yq d - metadata.creationTimestamp \
404-
| kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f -
384+
| yq d - metadata.creationTimestamp > host-key.yaml
385+
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" host-key.yaml
386+
rm -f host-key.yaml
405387

406388
yq w -i "${INSTALLER_CONFIG_PATH}" sshGatewayHostKey.kind "secret"
407389
yq w -i "${INSTALLER_CONFIG_PATH}" sshGatewayHostKey.name "host-key"
@@ -515,7 +497,7 @@ yq w -i spicedb-secret.yaml metadata.namespace "default"
515497
yq d -i spicedb-secret.yaml metadata.creationTimestamp
516498
yq d -i spicedb-secret.yaml metadata.uid
517499
yq d -i spicedb-secret.yaml metadata.resourceVersion
518-
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f spicedb-secret.yaml
500+
diff-apply "${PREVIEW_K3S_KUBE_CONTEXT}" spicedb-secret.yaml
519501
rm -f spicedb-secret.yaml
520502

521503
#
@@ -617,13 +599,26 @@ rm -f /tmp/public-api
617599
log_info "Applying manifests (installing)"
618600

619601
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" delete -n "${PREVIEW_NAMESPACE}" job migrations || true
620-
kubectl --kubeconfig "${PREVIEW_K3S_KUBE_PATH}" --context "${PREVIEW_K3S_KUBE_CONTEXT}" apply -f "${INSTALLER_RENDER_PATH}"
602+
# export the function so we can use it in xargs
603+
export -f diff-apply
604+
mkdir temp-installer || true
605+
pushd temp-installer
606+
# this will split the big yaml produced by the installer, so we can diff individual parts of it and run them in parallel
607+
yq4 -s '.kind + "_" + .metadata.name' "../${INSTALLER_RENDER_PATH}"
608+
rm .yml || true # this one is a leftover from the split
609+
# shellcheck disable=SC2038
610+
find . | xargs -n 1 -I {} -P 5 bash -c "diff-apply ${PREVIEW_K3S_KUBE_CONTEXT} {}"
611+
log_info "Applied all"
612+
popd
613+
rm -rf temp-installer
621614
rm -f "${INSTALLER_RENDER_PATH}"
622615

623616
# =========================
624-
# Wait for pods to be ready
617+
# Wait for objects to be ready
625618
# =========================
626-
waitUntilAllPodsAreReady "${PREVIEW_K3S_KUBE_PATH}" "${PREVIEW_K3S_KUBE_CONTEXT}" "$PREVIEW_NAMESPACE"
619+
for item in deployment.apps/blobserve deployment.apps/content-service deployment.apps/dashboard deployment.apps/ide-metrics deployment.apps/ide-proxy deployment.apps/ide-service deployment.apps/image-builder-mk3 deployment.apps/minio deployment.apps/node-labeler deployment.apps/payment-endpoint deployment.apps/proxy deployment.apps/public-api-server deployment.apps/redis deployment.apps/server deployment.apps/spicedb deployment.apps/usage deployment.apps/ws-manager deployment.apps/ws-manager-bridge deployment.apps/ws-proxy statefulset.apps/messagebus statefulset.apps/mysql statefulset.apps/openvsx-proxy daemonset.apps/agent-smith daemonset.apps/fluent-bit daemonset.apps/registry-facade daemonset.apps/ws-daemon; do
620+
kubectl rollout status "${item}"
621+
done
627622

628623
# =====================
629624
# Add agent smith token

0 commit comments

Comments
 (0)