Skip to content

Commit 8c1000c

Browse files
committed
Makefile.kind: retry Gateway API CRD applies on transient failures
The servicemesh targets install the upstream Gateway API CRDs with individual kubectl apply calls that fetch each YAML from raw.githubusercontent.com. That host intermittently rate-limits with HTTP 429, and a single transient failure aborts make kind-servicemesh-prereqs before Cilium is even installed, failing the whole Gateway API conformance job for a reason unrelated to Cilium. Collect the CRD names into GW_CRDS and apply them through a shared apply-gateway-api-crds recipe that retries each apply up to five times with an escalating backoff. This only re-fetches static upstream YAML, so it cannot mask a Cilium regression, and a genuinely persistent error still fails the target once the retries are exhausted. This commit was prepared with AIL:3. Signed-off-by: André Martins <andre@cilium.io>
1 parent 6b7600c commit 8c1000c

1 file changed

Lines changed: 28 additions & 20 deletions

File tree

Makefile.kind

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,32 @@ kind-install-cilium: check_deps kind-ready ## Install a local Cilium version int
369369
GW_VERSION ?= $(shell grep -m 1 "sigs.k8s.io/gateway-api" go.mod | awk '{print $$2}' | awk -F'-' '{print (NF>2)?$$NF:$$0}')
370370
# Set this to "standard" to use the standard CRDs instead
371371
GW_CHANNEL ?= experimental
372+
373+
# The upstream Gateway API CRDs that the servicemesh targets install, in the
374+
# order they must be applied.
375+
GW_CRDS := gatewayclasses gateways httproutes referencegrants grpcroutes \
376+
backendtlspolicies tlsroutes listenersets tcproutes udproutes
377+
378+
# Apply the upstream Gateway API CRDs, retrying each one with a backoff.
379+
# raw.githubusercontent.com intermittently rate-limits (HTTP 429), and a single
380+
# transient failure here would abort the whole job before Cilium is even
381+
# installed. Retrying only re-fetches static upstream YAML, so it cannot mask a
382+
# Cilium regression; a genuinely persistent error still fails the target once
383+
# the attempts are exhausted.
384+
define apply-gateway-api-crds
385+
for crd in $(GW_CRDS); do \
386+
n=0; \
387+
until kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_$$crd.yaml; do \
388+
n=$$((n+1)); \
389+
if [ $$n -ge 5 ]; then \
390+
echo "Failed to apply gateway.networking.k8s.io_$$crd CRD after 5 attempts" >&2; \
391+
exit 1; \
392+
fi; \
393+
echo "Retrying gateway.networking.k8s.io_$$crd CRD apply ($$n/5) in $$((n * 5))s..."; \
394+
sleep $$((n * 5)); \
395+
done; \
396+
done
397+
endef
372398
KIND_NET_CIDR ?= $(shell docker network inspect kind-cilium -f '{{json .IPAM.Config}}' | jq -r '.[] | select(.Subnet | test("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+")) | .Subnet')
373399
LB_CIDR ?= $(shell echo $(KIND_NET_CIDR) | sed "s@0.0/16@255.200\/28@" | sed -e 's/[\/&]/\\&/g')
374400

@@ -379,16 +405,7 @@ kind-servicemesh-install-cilium: check_deps kind-ready ## Install a local Cilium
379405
# reinstall here. https://github.com/cilium/cilium-cli/issues/205
380406
-@$(CILIUM_CLI) uninstall >/dev/null 2>&1 || true
381407

382-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_gatewayclasses.yaml
383-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_gateways.yaml
384-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_httproutes.yaml
385-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_referencegrants.yaml
386-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_grpcroutes.yaml
387-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_backendtlspolicies.yaml
388-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_tlsroutes.yaml
389-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_listenersets.yaml
390-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_tcproutes.yaml
391-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_udproutes.yaml
408+
@$(apply-gateway-api-crds)
392409

393410
$(CILIUM_CLI) install \
394411
--chart-directory=$(ROOT_DIR)/install/kubernetes/cilium \
@@ -410,16 +427,7 @@ kind-servicemesh-install-cilium: check_deps kind-ready ## Install a local Cilium
410427
.PHONY: kind-servicemesh-prereqs
411428
kind-servicemesh-prereqs: check_deps kind-ready
412429
@echo " SETUP Servicemesh"
413-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_gatewayclasses.yaml
414-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_gateways.yaml
415-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_httproutes.yaml
416-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_referencegrants.yaml
417-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_grpcroutes.yaml
418-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_backendtlspolicies.yaml
419-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_tlsroutes.yaml
420-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_listenersets.yaml
421-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_tcproutes.yaml
422-
kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/$(GW_VERSION)/config/crd/$(GW_CHANNEL)/gateway.networking.k8s.io_udproutes.yaml
430+
@$(apply-gateway-api-crds)
423431

424432
$(eval KIND_VALUES_FAST_FILES += --helm-values=$(ROOT_DIR)/contrib/testing/kind-servicemesh.yaml)
425433

0 commit comments

Comments
 (0)