Wrapping Retry for Py3.10 25/13425/2
authorMark Beierl <mark.beierl@canonical.com>
Fri, 19 May 2023 02:21:06 +0000 (22:21 -0400)
committerMark Beierl <mark.beierl@canonical.com>
Fri, 19 May 2023 02:26:33 +0000 (22:26 -0400)
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 <mark.beierl@canonical.com>
n2vc/kubectl.py
n2vc/n2vc_juju_conn.py

index d6ca09a..3fe6b53 100644 (file)
@@ -35,6 +35,7 @@ from kubernetes.client.models import (
     V1SecretReference,
 )
 from kubernetes.client.rest import ApiException
     V1SecretReference,
 )
 from kubernetes.client.rest import ApiException
+from n2vc.libjuju import retry_callback
 from retrying_async import retry
 
 
 from retrying_async import retry
 
 
@@ -319,6 +320,7 @@ class Kubectl:
         attempts=10,
         delay=1,
         fallback=Exception("Failed getting the secret from service account"),
         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"
     )
     async def get_secret_data(
         self, name: str, namespace: str = "kube-system"
index 66a88db..9d0cdfa 100644 (file)
@@ -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.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
 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
 
     # 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,
     async def install_configuration_sw(
         self,
         ee_id: str,