Comment 3 for bug 1693600

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

Reviewed: https://review.openstack.org/468147
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=91bd79058abf79978335010a325952f17729d7a5
Submitter: Jenkins
Branch: master

commit 91bd79058abf79978335010a325952f17729d7a5
Author: Matt Riedemann <email address hidden>
Date: Thu May 25 15:46:22 2017 -0400

    Avoid lazy-load error when getting instance AZ

    When [cinder]cross_az_attach=False (not the default) and doing
    boot from volume, the API code validates the BDM by seeing if
    the instance and the volume are in the same availability zone.
    To get the AZ for the instance, the code is first trying to get
    the instance.host value.

    In Ocata we stopped creating the instance in the API and moved that
    to conductor for cells v2. So the Instance object in this case now
    is created in the _provision_instances method and stored in the
    BuildRequest object. Since there is no host to set on the instance
    yet and the Instance object wasn't populated from DB values, which
    before would set the host field on the instance object to None by
    default, trying to get instance.host will lazy-load the field and
    it blows up with ObjectActionError.

    The correct thing to do here is check if the host attribute is set
    on the Instance object. There is clear intent to assume host is
    not set in the instance since it was using instance.get('host'),
    probably from way back in the days when the instance in this case
    was a dict. So it's expecting to handle None, but we need to
    modernize how that is checked.

    Change-Id: I0dccb6a416dfe0eae4f7c52dfc28786a449b17bd
    Closes-Bug: #1693600