Missing required parameter of LimitRange in translate_outputs._create_k8s_object

Bug #1940602 reported by Ayumu Ueha
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tacker
Fix Released
Undecided
Unassigned

Bug Description

While deploying CNF(deployment) using LimitRange, a parameter error happened:

```
Traceback (most recent call last):
  File "/home/zuul/src/opendev.org/openstack/tacker/tacker/vnfm/infra_drivers/kubernetes/k8s/translate_outputs.py", line 303, in get_k8s_objs_from_yaml
    k8s_obj['object'] = self._create_k8s_object(
  File "/home/zuul/src/opendev.org/openstack/tacker/tacker/vnfm/infra_drivers/kubernetes/k8s/translate_outputs.py", line 283, in _create_k8s_object
    self._init_k8s_obj(k8s_obj, file_content_dict, must_param)
  File "/home/zuul/src/opendev.org/openstack/tacker/tacker/vnfm/infra_drivers/kubernetes/k8s/translate_outputs.py", line 453, in _init_k8s_obj
    self._init_k8s_obj(rely_obj, value, must_param)
  File "/home/zuul/src/opendev.org/openstack/tacker/tacker/vnfm/infra_drivers/kubernetes/k8s/translate_outputs.py", line 469, in _init_k8s_obj
    eval('client.' + rely_obj_name + '()')
  File "<string>", line 1, in <module>
  File "/home/zuul/src/opendev.org/openstack/tacker/.tox/py38/lib/python3.8/site-packages/kubernetes/client/models/v1_limit_range_item.py", line 77, in __init__
    self.type = type
  File "/home/zuul/src/opendev.org/openstack/tacker/.tox/py38/lib/python3.8/site-packages/kubernetes/client/models/v1_limit_range_item.py", line 215, in type
    raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
ValueError: Invalid value for `type`, must not be `None`
```

This is caused by `type` parameter is required while deploying LimitRange resource:
https://github.com/kubernetes-client/python/blob/release-18.0/kubernetes/docs/V1LimitRangeItem.md

Changes to the type mandatory parameter for V1LimitRangeItem have been made since v18.0.0 and the problem is now caused by the release of kubernetes v18.20.0 on 2021/8/17.
https://pypi.org/project/kubernetes/#history

Fix:

in tacker/vnfm/infra_drivers/kubernetes/k8s/translate_outputs.py,

https://opendev.org/openstack/tacker/src/branch/master/tacker/vnfm/infra_drivers/kubernetes/k8s/translate_outputs.py#L168

add `'V1LimitRangeItem': '(type="")'` to must_param

Changed in tacker:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tacker (master)

Reviewed: https://review.opendev.org/c/openstack/tacker/+/791123
Committed: https://opendev.org/openstack/tacker/commit/26a2b5fce201641b89ca3d7a432e23df779e5cf3
Submitter: "Zuul (22348)"
Branch: master

commit 26a2b5fce201641b89ca3d7a432e23df779e5cf3
Author: LiangLu <email address hidden>
Date: Thu May 13 17:26:56 2021 +0900

    Fix missing required parameter when k8s_obj init

    While deploying CNF(deployment) using pod-affinity rules, a
    parameter error happended because the topology_key is not
    assigned when initializing k8s object.

    This patch fixes this bug by adding the topology_key's default
    value into `must_param` in translate_outputs._create_k8s_object().
    At the same time, in order to deal with the recurrence of this
    kind of bug, we checked the required parameters of all resources
    in kubernetes again and added them to must_param.
        * Kubernetes version: from v1.18.20 to v1.21.1
        * Kubernetes-python-client version: v18.20.0

    The major changes from the "must_param" used in the previous
    Wallaby release of Tacker are probably as follows:

    RuntimeRawExtension
      The `data` parameter of `V1ControllerRevision`[1] in v11.0.0
      was `RuntimeRawExtension`[2], but the `RuntimeRawExtension` was
      not support for v12.0.0 or later. Therefore `V1ControllerRevision`
      in v18.20.0[3] it has been changed to` object` type.

    V1ServiceReference
      The `service` parameter of `V1APIServiceSpec`[4] in v11.0.0 was
      `V1ServiceReference`[5], but the `V1ServiceReference` was not
      support for v12.0.0 or later.
      Therefore `V1APIServiceSpec` in v18.20.0[6] it has been changed
      to `ApiregistrationV1ServiceReference`[7].

    V1LimitRangeItem
      The `type` parameter of `V1LimitRangeItem`[8] in v11.0.0 was
      optional type, but the parameter has changed to must param
      in v18.20.0[9].
      Therefore, the parameter should be added into `must_param`.

    [1] https://github.com/kubernetes-client/python/blob/v11.0.0/kubernetes/docs/V1ControllerRevision.md
    [2] https://github.com/kubernetes-client/python/blob/v11.0.0/kubernetes/docs/RuntimeRawExtension.md
    [3] https://github.com/kubernetes-client/python/blob/v18.20.0/kubernetes/docs/V1ControllerRevision.md
    [4] https://github.com/kubernetes-client/python/blob/v11.0.0/kubernetes/docs/V1APIServiceSpec.md
    [5] https://github.com/kubernetes-client/python/blob/v11.0.0/kubernetes/docs/V1ServiceReference.md
    [6] https://github.com/kubernetes-client/python/blob/v18.20.0/kubernetes/docs/V1APIServiceSpec.md
    [7] https://github.com/kubernetes-client/python/blob/v18.20.0/kubernetes/docs/ApiregistrationV1ServiceReference.md
    [8] https://github.com/kubernetes-client/python/blob/v11.0.0/kubernetes/docs/V1LimitRangeItem.md
    [9] https://github.com/kubernetes-client/python/blob/v18.20.0/kubernetes/docs/V1LimitRangeItem.md

    Closes-Bug: #1928153
    Closes-Bug: #1940602
    Change-Id: If77be98d0c4cec6f4c860ae84978f59772f9a6ee

Changed in tacker:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tacker 6.0.0.0rc1

This issue was fixed in the openstack/tacker 6.0.0.0rc1 release candidate.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.