add_dependencies does not work for floating ip resource

Bug #1384114 reported by Sergey Kraynev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Sergey Kraynev
Juno
Fix Released
High
Sergey Kraynev

Bug Description

1. create stack with template:

heat_template_version: 2013-05-23

parameters:
  public_net:
    type: string
    default: public
  cidr:
    type: string
    default: 11.11.11.0/24

resources:
  router:
    type: OS::Neutron::Router
    properties:
      external_gateway_info:
        network: {get_param: public_net}

  router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      router_id: { get_resource: router }
      subnet_id: { get_resource: private_subnet }

  private_net:
    type: OS::Neutron::Net

  private_subnet:
    type: OS::Neutron::Subnet
    properties:
      network: { get_resource: private_net }
      cidr: {get_param: cidr}

  s2_port:
    type: OS::Neutron::Port
    properties:
      network: {get_resource: private_net}
      fixed_ips:
        - subnet_id: { get_resource: private_subnet }

  s2_floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network: {get_param: public_net}
      port_id: { get_resource: s2_port }

In this stack resource floating ip should have dependency from router_interface.

But it does not work and you MAY get error during deletion:

2. [skr@ubuntu ~]$ heat event-list demos
+------------------+--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------------------+
| resource_name | id | resource_status_reason | resource_status | event_time |
+------------------+--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------------------+
| router_interface | 1392b71c-a9df-403a-a35d-797bffa5b96f | Conflict: Router interface for subnet 2281b007-05f5-49da-8af1-b25113da644b on router 561d5053-d708-4035-acca-1463a01ac5be cannot be deleted, as it is required by one or more floating IPs. | DELETE_FAILED | 2014-10-22T08:24:54Z |
| router_interface | a2bb0785-236c-4006-8333-13b2f0d2bd97 | state changed | DELETE_IN_PROGRESS | 2014-10-22T08:24:54Z |
| s2_floating_ip | c7c3d494-65f1-4aa0-9b6c-8ff43a28b0ea | state changed | CREATE_COMPLETE | 2014-10-22T08:24:46Z |
| s2_floating_ip | 32932820-3f70-4d4a-a3f0-e5bacf9940f6 | state changed | CREATE_IN_PROGRESS | 2014-10-22T08:24:45Z |
| router_interface | a61016cb-7a66-4011-a1ed-b8130cfce2e6 | state changed | CREATE_COMPLETE | 2014-10-22T08:24:45Z |
| s2_port | eb7cb453-90d0-482f-945e-f396ded33219 | state changed | CREATE_COMPLETE | 2014-10-22T08:24:45Z |
| router_interface | 2055d04e-43e2-48db-8e6f-b6b4151b6571 | state changed | CREATE_IN_PROGRESS | 2014-10-22T08:24:43Z |
| s2_port | 49fc1f88-cb72-4181-a92f-ee5168c8f6bc | state changed | CREATE_IN_PROGRESS | 2014-10-22T08:24:42Z |
| private_subnet | 97eae964-ee7e-4c6d-813e-a1ee38ef16c4 | state changed | CREATE_COMPLETE | 2014-10-22T08:24:42Z |
| private_subnet | 0a7804f3-6bc8-4351-9d26-5c68668527ef | state changed | CREATE_IN_PROGRESS | 2014-10-22T08:24:41Z |
| private_net | 4d67c463-1e97-4833-b3de-573cfe36ed9c | state changed | CREATE_COMPLETE | 2014-10-22T08:24:41Z |
| router | 281dc4ea-0bf1-40ee-a939-f68bf0745242 | state changed | CREATE_COMPLETE | 2014-10-22T08:24:41Z |
| private_net | 1957b3a1-4851-434d-a4e8-bc1692bb6aee | state changed | CREATE_IN_PROGRESS | 2014-10-22T08:24:40Z |
| router | e6f923f2-3789-4a1b-be9f-d643e9a2f4cd | state changed | CREATE_IN_PROGRESS | 2014-10-22T08:24:39Z |
+------------------+--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------------------+

3. I notice, that it MAY be reproduced with not 100 % chance.
The cause of this, that resulted graph of dependencies has two resources which may be used as first in chain for deletion (RouterInterface and FloatingIP).
When deletion starts from FIP all is ok, otherwise you will get error.

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/130176

Changed in heat:
status: New → In Progress
Steven Hardy (shardy)
tags: added: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/130176
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=29dbe697516e3e5dd38a926b76f623661cbce020
Submitter: Jenkins
Branch: master

commit 29dbe697516e3e5dd38a926b76f623661cbce020
Author: Sergey Kraynev <email address hidden>
Date: Wed Oct 22 04:16:34 2014 -0400

    Fix add_dependencies for floating_ip resource

    The cause of problem is related with tricky method of Dependencies
    class. So required_by method returns dictionary with resources which
    have current resource in dependency. In the same time port resource
    does not require floating ip, contrariwise floating ip require port.
    As result required_by will not return depended port. There is one
    way to solve issue: use dictionary of requires resources.

    Also this patch fixes missed code error with incorrect using properties
    attribute for value fixed_ip.

    Notice that both these issues were not detected, because:
     - method port_on_subnet is not executed, because required_by was always
       empty dictionary.
     - current test has shadow mistake. Dependencies for router_interface
       always contain FloatingIP resource, because router gateway also was
       presented in using templates and during creation graph FloatingIp
       automatically was added to result dictionary.

    Change-Id: Ida30e51d526a3f5d2a4d0a4102b1036f1c518302
    Closes-Bug: #1384114

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

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/130713

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

Reviewed: https://review.openstack.org/130713
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=79e23007efc7d4600a79ba9476867afdf314356a
Submitter: Jenkins
Branch: stable/juno

commit 79e23007efc7d4600a79ba9476867afdf314356a
Author: Sergey Kraynev <email address hidden>
Date: Wed Oct 22 04:16:34 2014 -0400

    Fix add_dependencies for floating_ip resource

    The cause of problem is related with tricky method of Dependencies
    class. So required_by method returns dictionary with resources which
    have current resource in dependency. In the same time port resource
    does not require floating ip, contrariwise floating ip require port.
    As result required_by will not return depended port. There is one
    way to solve issue: use dictionary of requires resources.

    Also this patch fixes missed code error with incorrect using properties
    attribute for value fixed_ip.

    Notice that both these issues were not detected, because:
     - method port_on_subnet is not executed, because required_by was always
       empty dictionary.
     - current test has shadow mistake. Dependencies for router_interface
       always contain FloatingIP resource, because router gateway also was
       presented in using templates and during creation graph FloatingIp
       automatically was added to result dictionary.

    Change-Id: Ida30e51d526a3f5d2a4d0a4102b1036f1c518302
    Closes-Bug: #1384114
    (cherry picked from commit 29dbe697516e3e5dd38a926b76f623661cbce020)

Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: kilo-1 → 2015.1.0
Zane Bitter (zaneb)
tags: added: in-stable-juno
removed: juno-backport-potential
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.