Compute API in nova - show/list servers with details says security_groups is required in response but it's optional

Bug #1846656 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Takashi Natsume

Bug Description

- [x] This doc is inaccurate in this way:

This came up in review:

https://review.opendev.org/#/c/685927/2//COMMIT_MSG@9

https://docs.openstack.org/api-ref/compute/#show-server-details

and

https://docs.openstack.org/api-ref/compute/#list-servers-detailed

response parameter tables both say that "security_groups" is a required field in the response but that's not true if the server does not have any attached ports which is possible. This is the server view builder code:

https://github.com/openstack/nova/blob/867401e575d2b27b9bc63ceda41cd85233545cd5/nova/api/openstack/compute/views/servers.py#L627

Note the key is not in the GET response if the server is not attached to any ports that have security groups.

I recreated in devstack by creating a server with no network:

$ openstack --os-compute-api-version 2.37 server create --flavor m1.tiny --image cirros-0.4.0-x86_64-disk --nic none --wait vm-no-net

And the security_groups key is not in the GET /servers/detail response:

$ curl -H "X-Auth-Token: $token" http://10.128.0.6/compute/v2.1/servers/detail | python -m json.tool | grep security_groups
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1388 100 1388 0 0 8213 0 --:--:-- --:--:-- --:--:-- 8213

-----------------------------------
Release: on 2019-09-19 17:55:19
SHA: 9ca14e081860b1abcc0d676f253a472028690e29
Source: https://opendev.org/openstack/nova/src/api-ref/source/index.rst
URL: https://docs.openstack.org/api-ref/compute/

Changed in nova:
assignee: nobody → Takashi NATSUME (natsume-takashi)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/686517

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.opendev.org/686517
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a7c3108bf78d2f48b48876a491ecbc69a7ce984f
Submitter: Zuul
Branch: master

commit a7c3108bf78d2f48b48876a491ecbc69a7ce984f
Author: Takashi NATSUME <email address hidden>
Date: Fri Oct 4 11:37:55 2019 +0900

    api-ref: Fix security groups parameters

    The security groups parameters are optional
    in the response of the following APIs.

    - GET /servers/detail
    - GET /servers/{server_id}
    - PUT /servers/{server_id}
    - POST /servers/{server_id}/action (rebuild)

    So fix them.

    Change-Id: Icc2315fd8b8c085de9d560de6ddf4c05aaaf6acb
    Closes-Bug: #1846656

Changed in nova:
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.