Skip to content

Commit ccf08fd

Browse files
authored
Fix metadata-webhook cleanup race condition (#3973)
* Limit metadata-webhook scope to serving-tests namespace Add namespaceSelector to the MutatingWebhookConfiguration to limit the webhook's scope to namespaces with the samples.knative.dev/release label. This prevents the webhook from blocking resource deletions in other namespaces when the serving-tests namespace is torn down. The issue occurred during upgrade test cleanup where the Route resource for deployment-upgrade-failure could not be deleted because the webhook service was unavailable after namespace cleanup started. Assisted-by: 🤖 Claude Opus/Sonnet 4.5 * Fix metadata-webhook cleanup race condition Delete webhook resources before namespace deletion to prevent blocking Route finalizer removal when webhook service is unavailable. The issue occurs when: 1. Tests complete and cleanup starts 2. 'kubectl delete ns serving-tests' begins namespace deletion 3. Routes have finalizers that need removal 4. Finalizer removal triggers the MutatingWebhookConfiguration 5. Webhook service (in serving-tests) is already being deleted 6. Webhook call times out, blocking namespace deletion Solution: Delete the webhook resources (including the cluster-scoped MutatingWebhookConfiguration) before deleting the serving-tests namespace. This mirrors the installation order and prevents the race condition. * Add --ignore-not-found to namespace deletion The webhook config directory includes 100-namespace.yaml which deletes the serving-tests namespace. Adding --ignore-not-found prevents the error when the namespace is already deleted.
1 parent 386adad commit ccf08fd

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎test/lib.bash‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,16 @@ EOF
571571
--upgradeopenshift
572572
fi
573573

574-
# Delete the leftover namespace.
575-
oc delete namespace serving-tests
574+
# Delete metadata-webhook resources before deleting the namespace.
575+
# This prevents blocking Route finalizer removal when webhook service is unavailable.
576+
if [[ $MESH == "true" ]]; then
577+
local rootdir
578+
rootdir="$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")"
579+
oc delete -f "${rootdir}/serving/metadata-webhook/config" --ignore-not-found
580+
fi
581+
582+
# Delete the leftover namespace (may already be deleted by webhook config cleanup).
583+
oc delete namespace serving-tests --ignore-not-found
576584

577585
logger.success 'Upgrade tests passed'
578586
}

0 commit comments

Comments
 (0)