From: Bin Yang Date: Mon, 24 Jan 2022 04:02:11 +0000 (+0800) Subject: Fix nfdeployment handler issue X-Git-Tag: 2.0.0-rc1~58 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=5143e92a36bd2142e04d0d80dbc60d68c3da03d7;p=pti%2Fo2.git Fix nfdeployment handler issue change retry param to workaround retry in 0 seconds issue Issue-ID: INF-258 Signed-off-by: Bin Yang Change-Id: I2c2717c4a24b7182156e69d0924259bd6afded8f --- diff --git a/o2common/domain/commands.py b/o2common/domain/commands.py index 51d695f..d5af671 100644 --- a/o2common/domain/commands.py +++ b/o2common/domain/commands.py @@ -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 index 0000000..dac86f3 --- /dev/null +++ b/o2common/domain/exceptions.py @@ -0,0 +1,18 @@ +# Copyright (C) 2022 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# pylint: disable=too-few-public-methods + +class Orano2Exception(Exception): + pass diff --git a/o2dms/domain/exceptions.py b/o2dms/domain/exceptions.py new file mode 100644 index 0000000..688392e --- /dev/null +++ b/o2dms/domain/exceptions.py @@ -0,0 +1,22 @@ + +# Copyright (C) 2022 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# pylint: disable=too-few-public-methods + +from o2common.domain.exceptions import Orano2Exception + + +class NfdeploymentNotFoundError(Orano2Exception): + pass diff --git a/o2dms/domain/states.py b/o2dms/domain/states.py index 1c98d49..1f1b434 100644 --- a/o2dms/domain/states.py +++ b/o2dms/domain/states.py @@ -26,5 +26,5 @@ class NfDeploymentState(): Updating = 4 Uninstalling = 5 Abnormal = 6 - Deleted = 7 + Deleting = 7 # Aborting = 8 diff --git a/o2dms/service/nfdeployment_handler.py b/o2dms/service/nfdeployment_handler.py index c6a40ff..665e03e 100644 --- a/o2dms/service/nfdeployment_handler.py +++ b/o2dms/service/nfdeployment_handler.py @@ -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 diff --git a/o2ims/domain/subscription_obj.py b/o2ims/domain/subscription_obj.py index 8a3a607..596a616 100644 --- a/o2ims/domain/subscription_obj.py +++ b/o2ims/domain/subscription_obj.py @@ -60,4 +60,4 @@ class EventState(): Updating = 4 Uninstalling = 5 Abnormal = 6 - Deleted = 7 + Deleting = 7