Comment 2 for bug 1792245

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

Reviewed: https://review.openstack.org/602173
Committed: https://git.openstack.org/cgit/openstack/blazar/commit/?id=77c1a2b683716482cc8f64bfc3ca47708802e2f6
Submitter: Zuul
Branch: master

commit 77c1a2b683716482cc8f64bfc3ca47708802e2f6
Author: Pierre Riteau <email address hidden>
Date: Thu Sep 13 11:35:55 2018 -0600

    Handle requirements set to empty strings

    If hypervisor_properties or resource_properties are set to empty strings
    by the API client, they are persisted as empty strings in the database.
    However, in convert_requirements(), the code assumes they are JSON
    strings and tries to parse them, which raises a MalformedRequirements
    exception.

    This can be triggered by an operator when updating an extra capability
    on a node that is reserved with resource_properties set to an empty
    string, as is_updatable_extra_capability() calls convert_requirements().
    Blazar would return a 400 Client Error to them.

    Ideally, only valid JSON should be persisted to the database. However,
    this will require an Alembic migration to change existing empty strings
    to empty JSON arrays. In the meantime, this simpler patch can be
    backported to stable branches.

    Change-Id: Ic6d18418a2515cd37bbeed25ee3ab8c360624ca3
    Closes-Bug: #1792245