Preserve healthy app pods on retries and allow bounded cold-start rollouts
This commit is contained in:
parent
fcd5693527
commit
492adcb0db
|
|
@ -14,6 +14,14 @@ reservations and placement permit the rollout; native K3s does not require old
|
|||
Pimox worker inventory. See the [code map](code-map.md) and
|
||||
[deployment gates](deployment.md#scheduling-and-deployment-gates).
|
||||
|
||||
Website and demos retries preserve existing pods when their immutable image
|
||||
reference is unchanged. Updating the Deployment image triggers the normal
|
||||
rolling update; the apps pipeline does not delete all selected pods to force a
|
||||
restart. The default rollout/readiness budget is 600 seconds, configurable with
|
||||
`LAB_APPS_READY_WAIT_SECONDS`, including the final ready-replica check rather
|
||||
than starting a second full wait after rollout. Slow initial image pulls can
|
||||
consume this budget; a timeout does not by itself establish a container crash.
|
||||
|
||||
## Adding Apps
|
||||
|
||||
Add Kubernetes manifests under `apps/<name>` and register them in
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@ reservations and placement permit the rollout; native K3s does not require old
|
|||
Pimox worker inventory. See the [code map](code-map.md) and
|
||||
[deployment gates](deployment.md#scheduling-and-deployment-gates).
|
||||
|
||||
Website and demos retries preserve existing pods when their immutable image
|
||||
reference is unchanged. Updating the Deployment image triggers the normal
|
||||
rolling update; the apps pipeline does not delete all selected pods to force a
|
||||
restart. The default rollout/readiness budget is 600 seconds, configurable with
|
||||
`LAB_APPS_READY_WAIT_SECONDS`, including the final ready-replica check rather
|
||||
than starting a second full wait after rollout. Slow initial image pulls can
|
||||
consume this budget; a timeout does not by itself establish a container crash.
|
||||
|
||||
## Adding Apps
|
||||
|
||||
Add Kubernetes manifests under `apps/<name>` and register them in
|
||||
|
|
|
|||
|
|
@ -5253,11 +5253,17 @@ wait_for_deployment_ready() {
|
|||
local timeout_seconds="$4"
|
||||
local desired_replicas
|
||||
local ready_replicas
|
||||
local elapsed=0
|
||||
local deadline
|
||||
|
||||
if ! [[ "${timeout_seconds}" =~ ^[0-9]+$ ]] || ((timeout_seconds < 1)); then
|
||||
echo "Deployment readiness timeout must be a positive number of seconds." >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
desired_replicas="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" get deployment "${deployment}" -o jsonpath='{.spec.replicas}' 2>/dev/null || true)"
|
||||
desired_replicas="${desired_replicas:-1}"
|
||||
|
||||
deadline=$((SECONDS + timeout_seconds))
|
||||
if ! kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" rollout status "deployment/${deployment}" --timeout="${timeout_seconds}s"; then
|
||||
echo "Timed out waiting for deployment/${deployment} rollout in namespace ${namespace}" >&2
|
||||
dump_argocd_debug "${app}"
|
||||
|
|
@ -5267,14 +5273,13 @@ wait_for_deployment_ready() {
|
|||
|
||||
until ready_replicas="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" get deployment "${deployment}" -o jsonpath='{.status.readyReplicas}' 2>/dev/null)"; \
|
||||
(( ${ready_replicas:-0} >= desired_replicas )); do
|
||||
if ((elapsed >= timeout_seconds)); then
|
||||
if ((SECONDS >= deadline)); then
|
||||
echo "Timed out waiting for deployment/${deployment} in namespace ${namespace} to have ${desired_replicas} ready replicas" >&2
|
||||
dump_argocd_debug "${app}"
|
||||
dump_namespace_debug "${namespace}"
|
||||
exit 1
|
||||
fi
|
||||
sleep 5
|
||||
elapsed=$((elapsed + 5))
|
||||
done
|
||||
}
|
||||
|
||||
|
|
@ -6917,19 +6922,6 @@ SERVICE_EOT
|
|||
sudo systemctl status homelab-gitea-runner.service --no-pager -l
|
||||
}
|
||||
|
||||
recreate_pods_for_selector() {
|
||||
local namespace="$1"
|
||||
local selector="$2"
|
||||
local app="$3"
|
||||
|
||||
if ! kubectl --kubeconfig "${KUBECONFIG_PATH}" -n "${namespace}" delete pod -l "${selector}" --ignore-not-found --wait=true --timeout=120s; then
|
||||
echo "Failed to recreate pods matching ${selector} in namespace ${namespace}" >&2
|
||||
dump_argocd_debug "${app}"
|
||||
dump_namespace_debug "${namespace}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_deployment_container_image() {
|
||||
local namespace="$1"
|
||||
local deployment="$2"
|
||||
|
|
@ -7833,7 +7825,7 @@ PIMOX_NODE_STORAGE_EOF
|
|||
|
||||
apps() {
|
||||
local app_selector="${1:-all}"
|
||||
local app_ready_wait_seconds="${LAB_APPS_READY_WAIT_SECONDS:-180}"
|
||||
local app_ready_wait_seconds="${LAB_APPS_READY_WAIT_SECONDS:-600}"
|
||||
local app_resource_wait_seconds="${LAB_APPS_RESOURCE_WAIT_SECONDS:-120}"
|
||||
local buildx_builder_ready=false
|
||||
local demos_image_built=false
|
||||
|
|
@ -8043,7 +8035,8 @@ apps() {
|
|||
wait_for_namespace website-production website-production "${app_resource_wait_seconds}"
|
||||
wait_for_namespaced_resource website-production deployment php-website-deployment website-production "${app_resource_wait_seconds}"
|
||||
ensure_deployment_container_image website-production php-website-deployment php-app "${website_image_ref}" website-production
|
||||
recreate_pods_for_selector website-production app=php-website website-production
|
||||
# Immutable image changes already trigger the Deployment rolling update.
|
||||
# Keep healthy pods in place when retrying an unchanged app deployment.
|
||||
wait_for_deployment_ready website-production php-website-deployment website-production "${app_ready_wait_seconds}"
|
||||
if [[ "${website_image_built}" == "true" ]]; then
|
||||
write_website_image_state "${website_image_state_file}" "${website_source_hash}" "${website_platforms}" "${website_image_ref}"
|
||||
|
|
@ -8055,7 +8048,6 @@ apps() {
|
|||
wait_for_namespace demos-static demos-static "${app_resource_wait_seconds}"
|
||||
wait_for_namespaced_resource demos-static deployment demos-static demos-static "${app_resource_wait_seconds}"
|
||||
ensure_deployment_container_image demos-static demos-static demos-static "${demos_image_ref}" demos-static
|
||||
recreate_pods_for_selector demos-static app=demos-static demos-static
|
||||
wait_for_deployment_ready demos-static demos-static demos-static "${app_ready_wait_seconds}"
|
||||
if [[ "${demos_image_built}" == "true" ]]; then
|
||||
write_demos_image_state "${demos_image_state_file}" "${demos_source_hash}" "${demos_platforms}" "${demos_image_ref}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue