Incorrect updating and deleting OS::Nova::HostAggregate

Bug #1520221 reported by Peter Razumovsky
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Rico Lin

Bug Description

host aggregate resource is incorrectly updates and deletes.

First case: If there's no difference in hosts property, handle_update incorrectly resolves and decides that all hosts, specified during creation, should be deleted. For example, on create we have next template:

heat_template_version: 2015-10-15

resources:
  ha:
    type: OS::Nova::HostAggregate
    properties:
      name: ha
      availability_zone: internal
      hosts:
        - ubuntu
      metadata:
        rar: zip

And on update we change only metadata:

heat_template_version: 2015-10-15

resources:
  ha:
    type: OS::Nova::HostAggregate
    properties:
      name: ha
      availability_zone: internal
      hosts:
        - ubuntu
      metadata:
        rar: zip
        test: test

Resource updated but when we call resource-show, we get: http://paste.openstack.org/show/480108/

Second case: HostAggregate cannot be deleted. When we trying to delete the resource, next error occurres:

BadRequest: Cannot remove host from aggregate 3. Reason: Host aggregate is not empty. (HTTP 400) (Request-ID: req-5b1bb325-e272-498a-866d-a6a971fb0f84)

Traceback of this error:

2015-11-26 15:49:11.732 TRACE heat.engine.resource Traceback (most recent call last):
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/resource.py", line 636, in _action_recorder
2015-11-26 15:49:11.732 TRACE heat.engine.resource yield
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/resource.py", line 1287, in delete
2015-11-26 15:49:11.732 TRACE heat.engine.resource yield self.action_handler_task(action, *action_args)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/scheduler.py", line 295, in wrapper
2015-11-26 15:49:11.732 TRACE heat.engine.resource step = next(subtask)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/resource.py", line 677, in action_handler_task
2015-11-26 15:49:11.732 TRACE heat.engine.resource handler_data = handler(*args)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/resource.py", line 1247, in handle_delete
2015-11-26 15:49:11.732 TRACE heat.engine.resource self.client_plugin().ignore_not_found(ex)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/clients/client_plugin.py", line 82, in __call__
2015-11-26 15:49:11.732 TRACE heat.engine.resource six.reraise(exc_type, exc_val, traceback)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/opt/stack/heat/heat/engine/resource.py", line 1245, in handle_delete
2015-11-26 15:49:11.732 TRACE heat.engine.resource obj.delete(self.resource_id)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/usr/local/lib/python2.7/dist-packages/novaclient/v2/aggregates.py", line 95, in delete
2015-11-26 15:49:11.732 TRACE heat.engine.resource self._delete('/os-aggregates/%s' % (base.getid(aggregate)))
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/usr/local/lib/python2.7/dist-packages/novaclient/base.py", line 181, in _delete
2015-11-26 15:49:11.732 TRACE heat.engine.resource _resp, _body = self.api.client.delete(url)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 455, in delete
2015-11-26 15:49:11.732 TRACE heat.engine.resource return self._cs_request(url, 'DELETE', **kwargs)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 424, in _cs_request
2015-11-26 15:49:11.732 TRACE heat.engine.resource resp, body = self._time_request(url, method, **kwargs)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 397, in _time_request
2015-11-26 15:49:11.732 TRACE heat.engine.resource resp, body = self.request(url, method, **kwargs)
2015-11-26 15:49:11.732 TRACE heat.engine.resource File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 391, in request
2015-11-26 15:49:11.732 TRACE heat.engine.resource raise exceptions.from_response(resp, body, url, method)
2015-11-26 15:49:11.732 TRACE heat.engine.resource BadRequest: Cannot remove host from aggregate 3. Reason: Host aggregate is not empty. (HTTP 400) (Request-ID: req-5b1bb325-e272-498a-866d-a6a971fb0f84)

Changed in heat:
assignee: nobody → huangtianhua (huangtianhua)
Revision history for this message
huangtianhua (huangtianhua) wrote :

The second case I didn't reproduce. I can delete the stack successful.

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

Fix proposed to branch: master
Review: https://review.openstack.org/251035

Changed in heat:
status: New → In Progress
Changed in heat:
assignee: huangtianhua (huangtianhua) → Rico Lin (rico-lin)
Changed in heat:
assignee: Rico Lin (rico-lin) → Sergey Kraynev (skraynev)
Changed in heat:
assignee: Sergey Kraynev (skraynev) → huangtianhua (huangtianhua)
Changed in heat:
assignee: huangtianhua (huangtianhua) → Rico Lin (rico-lin)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/251035
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=385aa7d2dcf62414cb18ecf2c3f44315527a89bf
Submitter: Jenkins
Branch: master

commit 385aa7d2dcf62414cb18ecf2c3f44315527a89bf
Author: huangtianhua <email address hidden>
Date: Sat Nov 28 18:37:43 2015 +0800

    Correct errors of HostAggregate handling

    This patch changes:
    1. Avoid empty value for 'metadata', to avoid
       BadRequest error raise if user remove this property from
       template when updation, also avoid unnecessary hit to db.

    2. Won't remove the hosts if there is no change when updation.

    3. Remove hosts before delete HostAggregate

    Co-Authored-By: Rico Lin <email address hidden>

    Closes-Bug: #1520221
    Change-Id: I726f7229c6be55113c73dbbb2f8e7ddbdabab610

Changed in heat:
status: In Progress → Fix Released
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/heat 6.0.0.0b2

This issue was fixed in the openstack/heat 6.0.0.0b2 development milestone.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

This issue was fixed in the openstack/heat 6.0.0.0b2 development milestone.

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.