Add exclusive processing to get_vnfd in v2 API

When using an external NFVO, if VNF instances with the same vnfd_id
are instantiated at the same time, one of the VNF instances will
fail to create the CSAR cache directory and will have a "ROLLED_BACK"
status.
This patch fixes the get_vnfd method so that it cannot be executed on
the same vnfd_id at the same time.

Closes-Bug: #2088124
Change-Id: I15dab7796b356376f39c9a46410f7edb9d2d8242
This commit is contained in:
Ken Fujimoto 2024-11-08 06:44:39 +00:00
parent f41acdc698
commit 7cb7070df4
2 changed files with 5 additions and 2 deletions

View File

@ -69,7 +69,7 @@ def lock_vnf_instance(inst_arg, delay=False):
return operation_lock return operation_lock
def lock_resources(res_arg, delay=False): def lock_resources(res_arg, blocking=False):
def operation_lock(func): def operation_lock(func):
@functools.wraps(func) @functools.wraps(func)
@ -84,7 +84,8 @@ def lock_resources(res_arg, delay=False):
res_id = res_arg.format(**call_args) res_id = res_arg.format(**call_args)
lock = coord.get_lock(res_id) lock = coord.get_lock(res_id)
blocking = False if not delay else 10 # NOTE: blocking can be integer and it means timeout period.
# if blocking is True, wait until lock is released.
# NOTE: 'with lock' is not used since it can't handle # NOTE: 'with lock' is not used since it can't handle
# lock failed exception well. # lock failed exception well.
if not lock.acquire(blocking=blocking): if not lock.acquire(blocking=blocking):

View File

@ -22,6 +22,7 @@ import zipfile
from oslo_log import log as logging from oslo_log import log as logging
from tacker.sol_refactored.common import config from tacker.sol_refactored.common import config
from tacker.sol_refactored.common import coordinate
from tacker.sol_refactored.common import fm_alarm_utils as alarm_utils from tacker.sol_refactored.common import fm_alarm_utils as alarm_utils
from tacker.sol_refactored.common import fm_subscription_utils as fm_utils from tacker.sol_refactored.common import fm_subscription_utils as fm_utils
from tacker.sol_refactored.common import http_client from tacker.sol_refactored.common import http_client
@ -124,6 +125,7 @@ class NfvoClient(object):
LOG.debug("grant response: %s", grant_res.to_dict()) LOG.debug("grant response: %s", grant_res.to_dict())
return grant_res return grant_res
@coordinate.lock_resources('{vnfd_id}', blocking=True)
def get_vnfd(self, context, vnfd_id, all_contents=False): def get_vnfd(self, context, vnfd_id, all_contents=False):
if self.is_local: if self.is_local:
return self.nfvo.get_vnfd(context, vnfd_id) return self.nfvo.get_vnfd(context, vnfd_id)