Metadata update fails when an Instance has not yet been created

Bug #1185530 reported by Zane Bitter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Zane Bitter

Bug Description

Take the following template:

{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Description" : "Just a WaitCondition.",
  "Parameters" : {
    "KeyName" : {"Type" : "String", "Default": "mine" },
  },
  "Resources" : {
    "WH" : {
      "Type" : "AWS::CloudFormation::WaitConditionHandle"
    },
    "S1": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId" : "a",
        "InstanceType" : "m1.large",
        "KeyName" : { "Ref" : "KeyName" },
        "UserData" : { "Fn::Join" : [ "", [ "#!/bin/bash -v\n",
                                                "echo ",
                                                { "Ref" : "WH" },
                                                "\n" ] ] }
      }
    },
    "WC" : {
      "Type" : "AWS::CloudFormation::WaitCondition",
      "DependsOn": "S1",
      "Properties" : {
        "Handle" : {"Ref" : "WH"},
        "Timeout" : "5"
      }
    },
    "S2": {
      "Type": "AWS::EC2::Instance",
      "DependsOn": "WC",
      "Metadata" : {
        "test" : {"Fn::GetAtt": ["WC", "Data"]}
      },
      "Properties": {
        "ImageId" : "a",
        "InstanceType" : "m1.large",
        "KeyName" : { "Ref" : "KeyName" },
        "UserData" : "#!/bin/bash -v\n"
      }
    }
  }
}

This implements what you'd imagine to be a fairly common pattern - it starts up one server, which posts some result of its software configuration to a WaitCondition, and said result is used in the Metadata of a second server.

Posting to the WaitConditionHandle causes an exception, because it attempts to refresh the metadata of the second server (actually of all resources, but it is a NOP for everything except Instances and WaitConditionHandles) and this fails because the second server has not been created yet, and therefore is not stored in the database.

Note that the issue here is not that "S2" references "WC" in its metadata, simply that its creation has not started at the time that "S1" starts posting data to the WaitConditionHandle.

Zane Bitter (zaneb)
description: updated
Zane Bitter (zaneb)
Changed in heat:
assignee: nobody → Zane Bitter (zaneb)
importance: Undecided → Medium
status: New → In Progress
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/31183

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

Reviewed: https://review.openstack.org/31183
Committed: http://github.com/openstack/heat/commit/df2e6779bab71da06c00dd78d3732a756ce9c6ad
Submitter: Jenkins
Branch: master

commit df2e6779bab71da06c00dd78d3732a756ce9c6ad
Author: Zane Bitter <email address hidden>
Date: Fri May 31 12:52:30 2013 +0200

    Handle metadata updates during stack creation

    Don't try to recalculate the metadata on an instance that hasn't yet been
    stored in the database.

    Fixes bug #1185530

    Change-Id: I39f2733e2ba4730ea05a4a50962cb30f044ef752

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
milestone: none → havana-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: havana-2 → 2013.2
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.