Port extra properties ignored when a port is created via OS::Nova::Server

Bug #2085966 reported by Alejandro Santoyo Gonzalez
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
heat (Ubuntu)
New
Undecided
Unassigned

Bug Description

When you create a port via OS::Nova::Server, if you only specify a network ID then the extra properties you pass in the template are ignored as per the code below:

heat/engine/resources/openstack/nova/server.py:

handle_create()
\_ _build_nics()
  \_ if there's a port in the template then that's used
  |_ if there's a subnet in the template then _create_internal_port() is called and the extra props are passed to Neutron
  |_ if only a network ID is passed in the template then the port extra properties ni the template (if any) are ignored and the defaults are passed.

Reproducer:
-----------

heat_template_version: 2021-04-16

resources:

  server_test:
    type: OS::Nova::Server
    properties:
      name: server_test
      config_drive: true
      flavor: m1.small
      image: "focal"
      networks:
        - network: test_net
          port_extra_properties:
            binding:vnic_type: direct

Here is the request body for the API call sent from Heat to Neutron for the above template the network_id is there but not the extra property passed:

/var/log/neutron/neutron-server.log:2024-10-30 12:10:38.439 246121 DEBUG neutron.api.v2.base [req-5ea6e086-cf63-4441-a19a-e785fbcea5dc 3e23d2d4716f972bd4eff30931e2a797fa5b0e355ef4d5b05bee2212e156b40a e964739be53f40d0b3862aad6cff8732 - 198a7a588d7c4edb880789e342ec3d03 198a7a588d7c4edb880789e342ec3d03] Request body: {'port': {'device_id': '6bdf1f2b-fc39-4c56-bde6-beffd08ff0e6', 'network_id': '78637385-b2cc-41ae-8d5c-0ed94ccd12df', 'admin_state_up': True, 'tenant_id': 'e964739be53f40d0b3862aad6cff8732'}} prepare_request_body /usr/lib/python3/dist-packages/neutron/api/v2/base.py:730

I believe we should be calling _create_internal_port() when only a network ID is passed in the templates, as we already do when a subnet is passed. The rationale is that either way we're creating a port with no IP, so I see no reason why we should not follow the same path.

description: updated
description: updated
description: updated
Revision history for this message
Alejandro Santoyo Gonzalez (al3jandrosg) wrote :

For anyone else who stumbles upon this issue, the workaround is to create the port using OS::Neutron::Port and attach it to the instance instead of implicitly creating the port via OS::Nova::Server.

Revision history for this message
Alejandro Santoyo Gonzalez (al3jandrosg) wrote :
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.