Server is missing network info after update its nic

Bug #1584623 reported by huangtianhua
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
huangtianhua

Bug Description

1. create a instance with the template:
*************************************
heat_template_version: 2015-04-30
parameters:
  net:
    type: string
    default: 05d8e681-4b37-4570-bc8d-810089f706b2
  image:
    type: string
    default: 9b5add38-e42c-4fc2-aedc-4c4ee3062fb6
resources:
  sub:
    type: OS::Neutron::Subnet
    properties:
      network: {get_param: net}
      cidr: 70.0.0.0/24
  nic:
    type: AWS::EC2::NetworkInterface
    properties:
      SubnetId: {get_resource: sub}
  ins:
    type: AWS::EC2::Instance
    properties:
      InstanceType: 1
      ImageId: {get_param: image}
      NetworkInterfaces:
        - 'NetworkInterfaceId': {get_resource: nic}
          'DeviceIndex': 0
****************************************

2. stack create successful, then to update the stack with new 'net' parameter
3. the resources 'sub' and 'nic' were replaced, the stack update successful, but the instance has no network (e.g. ip)
4. find that the resource 'nic' referenced by instance has been updated to the new resource after resource 'nic' is created.

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

The same problem for nova server resource, with template:

heat_template_version: 2015-04-30
parameters:
  net:
    type: string
    default: 05d8e681-4b37-4570-bc8d-810089f706b2
  image:
    type: string
    default: 9b5add38-e42c-4fc2-aedc-4c4ee3062fb6
resources:
  port:
    type: OS::Neutron::Port
    properties:
      network: {get_param: net}
  ins:
    type: OS::Nova::Server
    properties:
      flavor: 1
      image: {get_param: image}
      networks:
        - port: {get_resource: port}

Changed in heat:
importance: Undecided → High
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/325784

Changed in heat:
status: New → In Progress
Changed in heat:
milestone: none → newton-3
Revision history for this message
Zane Bitter (zaneb) wrote :

The exact semantics of handle_update() as Heat has evolved have always been poorly defined with respect to what state the resource properties will be in at the time it is called. Many of the built in resource types simply overwrite self.properties with the new values from the new definition being passed in as a parameter at the beginning of handle_update(). However, since this is a third-party plugin interface, this ought to be made clear.

The current behaviour is totally inconsistent. Values that are either hard-coded in the template or obtained from parameters using get_param continue to have the *old* value. However, property values that are obtained from other resources using get_resource or get_attr have the *new* value.

Although it would be convenient for many many resource types to just have the properties pre-set to the new values, I think we have to pass the old values. The new values are available both from the ResourceDefinition passed to handle_update() and the prop_diff - many, many resources simply rely on the latter. This also seems less inconsistent with the current behaviour.

Technically this would be a breaking change to the third-party plugins API, but the behaviour is so inconsistent now that any plugin relying on it is probably broken anyway (since the behaviour can change just from the user changing where they get a property value from).

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

Related fix proposed to branch: master
Review: https://review.openstack.org/351382

Changed in heat:
assignee: huangtianhua (huangtianhua) → Zane Bitter (zaneb)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to heat (master)

Reviewed: https://review.openstack.org/351382
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=025c4fe1d321f3d99a0b0fc59c69d9893c1bdd5d
Submitter: Jenkins
Branch: master

commit 025c4fe1d321f3d99a0b0fc59c69d9893c1bdd5d
Author: Zane Bitter <email address hidden>
Date: Fri Aug 5 10:26:43 2016 -0400

    Don't change properties in regenerate_info_schema

    The definition of TemplateResource.regenerate_info_schema() has the effect
    of changing the semantics of handle_update() in odd ways. For all other
    resource types, self.properties is set to the existing properties
    definition of the resource at the time that handle_update() is called
    (passing the new resource definition as an argument. However,
    TemplateResource is an exception because regenerate_info_schema() replaces
    self.properties with the new values from the new resource definition.

    To reduce confusion and make all resources consistent in their semantics,
    this change refactors the change of the properties definition out of the
    _generate_schema() method that is called by regenerate_info_schema().

    Change-Id: Iab23ae39d05f8290dad02775dddd2e856b29951a
    Related-Bug: #1584623

Changed in heat:
assignee: Zane Bitter (zaneb) → huangtianhua (huangtianhua)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit b1617c8345ba62d2b758ae3291471155aa6d01f2
Author: huangtianhua <email address hidden>
Date: Fri Aug 5 10:26:43 2016 -0400

    Set properties to before_props before calling handle_update

    For some resources, we need to get the old properties
    while handle_update, e.g. for nova server resource, we
    calculate networks from old_nets and new_nets when update
    the server networks, but the properties of server is updated
    after rsrc_defn reparsing. So let's set the properties to
    before_props before calling handle_update.

    Change-Id: I24fea225a2749ee9baaa6273b78eed8126eb9e95
    Closes-Bug: #1584623

Changed in heat:
status: In Progress → Fix Released
tags: added: mitaka-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to heat (stable/mitaka)

Related fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/353241

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

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/353242

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (stable/mitaka)

Change abandoned by huangtianhua (<email address hidden>) on branch: stable/mitaka
Review: https://review.openstack.org/353241
Reason: Abandon this, we fix the problem for server/instance in mitaka branch, see:
https://review.openstack.org/#/c/353242/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/heat 7.0.0.0b3

This issue was fixed in the openstack/heat 7.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (stable/mitaka)

Change abandoned by Zane Bitter (<email address hidden>) on branch: stable/mitaka
Review: https://review.openstack.org/353241

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Zane Bitter (<email address hidden>) on branch: stable/mitaka
Review: https://review.openstack.org/353242

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.