0

Problem is that the stack won't build when the count is greater than 1.
The reason for this is because - port: { get_resource: test_port } is not unique for every instance made.

Error code received: CREATE_FAILED Conflict: resources.compute_nodes.resources[3]: Port XXX is still in use.

Question: How can I make - port: { get_resource: test_port } unique for each instance?

  compute_nodes:
      type: OS::Heat::ResourceGroup
      properties:
        count: 3
        resource_def:
           type: OS::Nova::Server
           properties:
             name: test-%index%
             key_name: { get_param: key_name }
             image: "Ubuntu Server 18.04 LTS (Bionic Beaver) amd64"
             flavor: m1.small
             networks:
               - port: { get_resource: test_port }


 test_port:
    type: OS::Neutron::Port
    properties:
      network_id: { get_resource: private_net }
      security_groups: { get_param: sec_group_lin }
      fixed_ips:
        - subnet_id: { get_resource: private_subnet }

  test_floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network: { get_param: public_net }
      port_id: { get_resource: test_port }

Iterate comma_delimited_list OS::Heat::ResourceGroup

Arya N
  • 95
  • 1
  • 1
  • 6

2 Answers2

1

Your stack tries to attach the same port to different Nova server, so this is failing. The solution would be to create a nested stack that would create your 3 resources (Nova server, Neutron port and Neutron Floating IP), and then your main stack would implement a resource group to "scale" your servers:

Nested_stack: nested_stack.yaml

parameter:
  index:
    type: number

  sec_group_lin:
    type: string

  key_name:
    type: string

  public_net:
    type: string


resources:

  compute_nodes:
    type: OS::Nova::Server
    depends_on: [test_port, test_floating_ip]
    properties:
      name: { list-join: ['-', ['test', {get_param: index} ] ] }
      key_name: { get_param: key_name }
      image: "Ubuntu Server 18.04 LTS (Bionic Beaver) amd64"
      flavor: m1.small
      networks:
        - port: { get_resource: test_port }

  test_port:
    type: OS::Neutron::Port
    properties:
      network_id: { get_resource: private_net }
      security_groups: { get_param: sec_group_lin }
      fixed_ips:
        - subnet_id: { get_resource: private_subnet }

test_floating_ip:
  type: OS::Neutron::FloatingIP
  depends_on: [test_port]
  properties:
    floating_network: { get_param: public_net }
    port_id: { get_resource: test_port }

Then your main stack would look like:

parameters:

  key_name:
    type: string
  public_net:
    type: string
  sec_group_lin:
    type: string

resources:
 compute_nodes:
  type: OS::Heat::ResourceGroup
  properties:
    count: 3
    resource_def:
       type: nested_stack.yaml
       properties:
         index: %index%
         key_name: {get_param: key_name}
         public_net: { get_param: public_net }
         sec_group_lin: { get_param: sec_group_lin }

This will created x (here x=3 as your count is set to 3) servers with each of them having its own test port and test floating IP.

zhonzo
  • 11
  • 2
0

Make use of "depends_on" to align the flow of execution of template

 compute_nodes:
  type: OS::Heat::ResourceGroup
  depends_on: [test_port, test_floating_ip]
  properties:
    count: 3
    resource_def:
       type: OS::Nova::Server
       properties:
         name: test-%index%
         key_name: { get_param: key_name }
         image: "Ubuntu Server 18.04 LTS (Bionic Beaver) amd64"
         flavor: m1.small
         networks:
           - port: { get_resource: test_port }


test_port:
  type: OS::Neutron::Port
  properties:
    network_id: { get_resource: private_net }
    security_groups: { get_param: sec_group_lin }
    fixed_ips:
      - subnet_id: { get_resource: private_subnet }

test_floating_ip:
  type: OS::Neutron::FloatingIP
  depends_on: [test_port]
  properties:
    floating_network: { get_param: public_net }
    port_id: { get_resource: test_port }
  • `2019-03-11 10:32:28Z [test11.compute_nodes]: CREATE_FAILED Conflict: resources.compute_nodes.resources[0]: Port 0f6c6d27-1301-4522-b595-a96eb8a137d9 is still in use. (HTTP 409) (Request-ID: req-9bb0da03-7c54-49a3-9f61-4f5438889c84)` – Arya N Mar 11 '19 at 10:33