Skip to content

Commit c323660

Browse files
authored
Fix E2E deploy timeout caused by reconcile race in kpt live apply (#1080)
* Fix E2E deploy timeout caused by CRD/instance reconcile race in kpt live apply Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech> * Address review comments Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech> --------- Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
1 parent 7085bca commit c323660

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

make/deploy.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ run-in-kind-db-cache-no-git-push-drafts: load-images-to-kind deployment-config d
105105

106106
.PHONY: destroy
107107
destroy:## Deletes all porch resources installed by the last run-in-kind-* command
108+
@if [ -d "$(DEPLOYPORCHCONFIGDIR)-post" ]; then \
109+
kubectl delete -f "$(DEPLOYPORCHCONFIGDIR)-post/" --ignore-not-found; \
110+
fi
108111
kpt live destroy $(DEPLOYPORCHCONFIGDIR)
109112

110113
.PHONY: deployment-config
@@ -137,6 +140,9 @@ deploy-current-config:## Deploy the configuration that is currently in $(DEPLOYP
137140
@if [ "$(SKIP_CONTROLLER_BUILD)" != "true" ]; then \
138141
kubectl rollout status deployment porch-controllers --namespace porch-system --timeout=180s; \
139142
fi
143+
@if [ -d "$(DEPLOYPORCHCONFIGDIR)-post" ]; then \
144+
kubectl apply --server-side --force-conflicts -f "$(DEPLOYPORCHCONFIGDIR)-post/"; \
145+
fi
140146
@echo "Done."
141147

142148
.PHONY: reload-function-runner

scripts/create-deployment-blueprint.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2022-2025 The kpt Authors
2+
# Copyright 2022-2026 The kpt Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -357,6 +357,13 @@ function main() {
357357

358358
# Porch Deployment Config
359359
cp ${PORCH_DIR}/deployments/porch/*.yaml "${PORCH_DIR}/deployments/porch/Kptfile" "${DESTINATION}"
360+
361+
# Move FunctionConfig/ServiceTemplate CR instances to a separate post-deploy directory.
362+
# These are applied after the main deployment rollout checks pass to avoid kpt live apply reconcile timeouts
363+
# caused by applying a CRD and its instances in the same operation.
364+
rm -rf "${DESTINATION}-post"
365+
mkdir -p "${DESTINATION}-post"
366+
mv "${DESTINATION}/22-function-templates.yaml" "${DESTINATION}/23-function-configurations.yaml" "${DESTINATION}-post/"
360367
# Copy Porch controller manager rbac
361368
cp ${PORCH_DIR}/controllers/config/rbac/role.yaml "${DESTINATION}/9-porch-controller-clusterrole.yaml"
362369

scripts/create-deployment-config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2025 The kpt Authors
2+
# Copyright 2025-2026 The kpt Authors
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ source "$(dirname "$0")/common.sh"
2222

2323
echo "Creating deployment configuration..."
2424

25-
rm -rf "${DEPLOYPORCHCONFIGDIR}" || true
25+
rm -rf "${DEPLOYPORCHCONFIGDIR}" "${DEPLOYPORCHCONFIGDIR}-post" || true
2626
mkdir -p "${DEPLOYPORCHCONFIGDIR}"
2727

2828
./scripts/create-deployment-blueprint.sh \

scripts/create-deployment-kpt.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ function deploy-porch-dev-pkg {
118118
kpt fn render ${DESTINATION}/porch
119119
kpt live init ${DESTINATION}/porch
120120
kpt live apply ${DESTINATION}/porch
121+
# Apply CRD instances after the main deployment to avoid reconcile timeouts
122+
# caused by applying a CRD and its instances in the same operation.
123+
if [ -d "${DESTINATION}/porch-post" ]; then
124+
kubectl apply --server-side --force-conflicts -f "${DESTINATION}/porch-post/"
125+
fi
121126
}
122127

123128
function load-custom-images {
@@ -166,6 +171,16 @@ for resource in ctx.resource_list["items"]:
166171
"${WRAPPER_SERVER_IMAGE}"
167172

168173
echo "Deploying porch with newly built images..."
174+
# Move FunctionConfig/ServiceTemplate CR instances to a separate post-deploy directory.
175+
# These are applied after the main deployment to avoid kpt live apply reconcile timeouts
176+
# caused by applying a CRD and its instances in the same operation.
177+
rm -rf "${DESTINATION}/porch-post"
178+
mkdir -p "${DESTINATION}/porch-post"
179+
for f in "${DESTINATION}/porch/22-function-templates.yaml" "${DESTINATION}/porch/23-function-configurations.yaml"; do
180+
if [ -f "$f" ]; then
181+
mv "$f" "${DESTINATION}/porch-post/"
182+
fi
183+
done
169184
deploy-porch-dev-pkg
170185

171186
echo

0 commit comments

Comments
 (0)