Provide correct error message if find_resource_by_name is called for resource which does not have a name parameter.

Bug #1485779 reported by Banashankar
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-neutronclient
Expired
Medium
Unassigned

Bug Description

neutron lbaas-member-delete with the non existing member id throws incorrect error message.

For e.g.

neutron lbaas-member-delete 852bfa31-6522-4ccf-b48c-768cd2ab5212 test_pool

Throws the following error message.

Multiple member matches found for name '852bfa31-6522-4ccf-b48c-768cd2ab5212', use an ID to be more specific.

Example:

$ neutron lbaas-member-list pool1

+--------------------------------------+----------+---------------+--------+--------------------------------------+----------------+
| id | address | protocol_port | weight | subnet_id | admin_state_up |
+--------------------------------------+----------+---------------+--------+--------------------------------------+----------------+
| 64e4d9f4-c2c5-4d58-b696-21cb7cff21ad | 10.3.3.5 | 80 | 1 | e822a77b-5060-4407-a766-930d6fd8b644 | True |
| a1a9c7a6-f9a5-4c12-9013-f0990a5f2d54 | 10.3.3.3 | 80 | 1 | e822a77b-5060-4407-a766-930d6fd8b644 | True |
| d9d060ee-8af3-4d98-9bb9-49bb81bc4c37 | 10.2.2.3 | 80 | 1 | f6398da5-9234-4ed9-a0ca-29cbd33d44b9 | True |
+--------------------------------------+----------+---------------+--------+--------------------------------------+----------------+

$ neutron lbaas-member-delete non-existing-uuid pool1
Multiple member matches found for name 'non-existing-uuid', use an ID to be more specific.

Tags: lbaas
Banashankar (bkalebe)
summary: - Delete member with wrong member id throws wrong error message.
+ Delete member with non existing member id throws incorrect error
+ message.
description: updated
Revision history for this message
Brandon Logan (brandon-logan) wrote : Re: Delete member with non existing member id throws incorrect error message.

this is a neutron client error, moving to that project.

description: updated
Revision history for this message
Brandon Logan (brandon-logan) wrote :

this is not an cotavia issue, but a neutron client issue.

affects: octavia → python-neutronclient
Changed in python-neutronclient:
importance: Undecided → Medium
status: New → Confirmed
Changed in python-neutronclient:
assignee: nobody → Reedip (reedip-banerjee)
summary: - Delete member with non existing member id throws incorrect error
- message.
+ [neutron-lbaas]Delete member with non existing member id throws
+ incorrect error message.
Revision history for this message
Harshada Mangesh Kakad (harshada-kakad) wrote : Re: [neutron-lbaas]Delete member with non existing member id throws incorrect error message.

Reedip are you working on this else I would like to take this bug.

Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote :

Hi Harshada,
Yes, I will be taking this up after the summit , if its ok?

Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote :

Ok, reproduced it...
Need to see why it happened

reedip@reedip-VirtualBox:/opt/stack/python-neutronclient/neutronclient/tests/unit/lb/v2$ neutron lbaas-member-list testpool
+--------------------------------------+--------------+---------------+--------+--------------------------------------+----------------+
| id | address | protocol_port | weight | subnet_id | admin_state_up |
+--------------------------------------+--------------+---------------+--------+--------------------------------------+----------------+
| 2644b225-53df-4cdf-9ab3-dea5da1d402c | 172.24.4.120 | 90 | 1 | af8b5dfb-732b-4ecd-87f5-10cd4cb0d917 | True |
| 39d1017e-92ca-40fd-b02d-739189a4b8df | 172.24.4.121 | 90 | 1 | af8b5dfb-732b-4ecd-87f5-10cd4cb0d917 | True |
+--------------------------------------+--------------+---------------+--------+--------------------------------------+----------------+
reedip@reedip-VirtualBox:/opt/stack/python-neutronclient/neutronclient/tests/unit/lb/v2$ neutron lbaas-member-delete Dummy testpool
Multiple member matches found for name 'Dummy', use an ID to be more specific.

Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote :

