An error occurred when init k8s object in v1 api

Bug #1978071 reported by Yi Feng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tacker
Fix Released
Medium
Yi Feng

Bug Description

When instantiate CNF resources whose manifest file contains `exec` parameter with v1 api, an error occurred when init k8s object.
The log is shown below.
```
Apr 22 21:36:17 Tacker-On-VM2 tacker-conductor[964844]: 2022-04-22 21:36:17.546 ERROR tacker.vnfm.infra_drivers.kubernetes.k8s.translate_outputs [req-4d4deaf8-afaa-4fae-a2d7-d48a767350b6 admin admin] Deployment create failure. Reason=can only concatenate str (not "NoneType") to str
Apr 22 21:36:17 Tacker-On-VM2 tacker-conductor[964844]: 2022-04-22 21:36:17.546 ERROR tacker.vnflcm.vnflcm_driver [req-4d4deaf8-afaa-4fae-a2d7-d48a767350b6 admin admin] Unable to instantiate vnf instance c1c162d4-bc61-484b-a774-f3a6caee4cc8 due to error : Failed to init resource.: tacker.common.exceptions.InitApiFalse: Failed to init resource.
```

part of yaml_file:
```
       livenessProbe:
          exec:
            command:
            - rm
            - -f
            - /usr/local/container/CheckFile.txt

```

In the manifest file, there is an `exec` parameter, but in the kubernetes-client module, this parameter is modified to `_exec` due to the need to avoid python keywords. This processing resulted in an unrecognized `exec` parameter in the manifest file, which resulted in an error.
The following resources were found to have the same problem during the investigation.
1. `_not` of V1JsonSchemaProps
2. `_except` of V1IPBlock
3. `_continue` of V1ListMeta
4. `_from` of V1NetworkPolicyIngressRule
5. `_exec` of V1LifecycleHandler

In order to solve this problem, it is necessary to convert the above keywords into keywords that can be recognized by the kubernetes-client module.

Yi Feng (fengyi765)
Changed in tacker:
assignee: nobody → Yi Feng (fengyi765)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tacker (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/tacker/+/845655

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

Reviewed: https://review.opendev.org/c/openstack/tacker/+/845655
Committed: https://opendev.org/openstack/tacker/commit/6441914c5fa46c12b16e5545956f5a0494f07874
Submitter: "Zuul (22348)"
Branch: master

commit 6441914c5fa46c12b16e5545956f5a0494f07874
Author: Shuwen Cai <email address hidden>
Date: Tue Jun 14 11:08:31 2022 +0900

    Fix k8s init error when file contains special key

    When executing CNF lifcycle operations, if the manifest file
    contains the following parameters:
      `exec`, `not`, `except`, `continue`, `from`
    the initialization of Kubernetes resources will fail.

    To fix this issue, this patch makes changes to the `_init_k8s_obj`
    method in the `translate_outputs.py` file. When the manifest file
    contains the above parameters, it is first converted into
    parameters that can be recognized by the k8s client module and
    then initialized.

    Closes-Bug: #1978071
    Change-Id: I392e1b07152b260de775754dbe4606995f658d8d

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

This issue was fixed in the openstack/tacker 8.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.