From fb79786bd154505ea9c7578e6247dea565ea9c41 Mon Sep 17 00:00:00 2001 From: Mark Beierl Date: Thu, 18 May 2023 22:21:06 -0400 Subject: [PATCH] Wrapping Retry for Py3.10 The retrying_async library is not Python 3.10 ready, so we are providing a 3.10 compatible callback for it to use instead of the default one Change-Id: I15e9b64c70d4d294c9ff0c6c7048cd257f6e1b61 Signed-off-by: Mark Beierl --- n2vc/kubectl.py | 2 ++ n2vc/n2vc_juju_conn.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/n2vc/kubectl.py b/n2vc/kubectl.py index d6ca09a..3fe6b53 100644 --- a/n2vc/kubectl.py +++ b/n2vc/kubectl.py @@ -35,6 +35,7 @@ from kubernetes.client.models import ( V1SecretReference, ) from kubernetes.client.rest import ApiException +from n2vc.libjuju import retry_callback from retrying_async import retry @@ -319,6 +320,7 @@ class Kubectl: attempts=10, delay=1, fallback=Exception("Failed getting the secret from service account"), + callback=retry_callback, ) async def get_secret_data( self, name: str, namespace: str = "kube-system" diff --git a/n2vc/n2vc_juju_conn.py b/n2vc/n2vc_juju_conn.py index 66a88db..9d0cdfa 100644 --- a/n2vc/n2vc_juju_conn.py +++ b/n2vc/n2vc_juju_conn.py @@ -37,7 +37,7 @@ from n2vc.exceptions import ( ) from n2vc.n2vc_conn import N2VCConnector from n2vc.n2vc_conn import obj_to_dict, obj_to_yaml -from n2vc.libjuju import Libjuju +from n2vc.libjuju import Libjuju, retry_callback from n2vc.store import MotorStore from n2vc.utils import get_ee_id_components, generate_random_alfanum_string from n2vc.vca.connection import get_connection @@ -355,7 +355,13 @@ class N2VCJujuConnector(N2VCConnector): # In case of native_charm is being deployed, if JujuApplicationExists error happens # it will try to add_unit - @retry(attempts=3, delay=5, retry_exceptions=(N2VCApplicationExists,), timeout=None) + @retry( + attempts=3, + delay=5, + retry_exceptions=(N2VCApplicationExists,), + timeout=None, + callback=retry_callback, + ) async def install_configuration_sw( self, ee_id: str, -- 2.25.1