nova instance-action fails if project_id=NULL

Bug #1817542 reported by Belmiro Moreira
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Takashi Natsume
Rocky
Fix Committed
High
Takashi Natsume

Bug Description

nova instance-action fails if project_id=NULL

Starting in api version 2.62 "an obfuscated hashed host id is returned"
To generate the host_id it uses utils.generate_hostid() that uses (in this case) the project_id and the host of the action.

However, we can have actions without a user_id/project_id defined.
For example, when something happens outside nova API (user shutdown the VM inside the guest OS).
In this case we have an action "stop", without a user_id/project_id.

When running 2.62 it fails when performing:
nova instance-action <instance_uuid> <req_uuid>

no issues if using:
--os-compute-api-version 2.60

===
The trace in nova-api logs:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nova/api/openstack/wsgi.py", line 801, in wrapped
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/instance_actions.py", line 169, in show
    ) for evt in events_raw]
  File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/instance_actions.py", line 69, in _format_event
    project_id)
  File "/usr/lib/python2.7/site-packages/nova/utils.py", line 1295, in generate_hostid
    data = (project_id + host).encode('utf-8')
TypeError: unsupported operand type(s) for +: 'NoneType' and 'unicode'

Tags: api
Changed in nova:
assignee: nobody → Takashi NATSUME (natsume-takashi)
Changed in nova:
status: New → 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.openstack.org/639936

Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/639936
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=31fe7c76009e1c6d7859036e44b057d081b059b5
Submitter: Zuul
Branch: master

commit 31fe7c76009e1c6d7859036e44b057d081b059b5
Author: Takashi NATSUME <email address hidden>
Date: Thu Feb 28 13:49:41 2019 +0900

    Fix an error when generating a host ID

    When instance action events are created by periodic tasks,
    the project IDs of them become null (None).
    It causes an error when 'hostId' is generated
    in the "Show Server Action Details"
    (GET /servers/{server_id}/os-instance-actions/{request_id})
    API.

    Fix the issue by using the project ID of the server
    if the project ID of the event is None.

    Change-Id: Iac07fcddd4cc3321c6efe702066eb8af6a875418
    Closes-Bug: #1817542

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.openstack.org/641173

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

Reviewed: https://review.openstack.org/641173
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=e2185168f812286dd140936df64261e67568a410
Submitter: Zuul
Branch: stable/rocky

commit e2185168f812286dd140936df64261e67568a410
Author: Takashi NATSUME <email address hidden>
Date: Thu Feb 28 13:49:41 2019 +0900

    Fix an error when generating a host ID

    When instance action events are created by periodic tasks,
    the project IDs of them become null (None).
    It causes an error when 'hostId' is generated
    in the "Show Server Action Details"
    (GET /servers/{server_id}/os-instance-actions/{request_id})
    API.

    Fix the issue by using the project ID of the server
    if the project ID of the event is None.

    Conflicts:
        nova/tests/unit/api/openstack/compute/test_instance_actions.py

        The conflicts are due to not having the following
        changes in Rocky.

        I7f5f08691ca3f73073c66c29dddb996fb2c2b266
        If91c179e3823c8b0da744a9363906b0f7b05c326
        I44546bc9798708a48a250cc3a21bdbcabe2649e1

    Change-Id: Iac07fcddd4cc3321c6efe702066eb8af6a875418
    Closes-Bug: #1817542
    (cherry picked from commit 31fe7c76009e1c6d7859036e44b057d081b059b5)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 19.0.0.0rc1

This issue was fixed in the openstack/nova 19.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 18.2.0

This issue was fixed in the openstack/nova 18.2.0 release.

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.