Putting up an Initial Assessment so that it comes to help for others who are new to neutron-client:
It seems that the lbaas-list members API does not return NAME.
{'members': [{u'weight': 1, u'admin_state_up': True, u'subnet_id': u'af8b5dfb-732b-4ecd-87f5-10cd4cb0d917', u'address': u'172.24.4.120', u'protocol_port': 90, u'id': u'2644b225-53df-4cdf-9ab3-dea5da1d402c'}, {u'weight': 1, u'admin_state_up': True, u'subnet_id': u'af8b5dfb-732b-4ecd-87f5-10cd4cb0d917', u'address': u'172.24.4.121', u'protocol_port': 90, u'id': u'39d1017e-92ca-40fd-b02d-739189a4b8df'}]}

It only returns the ID.
If the ID does not match, then the match is made by name, as per the backtrace observed here
ERROR: neutronclient.shell Multiple member matches found for name 'Dummy', use an ID to be more specific.
Traceback (most recent call last):
  File "/opt/stack/python-neutronclient/neutronclient/shell.py", line 820, in run_subcommand
    return run_command(cmd, cmd_parser, sub_argv)
  File "/opt/stack/python-neutronclient/neutronclient/shell.py", line 111, in run_command
    return cmd.run(known_args)
  File "/opt/stack/python-neutronclient/neutronclient/neutron/v2_0/__init__.py", line 599, in run
    **params)
  File "/opt/stack/python-neutronclient/neutronclient/neutron/v2_0/__init__.py", line 133, in find_resourceid_by_name_or_id
    parent_id, fields='id')['id']
  File "/opt/stack/python-neutronclient/neutronclient/neutron/v2_0/__init__.py", line 125, in find_resource_by_name_or_id
    fields)
  File "/opt/stack/python-neutronclient/neutronclient/neutron/v2_0/__init__.py", line 104, in _find_resource_by_name
    name=name)
NeutronClientNoUniqueMatch: Multiple member matches found for name 'Dummy', use an ID to be more specific.
Multiple member matches found for name 'Dummy', use an ID to be more specific.

When you see the code /opt/stack/python-neutronclient/neutronclient/neutron/v2_0/__init__.py , _find_resource_by_name() , you would find that the search for the params is done by 'name'.
As the name filed is missing in the API, the actual member does not exist and the result is the complete list of the members.The length of the list of entries is >1 which causes this exception to occur.

The reason for the missing 'name' parameter is because the DB tables themselves dont have the name parameter.
https://github.com/openstack/neutron-lbaas/blob/master/neutron_lbaas/db/loadbalancer/models.py
Hope this explanation helps us coders.

affects: python-neutronclient → neutron
tags: added: lbaas
affects: neutron → python-neutronclient
Revision history for this message
Akihiro Motoki (amotoki) wrote :

member resource does not have "name" field and the sub-command supports only UUID.
The solution would be simple and i think it is enough to remove the call of find_resource_by_name_or_id.
By doing so, we can defer the existence check to the server side and it should work.

Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote :

Akihiro San:
Yes that is possible.
I can give it a try and see how it behaves.
I am just a bit conscious as this change may have a wider impact.

Changed in python-neutronclient:
status: Confirmed → Fix Committed
Revision history for this message
Akihiro Motoki (amotoki) wrote :

Could you provide information or reasons when you change the status to Fix Committed?

Changed in python-neutronclient:
status: Fix Committed → Confirmed
Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote : Re: Do not call find_resource_by_name for API which does not have a name parameter

Hi Akihiro ,
While the following bug is solved by https://review.openstack.org/246077.
However, if the issue is generic, we can verify if the allowed_names is set to True or not, and proceed accordingly

summary: - [neutron-lbaas]Delete member with non existing member id throws
- incorrect error message.
+ Do not call find_resource_by_name for API which does not have a name
+ parameter
summary: - Do not call find_resource_by_name for API which does not have a name
- parameter
+ Provide correct error message if find_resource_by_name is called for
+ resource which does not have a name parameter.
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/279409

Changed in python-neutronclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-neutronclient (master)

Change abandoned by Armando Migliaccio (<email address hidden>) on branch: master
Review: https://review.openstack.org/279409
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

If you are still working on this please resume, or allow someone else to pick this up.

Changed in python-neutronclient:
status: In Progress → Incomplete
assignee: Reedip (reedip-banerjee) → nobody
Changed in python-neutronclient:
assignee: nobody → Reedip (reedip-banerjee)
Changed in python-neutronclient:
assignee: Reedip (reedip-banerjee) → nobody
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for python-neutronclient because there has been no activity for 60 days.]

Changed in python-neutronclient:
status: Incomplete → Expired
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.