Set default namespace when caling k8s scale API

The error is occur on calling read/patch_xxx_scale API of kubernetes
python client when using manifest that has no namespace in Helm chart.
This patch fixes this problem by setting namespace to "default" if it
is an empty string or None.

Closes-Bug: #1953477
Change-Id: I5f5bc38c023bbe7674c7513e4a0609c217936595
changes/98/820698/3
Ayumu Ueha 10 months ago
parent e501198b0f
commit e2fa03fb7b
  1. 6
      tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py

@ -1229,6 +1229,8 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
if name == vdu_properties.get('name'):
namespace = vnf_resource.resource_name.\
split(COMMA_CHARACTER)[0]
if not namespace:
namespace = "default"
kind = vnf_resource.resource_type.\
split(COMMA_CHARACTER)[1]
if kind in target_kinds:
@ -1384,6 +1386,8 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
if name == vdu_properties.get('name'):
namespace = vnf_resource.resource_name.\
split(COMMA_CHARACTER)[0]
if not namespace:
namespace = "default"
kind = vnf_resource.resource_type.\
split(COMMA_CHARACTER)[1]
if kind in target_kinds:
@ -2128,6 +2132,8 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
vnfc_resource.metadata.get(info['kind']))
info['name'] = rsc_metadata.get('name')
info['namespace'] = rsc_metadata.get('namespace')
if not info['namespace']:
info['namespace'] = "default"
k8s_resources.append(info)
# exclude duplicate entries
k8s_resources = list(map(jsonutils.loads,

Loading…
Cancel
Save