peterknife / boto

Automatically exported from code.google.com/p/boto
0 stars 0 forks source link

tag deletion doesn't work #536

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. attempt to delete any tag using ec2.connection.delete_tags

What is the expected output? What do you see instead?
You'd expect the tags to no longer be there. However the tags remain

What version of the product are you using? On what operating system?
Ubuntu 11, boto 2.0

Please provide any additional information below.
Amazon may have changed the API...

Original issue reported on code.google.com by jmal...@gmail.com on 18 Jul 2011 at 6:56

GoogleCodeExporter commented 9 years ago
I can't reproduce this issue.  Please see log below:

>>> import boto
>>> c = boto.connect_ec2()
>>> c.get_all_instances(filters={'instance-state-name':'running'})
[Reservation:r-1c396c74, Reservation:r-76a71a1b]
>>> i = _[0].instances[0]
>>> i
Instance:i-67c81e0c
>>> c.get_all_tags(filters={'resource-id':i.id})
[]
>>> c.create_tags([i.id], {'foo':'bar'})
True
>>> c.get_all_tags(filters={'resource-id':i.id})
[Tag:foo]
>>> c.delete_tags([i.id], {'foo':'bar'})
True
>>> c.get_all_tags(filters={'resource-id':i.id})
[]
>>> 

Can you provide more information on what you are doing?

Original comment by Mitch.Ga...@gmail.com on 19 Jul 2011 at 2:07

GoogleCodeExporter commented 9 years ago

Original comment by Mitch.Ga...@gmail.com on 19 Jul 2011 at 2:10

GoogleCodeExporter commented 9 years ago
Hi Mitch,
I've just realized that this issue is dependent on the version of python i'm 
running!

On my amazon ec2 instances I'm using:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2

On my box I'm using:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2

The delete tags call doesn't work on my local box, but works fine on amazon. 
I've also noticed that the delete tags call is working fine on my OSX box at 
home, running python 2.6

I originally thought it might be an issue with the version of boto, but I've 
now tested with them both running boto2.0b4 and the issue only persists on the 
box running python 2.7

FYI the result from amazon (I've inspected the XML return value) comes back 
fine.

Original comment by jmal...@gmail.com on 21 Jul 2011 at 9:12

GoogleCodeExporter commented 9 years ago
Disregard my previous theories..

I've found the bug and submitted a pull request at github.
https://github.com/boto/boto/pull/289

The problem was deletion of tags where no value is specified.
In build_tag_param_list you were sending a Tag.n.Value of "" if the value was 
None.
The boto API states that this will only delete a tag if the value of the tag is 
"".

What you want to do instead is to simply not send a Tag.n.Value, then you get 
the expected behavior.

Original comment by jmal...@gmail.com on 3 Aug 2011 at 4:18

GoogleCodeExporter commented 9 years ago
This fix was merged to github master in:

https://github.com/boto/boto/commit/fb61bcef465a8b0cea87a52f7051e3dec6752230

Original comment by Mitch.Ga...@gmail.com on 4 Aug 2011 at 10:05