Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retries to NNCP deployment #853

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ NNCP_CTLPLANE_IPV6_ADDRESS_SUFFIX ?=10
NNCP_GATEWAY_IPV6 ?=fd00:aaaa::1
NNCP_DNS_SERVER_IPV6 ?=fd00:aaaa::1
NNCP_ADDITIONAL_HOST_ROUTES ?=
NNCP_RETRIES ?= 5

# MetalLB
ifeq ($(NETWORK_ISOLATION_USE_DEFAULT_NETWORK), true)
Expand Down Expand Up @@ -667,8 +668,8 @@ endif

OPENSTACK_PREP_DEPS := validate_marketplace
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(INSTALL_CERT_MANAGER)), certmanager)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(NETWORK_ISOLATION)), nmstate nncp netattach metallb metallb_config)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(NETWORK_BGP)), nmstate nncp netattach metallb metallb_config)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(NETWORK_ISOLATION)), nmstate nncp_with_retries netattach metallb metallb_config)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(NETWORK_BGP)), nmstate nncp_with_retries netattach metallb metallb_config)
OPENSTACK_PREP_DEPS += $(if $(findstring true,$(BMO_SETUP)), crc_bmo_setup)

.PHONY: openstack_prep
Expand Down Expand Up @@ -2154,6 +2155,12 @@ else
oc wait deployments/nmstate-webhook -n ${NAMESPACE} --for condition=Available --timeout=${TIMEOUT}
endif

.PHONY: nncp_with_retries
nncp_with_retries: ## Deploy NNCP with retries
$(eval $(call vars,$@))
bash scripts/retry_make_nncp.sh $(NNCP_RETRIES)


.PHONY: nncp
nncp: export INTERFACE=${NNCP_INTERFACE}
nncp: export BRIDGE_NAME=${NNCP_BRIDGE}
Expand Down
15 changes: 15 additions & 0 deletions scripts/retry_make_nncp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

n=0
retries="${1:-5}" # Number of retries with a default value of 5

while true; do
make nncp && break
make nncp_cleanup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like this is not a stable pattern

when we delete and recreate the resource even if its the same content its going to be a separate object at the k8s level so without an exponential backoof i.e. waiting longer each time we call make nncp i think its possible that we ould be in a loop just because we kept restarting before it could make progress.

should we increase the NNCP_TIMEOUT slightly on each retry?

Copy link
Contributor Author

@lewisdenny lewisdenny Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like this is not a stable pattern

It's not ideal but it's a worst case recovery, we already give the NNCP CR 240s seconds to complete and I haven't seen any jobs failing due to timeout.

i think its possible that we ould be in a loop just because we kept restarting before it could make progress.

I haven't seen any job fail due to NNCP CR taking over 240s to apply. This loop is limited to 5 iterations so max it would be stuck for is 20mins and this would only be if there is a real issue with the NNCP CR that needs to be fixed, aka a real bug.

should we increase the NNCP_TIMEOUT slightly on each retry?

No I don't believe we should, I believe it's high enough already unless you have seen jobs failing to apply the NNCP in under 240 seconds?

n=$((n+1))
if (( n >= retries )); then
echo "Failed to run 'make nncp' target. Aborting"
exit 1
fi
sleep 10
done