"openstack volume create" sending null values in create requests

Bug #1750399 reported by Lars Kellogg-Stedman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Confirmed
Undecided
Chaemin Lim

Bug Description

The "openstack volume create" command is sending null values for unset fields in create requests. For example, when running "openstack volume create --size 1 testvolume", the result request is:

  {
  "volume": {
    "status": "creating",
    "user_id": null,
    "name": "testvolume",
    "imageRef": null,
    "availability_zone": null,
    "description": null,
    "multiattach": false,
    "attach_status": "detached",
    "volume_type": null,
    "metadata": {},
    "consistencygroup_id": null,
    "source_volid": null,
    "snapshot_id": null,
    "project_id": null,
    "source_replica": null,
    "size": 1
  }
  }

Unset fields should probably be omitted from the request rather than sent as null.

Chaemin Lim (antraxmin)
Changed in python-openstackclient:
assignee: nobody → 임채민 (antraxmin)
Revision history for this message
Chaemin Lim (antraxmin) wrote :

Hello, I tried to analyze the code to resolve this issue.
After adding debugging logs and checking actual API requests, I found the following:

If you add code to filter null values in the python-openstackclient:
volume_args = {k: v for k, v in volume_args.items() if v is not None}
The actual API request still included a null value.

Debug Log Results:
Volume args before filtering: {'size': 1, 'snapshot_id': None, ...}
Volume args after filtering: {'size': 1, 'name': 'test_volume'}
Final volume args being passed to create(): {'size': 1, 'name': 'test_volume'}

However, actual API requests:
REQ: -d '{"volume": {"size": 1, "consistencygroup_id": null, "snapshot_id": null, ...}}'

When I checked the code in python-cinderclient, the create method in the v3/volumes.py file included all parameters in the API request as they were without null value filtering:
body = {'volume': {'size': size, 'consistencygroup_id': consistencygroup_id, ...}}

Therefore, I decided that both projects needed to be fixed to completely resolve this bug
- python-openstackclient:adding null value filtering code
- python-cinderclient: add null value filtering logic in create method

I'd appreciate it if you could review what I analyzed and if the approach is correct. Please advise if there is anything you missed or if you need to consider other approaches.

Revision history for this message
Alexey Stupnikov (astupnikov) wrote :

I can see that reported behavior is reproducible.

REQ: curl -g -i -X POST http://192.168.122.198/volume/v3/volumes -H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-cinderclient" -H "X-Auth-Token: {SHA256}0c54f45882461f69327151ab4928988d1b6d3f628f959ab27394802096b7da94" -d '{"volume": {"size": 1, "consistencygroup_id": null, "snapshot_id": null, "name": "testvolume", "description": null, "volume_type": null, "availability_zone": null, "metadata": {}, "imageRef": null, "source_volid": null, "backup_id": null}}'

Changed in python-openstackclient:
status: New → Confirmed
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.