[Bug 2130459] Re: neutronclient uses the wrong key when listing port bindings

Satya Jhaveri 2130459 at bugs.launchpad.net
Wed Feb 25 22:43:40 UTC 2026


Also verified for Epoxy. Below shows running the test case in the bug
description before and after enabling proposed:

ubuntu at juju-7fff07-test-noble-epoxy-7:~$ python3 reproduce.py 1d666736-2dc3-4f36-a9a8-1d5de306e89a
Attempting list_port_bindings for 1d666736-2dc3-4f36-a9a8-1d5de306e89a...
FAILURE: error: 'port_bindings'
ubuntu at juju-7fff07-test-noble-epoxy-7:~$ apt-cache policy python3-neutronclient
python3-neutronclient:
  Installed: 1:11.4.0-0ubuntu1~cloud0
  Candidate: 1:11.4.0-0ubuntu1~cloud0
  Version table:
 *** 1:11.4.0-0ubuntu1~cloud0 500
        500 http://ubuntu-cloud.archive.canonical.com/ubuntu noble-updates/epoxy/main amd64 Packages
        100 /var/lib/dpkg/status
     1:11.2.0-0ubuntu1 500
        500 http://availability-zone-3.clouds.archive.ubuntu.com/ubuntu noble/main amd64 Packages
ubuntu at juju-7fff07-test-noble-epoxy-7:~$ sudo add-apt-repository cloud-archive:epoxy-proposed  2>&1 >/dev/null
ubuntu at juju-7fff07-test-noble-epoxy-7:~$ sudo apt update && sudo apt upgrade python3-neutronclient 2>&1 >/dev/null
ubuntu at juju-7fff07-test-noble-epoxy-7:~$ python3 reproduce.py 1d666736-2dc3-4f36-a9a8-1d5de306e89a
Attempting list_port_bindings for 1d666736-2dc3-4f36-a9a8-1d5de306e89a...
SUCCESS: Bindings retrieved: {'bindings': [{'host': 'juju-7fff07-test-noble-epoxy-8', 'vif_type': 'ovs', 'vnic_type': 'normal', 'status': 'ACTIVE', 'profile': {}, 'vif_details': {'port_filter': True, 'connectivity': 'l2', 'bridge_name': 'br-int', 'datapath_type': 'system'}}]}
ubuntu at juju-7fff07-test-noble-epoxy-7:~$ apt-cache policy python3-neutronclient
python3-neutronclient:
  Installed: 1:11.4.0-0ubuntu1~cloud1
  Candidate: 1:11.4.0-0ubuntu1~cloud1
  Version table:
 *** 1:11.4.0-0ubuntu1~cloud1 500
        500 http://ubuntu-cloud.archive.canonical.com/ubuntu noble-proposed/epoxy/main amd64 Packages
        100 /var/lib/dpkg/status
     1:11.4.0-0ubuntu1~cloud0 500
        500 http://ubuntu-cloud.archive.canonical.com/ubuntu noble-updates/epoxy/main amd64 Packages
     1:11.2.0-0ubuntu1 500
        500 http://availability-zone-3.clouds.archive.ubuntu.com/ubuntu noble/main amd64 Packages


Thanks

-- 
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to Ubuntu Cloud Archive.
https://bugs.launchpad.net/bugs/2130459

Title:
  neutronclient uses the wrong key when listing port bindings

Status in Ubuntu Cloud Archive:
  Fix Committed
Status in Ubuntu Cloud Archive antelope series:
  Won't Fix
Status in Ubuntu Cloud Archive bobcat series:
  Won't Fix
Status in Ubuntu Cloud Archive caracal series:
  Fix Committed
Status in Ubuntu Cloud Archive dalmatian series:
  Fix Committed
Status in Ubuntu Cloud Archive epoxy series:
  Fix Committed
Status in Ubuntu Cloud Archive flamingo series:
  Fix Committed
Status in Ubuntu Cloud Archive gazpacho series:
  Fix Released
Status in Ubuntu Cloud Archive ussuri series:
  Won't Fix
Status in Ubuntu Cloud Archive yoga series:
  In Progress
Status in Ubuntu Cloud Archive zed series:
  Won't Fix
