[Bug 2130459] Re: neutronclient uses the wrong key when listing port bindings
Satya Jhaveri
2130459 at bugs.launchpad.net
Wed Jan 28 03:52:03 UTC 2026
** Patch added: "lp2130459_focal_yoga.debdiff"
https://bugs.launchpad.net/ubuntu/questing/+source/python-neutronclient/+bug/2130459/+attachment/5941194/+files/lp2130459_focal_yoga.debdiff
** Patch removed: "lp2130459_jammy.debdiff"
https://bugs.launchpad.net/ubuntu/questing/+source/python-neutronclient/+bug/2130459/+attachment/5941185/+files/lp2130459_jammy.debdiff
--
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to python-neutronclient in Ubuntu.
https://bugs.launchpad.net/bugs/2130459
Title:
neutronclient uses the wrong key when listing port bindings
Status in Ubuntu Cloud Archive:
In Progress
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:
In Progress
Status in Ubuntu Cloud Archive dalmatian series:
In Progress
Status in Ubuntu Cloud Archive epoxy series:
In Progress
Status in Ubuntu Cloud Archive flamingo series:
In Progress
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:
In Progress
Status in python-neutronclient source package in Jammy:
In Progress
Status in python-neutronclient source package in Noble:
In Progress
Status in python-neutronclient source package in Plucky:
Won't Fix
Status in python-neutronclient source package in Questing:
In Progress
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