Comment 21 for bug 1378904

Submitter: Zuul
Branch: stable/rocky

commit 1559db570452cd5502b8f5e9ba44fef54295537f
Author: Andrey Volkov <email address hidden>
Date: Tue Oct 3 15:42:55 2017 +0300

    Check hosts have no instances for AZ rename

    Update aggregate and update aggregate metadata API calls have the
    ability to update availability zone name for the aggregate. If the
    aggregate is not empty (has hosts with instances on it)
    the update leads to discrepancy for objects saving availability zone as a
    string but not reference.

    From devstack DB they are:
    - cinder.backups.availability_zone
    - cinder.consistencygroups.availability_zone
    - cinder.groups.availability_zone
    - cinder.volumes.availability_zone
    - neutron.agents.availability_zone
    - neutron.networks.availability_zone_hints
    - neutron.router_extra_attributes.availability_zone_hints
    - nova.dns_domains.availability_zone
    - nova.instances.availability_zone
    - nova.volume_usage_cache.availability_zone
    - nova.shadow_dns_domains.availability_zone
    - nova.shadow_instances.availability_zone
    - nova.shadow_volume_usage_cache.availability_zone

    Why that's bad?
    First, API and Horizon show different values for host and instance for
    example. Second, migration for instances with changed availability
    zone fails with "No valid host found" for old AZ.

    This change adds an additional check to aggregate an Update Aggregate API call.
    With the check, it's not possible to rename AZ if the corresponding
    aggregate has instances in any hosts.

    PUT /os-aggregates/{aggregate_id} and
    POST /os-aggregates/{aggregate_id}/action return HTTP 400 for
    availability zone renaming if the hosts of the aggregate have any instances.
    It's similar to conflicting AZ names error already available.

    Change-Id: Ic27195e46502067c87ee9c71a811a3ca3f610b73
    Closes-Bug: #1378904
    (cherry picked from commit 8e19ef4173906da0b7c761da4de0728a2fd71e24)