Status in python-neutronclient:
  Fix Released
Status in python-neutronclient package in Ubuntu:
  Fix Released
Status in python-neutronclient source package in Bionic:
  Won't Fix
Status in python-neutronclient source package in Focal:
  Won't Fix
Status in python-neutronclient source package in Jammy:
  Fix Committed
Status in python-neutronclient source package in Noble:
  Fix Committed
Status in python-neutronclient source package in Plucky:
  Won't Fix
Status in python-neutronclient source package in Questing:
  Fix Committed
Status in python-neutronclient source package in Resolute:
  Fix Released

Bug description:
  [ Impact ]

  A bug in python-neutronclient causes a KeyError when attempting to list
  port bindings via the client. Specifically, calling the list_port_bindings
  method triggers a KeyError: 'port_bindings'. This occurs because the client
  expects the Neutron API response to contain the "port_bindings" key.

  This affects any service or tool that calls this method, and as such can
  cause functional failures in Openstack deployments. Upstream has fixed this
  by adjusting the parsing of the API response to use the correct key "bindings"
  instead of "port_bindings". The attached debdiffs apply this same fix to 
  affected Ubuntu and Ubuntu Cloud Archive series.

  [ Test Plan ]

  Deploy an OpenStack environment on the target series.

  1. Ensure you have administrative access to the deployed cloud and source
  credentials.

  2. Create a test network and a port to run the query against.

  ```sh
  openstack network create test-net

  openstack subnet create --network test-net --subnet-range
  10.10.99.0/24 test-subnet

  PORT_ID=$(openstack port create --network test-net test-port -c id -f value)
  ```

  3. Verify the failure exists using the following python script. It attempts
  to call the problematic API method.

  Create a file named reproduce.py with the following contents:

  ```py
  import os
  import sys
  from keystoneauth1 import identity, session
  from neutronclient.v2_0 import client

  # Authenticate using environment variables
  auth = identity.v3.Password(
      auth_url=os.environ['OS_AUTH_URL'],
      username=os.environ['OS_USERNAME'],
      password=os.environ['OS_PASSWORD'],
      project_name=os.environ['OS_PROJECT_NAME'],
      user_domain_name=os.environ.get('OS_USER_DOMAIN_NAME', 'Default'),
      project_domain_name=os.environ.get('OS_PROJECT_DOMAIN_NAME', 'Default')
  )
  sess = session.Session(auth=auth)
  neutron = client.Client(session=sess)

  # Get the port ID
  port_id = sys.argv[1]

  print(f"Attempting list_port_bindings for {port_id}...")
  try:
      bindings = neutron.list_port_bindings(port_id)
      print("SUCCESS: Bindings retrieved:", bindings)
  except Exception as e:
      print(f"FAILURE: error: {e}")
      sys.exit(1)
  ```

  Run this script with the newly created port:

  ```sh
  python3 reproduce.py $PORT_ID
  ```

  The expected result before applying the fix is that the script will 
  fail with FAILURE: error: KeyError: 'port_bindings'.

  The expected result after applying the fix is that the script will 
  run successfully.

  [ Where problems could occur ]

  API response mismatch: The patch changes the key lookup from "port_bindings"
  to "bindings". If there are non-standard Neutron API implementations that
  only "port_bindings" and not the expected structure, this fix could theoretically
  prevent usage of this method that was previously working.

  [ Other Info ]

  This backports the merged upstream fix which corrects the JSON key.
  The description / message from the original commit message is provided
  below:

  v2_0: Use 'bindings' when listing port bindings
  This commit fixes a bug in v2_0 client's "list_port_bindings"
  function, where it uses "port_bindings" to access Neutron's
  response, instead of "bindings" [0].

  [0]: https://docs.openstack.org/api-ref/network/v2/index.html#show-
  port-binding-of-a-port

  Closes-Bug: #2130459
  Change-Id: I32ef753ec212b55f698e3844e043f68b22992ead
  Signed-off-by: Zhan Zhang <zzhang953 at bloomberg.net>

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-archive/+bug/2130459/+subscriptions




More information about the Ubuntu-openstack-bugs mailing list