From: garciadeblas Date: Fri, 19 Jul 2024 10:08:07 +0000 (+0200) Subject: Feature 11014 - Fix upgrade params for KDU in case of reset_values X-Git-Tag: release-v16.0-start~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=8eb84d5cf2a0f4ea2ec4684fec1b6b7fd9a0ccbe;p=osm%2FLCM.git Feature 11014 - Fix upgrade params for KDU in case of reset_values Change-Id: Ia5167ddcbb8c1bee2f9bf85bbce0b82522077412 Signed-off-by: garciadeblas --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 3225f3e..a947949 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -5235,9 +5235,6 @@ class NsLcm(LcmBase): if kdu_name and ( primitive_name in ("upgrade", "rollback", "status") or kdu_action ): - # kdur and desc_params already set from before - if primitive_params: - desc_params.update(primitive_params) # TODO Check if we will need something at vnf level for index, kdu in enumerate(get_iterable(nsr_deployed, "K8s")): if ( @@ -5266,21 +5263,20 @@ class NsLcm(LcmBase): + "Exec k8s {} on {}.{}".format(primitive_name, vnf_index, kdu_name) ) step = "Executing kdu {}".format(primitive_name) - if primitive_name == "upgrade": - if desc_params.get("kdu_model"): - kdu_model = desc_params.get("kdu_model") - del desc_params["kdu_model"] + if primitive_name == "upgrade" and primitive_params: + if primitive_params.get("kdu_model"): + kdu_model = primitive_params.pop("kdu_model") else: kdu_model = kdu.get("kdu-model") if kdu_model.count("/") < 2: # helm chart is not embedded parts = kdu_model.split(sep=":") if len(parts) == 2: kdu_model = parts[0] - if desc_params.get("kdu_atomic_upgrade"): - atomic_upgrade = desc_params.get( + if primitive_params.get("kdu_atomic_upgrade"): + atomic_upgrade = primitive_params.get( "kdu_atomic_upgrade" ).lower() in ("yes", "true", "1") - del desc_params["kdu_atomic_upgrade"] + del primitive_params["kdu_atomic_upgrade"] else: atomic_upgrade = True # Type of upgrade: reset, reuse, reset_then_reuse @@ -5290,22 +5286,22 @@ class NsLcm(LcmBase): # If no option is specified, default behaviour is reuse_values # Otherwise, options will be parsed and used if ( - ("kdu_reset_values" not in desc_params) - and ("kdu_reuse_values" not in desc_params) - and ("kdu_reset_then_reuse_values" not in desc_params) + ("kdu_reset_values" not in primitive_params) + and ("kdu_reuse_values" not in primitive_params) + and ("kdu_reset_then_reuse_values" not in primitive_params) ): reuse_values = True else: - if desc_params.get("kdu_reset_values"): - reset_values = desc_params.pop( + if primitive_params.get("kdu_reset_values"): + reset_values = primitive_params.pop( "kdu_reset_values" ).lower() in ("yes", "true", "1") - if desc_params.get("kdu_reuse_values"): - reuse_values = desc_params.pop( + if primitive_params.get("kdu_reuse_values"): + reuse_values = primitive_params.pop( "kdu_reuse_values" ).lower() in ("yes", "true", "1") - if desc_params.get("kdu_reset_then_reuse_values"): - reset_then_reuse_values = desc_params.get( + if primitive_params.get("kdu_reset_then_reuse_values"): + reset_then_reuse_values = primitive_params.get( "kdu_reset_then_reuse_values" ).lower() in ("yes", "true", "1") # Two true options are not possible @@ -5316,7 +5312,11 @@ class NsLcm(LcmBase): raise LcmException( "Cannot upgrade the KDU simultaneously with two true options to handle values" ) - + # kdur and desc_params already set from before + if reset_values: + desc_params = primitive_params + else: + desc_params.update(primitive_params) detailed_status = await asyncio.wait_for( self.k8scluster_map[kdu["k8scluster-type"]].upgrade( cluster_uuid=kdu.get("k8scluster-uuid"),