Create pod failed due to invalid parameter

Bug #1667192 reported by Chaoyi Huang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-tricircleclient
Fix Released
Medium
Sindhu Devale

Bug Description

If we want to add a new pod in Tricircle, issue command like:

openstack --debug --os-region-name=CentralRegion multiregion networking pod create --region-name RegionThree --availability-zone az3

then failure will happen, it's because that the command is translated into curl:

REQ: curl -g -i -X POST http://162.3.124.203:19999/v1.0/pods -H "User-Agent: osc-lib/1.3.0 keystoneauth1/2.18.0 python-requests/2.12.5 CPython/2.7.12" -H "Content-Type: application/json" -H "Accept: application/json, */*" -H "X-Auth-Token: {SHA1}7f9c1fcaea66aca24e1ac93140c04a93eb0e8da2" -d '{"pod": {"dc_name": null, "az_name": "az3", "region_name": "RegionThree", "pod_az_name": null}}'

"dc_name" and pod_az_name are not provided in the command, so it should not be passed as "null" in curl request, these two parameter are no need to be included in the curl request, i.e, if it's optional parameter, then there is no need to use "null" value in the curl request...

Changed in python-tricircleclient:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Sindhu Devale (sindhu-devale-3)
Revision history for this message
Victor Morales (electrocucaracha) wrote :

Sindhu,

The main problem is that those values are optional but they considered as required in the _pod_from_args function, can you apply this change?

diff --git a/tricircleclient/v1/pods_cli.py b/tricircleclient/v1/pods_cli.py
index 232247e..73cbef0 100644
--- a/tricircleclient/v1/pods_cli.py
+++ b/tricircleclient/v1/pods_cli.py
@@ -46,11 +46,20 @@ class CreatePod(command.ShowOne):

     @staticmethod
     def _pod_from_args(parsed_args):
- return {'pod': {'region_name': parsed_args.region_name,
- 'az_name': parsed_args.availability_zone,
- 'pod_az_name': parsed_args.pod_availability_zone,
- 'dc_name': parsed_args.data_center,
- }}
+ result = {
+ 'pod':
+ {
+ 'region_name': parsed_args.region_name,
+ 'az_name': parsed_args.availability_zone,
+ }
+ }
+ if parsed_args.pod_availability_zone:
+ result['pod_az_name'] = parsed_args.pod_availability_zone
+
+ if parsed_args.data_center:
+ result['dc_name'] = parsed_args.data_center
+
+ return result

     def get_parser(self, prog_name):
         parser = super(CreatePod, self).get_parser(prog_name)

Revision history for this message
Chaoyi Huang (joehuang) wrote :

It could be more flexible like:

        pod = {}

        if parsed_args.region_name:
            pod['region_name'] = parsed_args.region_name

        if parsed_args.availability_zone:
            pod['az_name'] = parsed_args.availability_zone

        if parsed_args.pod_availability_zone:
            pod['pod_az_name'] = parsed_args.pod_availability_zone

        if parsed_args.data_center:
            pod['dc_name'] = parsed_args.data_center

        return {'pod': pod}

Tricircle will validate the request body too.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-tricircleclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/437739

Changed in python-tricircleclient:
status: Confirmed → In Progress
Changed in python-tricircleclient:
assignee: Sindhu Devale (sindhu-devale-3) → Chaoyi Huang (joehuang)
assignee: Chaoyi Huang (joehuang) → Victor Morales (electrocucaracha)
Changed in python-tricircleclient:
assignee: Victor Morales (electrocucaracha) → Sindhu Devale (sindhu-devale-3)
Changed in python-tricircleclient:
assignee: Sindhu Devale (sindhu-devale-3) → Victor Morales (electrocucaracha)
Changed in python-tricircleclient:
assignee: Victor Morales (electrocucaracha) → Sindhu Devale (sindhu-devale-3)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-tricircleclient (master)

Reviewed: https://review.openstack.org/437739
Committed: https://git.openstack.org/cgit/openstack/python-tricircleclient/commit/?id=4bebbc9a92b3ec509b6f94723e8c13e72caf378a
Submitter: Jenkins
Branch: master

commit 4bebbc9a92b3ec509b6f94723e8c13e72caf378a
Author: Sindhu Devale <email address hidden>
Date: Fri Feb 24 00:15:50 2017 +0000

    Fix bug while creating a pod

    1. What is the problem?
    Only region_name is the required field. So if other
    arguments are not given, currently the client assign null
    value in the curl request, which results in the failure
    of `openstack multiregion networking pod create` command.

    2. What is the solution to the problem?
    Current handling of input parameters

    3. What features need to be implemented to the Tricircle
       to realize the solution?
    None

    Closes-Bug: #1667192
    Change-Id: Iabf3204dd9907340180c200f324008503cd96647
    Co-Authored-By: Victor Morales <email address hidden>

Changed in python-tricircleclient:
status: In Progress → Fix Released
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.