aggregate-set-metadata return succesful on incorrect usage

Bug #1292572 reported by Santiago Baldassin
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Neetu Jain

Bug Description

aggregate-set-metadata <aggregate> "This is the aggregate metadata" return a "successfully updated" message even when no metadata was added to the aggregate due to the incorrect use of the API

Tags: api
Changed in nova:
assignee: nobody → Santiago Baldassin (santiago-b-baldassin)
Tracy Jones (tjones-i)
tags: added: api
Revision history for this message
melanie witt (melwitt) wrote :

Could you give an example of the incorrect API use that results in this behavior?

Revision history for this message
Santiago Baldassin (santiago-b-baldassin) wrote :

yes....it's right there in the description:

aggregate-set-metadata <aggregate> "This is the aggregate metadata"

Revision history for this message
Santiago Baldassin (santiago-b-baldassin) wrote :

Basically you are not forced to follow the key=value

Revision history for this message
Christopher Yeoh (cyeoh-0) wrote :

Yes we should do much better input validation here. Need to keep in mind backwards compatibility for V2 though

Changed in nova:
status: New → Confirmed
importance: Undecided → Low
Neetu Jain (nutshi)
Changed in nova:
assignee: Santiago Baldassin (santiago-b-baldassin) → Neetu Jain (nutshi)
Revision history for this message
Neetu Jain (nutshi) wrote :

I can take it up ..i think the bug stems up from this line
https://github.com/openstack/nova/blob/0afdcedc3897301ff14c6eefb7355964825c1c12/nova/objects/aggregate.py#L109

I am able to reproduce this problem

this will be my first fix .. some pointers will help ..
I understand the problem i think but i think i can not find a lace where the input validation needs to be added

Neetu Jain (nutshi)
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Santiago Baldassin (santiago-b-baldassin) wrote :

Hi Neetu Jain, you should submit a patch with the fix so that people can comment on it give you feedback :)

Revision history for this message
Santiago Baldassin (santiago-b-baldassin) wrote :

yes. #openstack-nova is the irc channel you are looking for

Revision history for this message
Neetu Jain (nutshi) wrote :

ok so i understand this bug a little better i think .. and it seems like there is currently not much information for do_seggregate_set_metadata to know if the deletion of addition of metadata failed in here.

https://github.com/openstack/python-novaclient/blob/076c1a004ab1c861bd02ef7b020e1cbce8a934cc/novaclient/v1_1/shell.py#L2776

because update_metadata from here
https://github.com/openstack/nova/blob/eb19b011eb29245ba17389d21dce02ea89a8a756/nova/objects/aggregate.py#L111
does not return an error if a there is an attempt to delete non-existent key

so what happens in this usecase is

aggregate-set-metadata <aggregate> "This is the aggregate metadata"

the key is "This is the aggregate metadata"

and the function calls tried to delete is ( since there is not value of key provided) .. since it does not return an error or raise an exception the calls succeeds and hence the message. so technically its is correct .. the entry has been updated as per user's choice ( the key has been deleted but since it was never there .. no action took place)

now we could improve the messaging if we introduce some logic in
https://github.com/openstack/nova/blob/eb19b011eb29245ba17389d21dce02ea89a8a756/nova/objects/aggregate.py#L111

1. we read the metadata of that aggregate-ID and determine what keys are present
2. if the user has given a key-value pair we determine if already existent key-value match to the given by user or not .. if they do .. we report and error "stating key=value" already present if they dont match then we go ahead and make the call to the server
3. simillar when only key is present ..then we check if already present keys match the given key .. if the user-key does not match any keys in teh aggregate ..then deletion is not possible so we raise an error " given key is not present hence can not be deleted "

to do this i am trying to understand how to read the meteadata on teh client side ..

Revision history for this message
Neetu Jain (nutshi) wrote :

i have the fix now .. for covering corner cases but i am unabel to commit it for review

because of some wierd isseu

https://ask.openstack.org/en/question/30423/please-help-can-nto-submit-my-first-review/

Revision history for this message
Neetu Jain (nutshi) wrote :

i am not sure if my review gets posted here or not .. so linking it here

https://review.openstack.org/#/c/98185/

the patch solves these 2 problems (and tackles cause of the bug mentioned here)

1. if the user has given a key-value pair we determine if already existent key-value match to the given by user or not .. if they do .. we report and error "stating key=value" already present if they dont match then we go ahead and make the call to the server
2. simillar when only key is present ..then we check if already present keys match the given key .. if the user-key does not match any keys in teh aggregate ..then deletion is not possible so we raise an error " given key is not present hence can not be deleted "

Revision history for this message
Neetu Jain (nutshi) wrote :
Neetu Jain (nutshi)
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
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.