Fix nfdeployment handler issue 00/7600/2
authorBin Yang <bin.yang@windriver.com>
Mon, 24 Jan 2022 04:02:11 +0000 (12:02 +0800)
committerBin Yang <bin.yang@windriver.com>
Mon, 24 Jan 2022 04:06:36 +0000 (12:06 +0800)
change retry param to workaround retry in 0 seconds issue

Issue-ID: INF-258

Signed-off-by: Bin Yang <bin.yang@windriver.com>
Change-Id: I2c2717c4a24b7182156e69d0924259bd6afded8f

o2common/domain/commands.py
o2common/domain/exceptions.py [new file with mode: 0644]
o2dms/domain/exceptions.py [new file with mode: 0644]
o2dms/domain/states.py
o2dms/service/nfdeployment_handler.py
o2ims/domain/subscription_obj.py

index 51d695f..d5af671 100644 (file)
@@ -17,4 +17,8 @@
 
 
 class Command:
+    # placeholder for retry feature
+    # tries: int = 1
+    # delay: int = 1
+    # backoff: int = 2
     pass
diff --git a/o2common/domain/exceptions.py b/o2common/domain/exceptions.py
new file mode 100644 (file)
index 0000000..dac86f3
--- /dev/null
@@ -0,0 +1,18 @@
+# Copyright (C) 2022 Wind River Systems, Inc.\r
+#\r
+#  Licensed under the Apache License, Version 2.0 (the "License");\r
+#  you may not use this file except in compliance with the License.\r
+#  You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+#  Unless required by applicable law or agreed to in writing, software\r
+#  distributed under the License is distributed on an "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#  See the License for the specific language governing permissions and\r
+#  limitations under the License.\r
+\r
+# pylint: disable=too-few-public-methods\r
+\r
+class Orano2Exception(Exception):\r
+    pass\r
diff --git a/o2dms/domain/exceptions.py b/o2dms/domain/exceptions.py
new file mode 100644 (file)
index 0000000..688392e
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+# Copyright (C) 2022 Wind River Systems, Inc.\r
+#\r
+#  Licensed under the Apache License, Version 2.0 (the "License");\r
+#  you may not use this file except in compliance with the License.\r
+#  You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+#  Unless required by applicable law or agreed to in writing, software\r
+#  distributed under the License is distributed on an "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#  See the License for the specific language governing permissions and\r
+#  limitations under the License.\r
+\r
+# pylint: disable=too-few-public-methods\r
+\r
+from o2common.domain.exceptions import Orano2Exception\r
+\r
+\r
+class NfdeploymentNotFoundError(Orano2Exception):\r
+    pass\r
index 1c98d49..1f1b434 100644 (file)
@@ -26,5 +26,5 @@ class NfDeploymentState():
     Updating = 4\r
     Uninstalling = 5\r
     Abnormal = 6\r
-    Deleted = 7\r
+    Deleting = 7\r
     # Aborting = 8\r
index c6a40ff..665e03e 100644 (file)
@@ -20,6 +20,7 @@ from o2dms.domain.dms import NfDeployment, NfDeploymentDesc
 from o2dms.domain import commands
 from typing import Callable
 
+from o2dms.domain.exceptions import NfdeploymentNotFoundError
 from o2dms.domain import events
 from o2common.service.unit_of_work import AbstractUnitOfWork
 from helm_sdk import Helm
@@ -82,15 +83,19 @@ def handle_nfdeployment_statechanged(
 
 
 # retry 10 seconds
-@retry(tries=20, max_delay=10000)
+@retry(
+    (NfdeploymentNotFoundError),
+    tries=100,
+    delay=2, max_delay=10000, backoff=1)
 def _retry_get_nfdeployment(
         cmd: commands.InstallNfDeployment,
         uow: AbstractUnitOfWork):
     nfdeployment: NfDeployment = uow.nfdeployments.get(
         cmd.NfDeploymentId)
     if nfdeployment is None:
-        raise Exception("Cannot find NfDeployment: {}".format(
-            cmd.NfDeploymentId))
+        raise NfdeploymentNotFoundError(
+            "Cannot find NfDeployment: {}".format(
+                cmd.NfDeploymentId))
     return nfdeployment
 
 
index 8a3a607..596a616 100644 (file)
@@ -60,4 +60,4 @@ class EventState():
     Updating = 4
     Uninstalling = 5
     Abnormal = 6
-    Deleted = 7
+    Deleting = 7