Can't access subnet attributes from a port resource

Bug #1336656 reported by Robert Collins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Ishant Tyagi

Bug Description

I am not 100% sure of this, but I have a template (below) which creates a port and attempts to go port.subnet.gateway_ip, but gets "" back instead of the gateway_ip. This is with heat from today.

Poking with neutronclient:
| 3b75b4c8-51c7-4233-b672-e4a2263cfa68 | undercloud_vlan | fa:16:3e:3a:c1:06 | {"subnet_id": "92aa5214-4bf7-49a1-ba17-4baddab13b65", "ip_address": "198.51.100.5"} |

neutron subnet-show 92aa5214-4bf7-49a1-ba17-4baddab13b65
+-------------------+------------------------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------------------------+
| allocation_pools | {"start": "198.51.100.2", "end": "198.51.100.10"} |
| cidr | 198.51.100.0/24 |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 198.51.100.1 |
| host_routes | {"destination": "169.254.169.254/32", "nexthop": "198.51.100.1"} |
| id | 92aa5214-4bf7-49a1-ba17-4baddab13b65 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | |
| network_id | 2c96faba-9527-4b40-8120-ec80beaca164 |
| tenant_id | 5693efce0656455f877fc4bfacd1e7ae |
+-------------------+------------------------------------------------------------------+

Resources:
  # Override the main template which can also supply a static route.
  99_undercloudVLANPort:
    Type: OS::Heat::StructuredDeployment
    Properties:
      config: {Ref: undercloudVLANPortConfig}
      server: {Ref: undercloud}
      signal_transport: NO_SIGNAL
  undercloudVLANPortConfig:
    Type: OS::Heat::StructuredConfig
    Properties:
      config:
        neutron:
          ovs:
            public_interface_tag_ip:
              Fn::Select:
              - ip_address
              - Fn::Select:
                - 0
                - Fn::GetAtt:
                  - undercloudVLANPort
                  - fixed_ips
            # Tell the instance to apply the default route.
            public_interface_route:
              Fn::Select:
              - gateway_ip
              - Fn::Select:
                - subnet
                - Fn::Select:
                  - 0
                  - Fn::GetAtt:
                    - undercloudVLANPort
                    - fixed_ips
  undercloudVLANPort:
    Type: OS::Neutron::Port
    Properties:
      name: undercloud_vlan
      network: public

description: updated
summary: - existing subnet not looked up on port?
+ can't access subnet attributes from a port resources
Thomas Herve (therve)
Changed in heat:
importance: Undecided → Medium
summary: - can't access subnet attributes from a port resources
+ Can't access subnet attributes from a port resource
Revision history for this message
Steve Baker (steve-stevebaker) wrote :

In the general case it would be nice if neutron resources had attributes which let you navigate the neutron associations. Adding a subnet attribute to the port resource would be a good enhancement for a new contributor.

Changed in heat:
status: New → Triaged
Changed in heat:
assignee: nobody → Ishant Tyagi (ishant-tyagi)
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/105408

Changed in heat:
status: Triaged → In Progress
Revision history for this message
Zane Bitter (zaneb) wrote :

The real problem here is that Neutron implicitly assigns a subnet for you and you have no way of knowing in advance which. The correct way to do it would be to explicitly create the subnet and then explicitly attach the port to that subnet (which you actually can do, apparently, with the fixed_ip option if you don't actually specify a fixed ip). Then you know the subnet resource that the port is attached to and can get its attributes directly.

The patch seems like a decent workaround for Neutron's broken design though.

Changed in heat:
milestone: none → juno-3
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 1336656] Re: Can't access subnet attributes from a port resource

I disagree that Neutron is broken here - I have a subnet on baremetal,
it gets used for many different heat stacks, there's no way to create
it in each stack: using an existing resource is a really common use
case in this situation IME.

Revision history for this message
Zane Bitter (zaneb) wrote :

If you know what Subnet it's going to be then it's easy enough to pass the gateway_ip in as a parameter (alongside the Subnet UUID, which you ought to be setting explicitly). The problem is that it's possible to let Neutron choose a Subnet for you, and at that point you don't know which gateway_ip to pass in.

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

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

commit 5868fd6dd7cba9b236e88c5fcddcbbaeb247d6f1
Author: ishant <email address hidden>
Date: Tue Jul 8 02:53:01 2014 -0700

    Add subnets attribute to OS::Neutron::Port resource

    Added subnets attribute to the port resource to fetch the subnet
    attributes such as gateway_ip which are associated with the port.

    Change-Id: Ia809c343d5b7d1488b505f9e9e20da02b36de07d
    Closes-Bug: #1336656

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: juno-3 → 2014.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.