Minor bug: _attrs includes deleted content

Matt Wagner matt.wagner at redhat.com
Thu Dec 8 18:28:05 UTC 2011


Hi all,

I've run across what I believe is a minor bug in iwhd, in which an Image
attribute is not deleted when the object it references is deleted. This
is probably not an urgent issue, as I only ran into this while manually
monkeying with things. Specifically, I deleted the Template associated
with an Image in order to test some code I'm working on, but the
reference to that Template remained in the _attrs list:

I have an Image, img, with a UUID of
f4650089-9716-41cb-86e8-bb1efd93eb05. Among its attributes, the Image
has a (valid) template ID (before I delete it):

>> img.attr('template')
=> "9803ed0b-f4e3-41b7-8e69-4b7152e1a40e"

# GET the template to show it exists
>> r = conn.do_request
>> "/templates/9803ed0b-f4e3-41b7-8e69-4b7152e1a40e", :method => :get
=> #<Nokogiri::XML::Document:0x3feac8484c64 name="document"
children=[#<Nokogiri::XML::Element:0x3feac8484390 name="template">]>
>> r.to_s
=> "<?xml version="1.0"?>\n<template/>\n"

However, I don't want a template on this image (because I'm testing that
case), so delete it:

# conn is simply an OAuth-aware HTTP connection to localhost:9090
# DELETE the Template
>> conn.do_request "/templates/9803ed0b-f4e3-41b7-8e69-4b7152e1a40e",
>> :method => :delete
=> #<Nokogiri::XML::Document:0x3feac845fa7c name="document">

# Try to fetch the image to ensure it's gone; a 404 is returned
>> conn.do_request "/templates/9803ed0b-f4e3-41b7-8e69-4b7152e1a40e",
>> :method => :get
RestClient::ResourceNotFound: 404 Resource Not Found: 

# To ensure we don't have a stale object, get the _attrs XML for our
# Image, img:
>> r = conn.do_request
>> "/images/f4650089-9716-41cb-86e8-bb1efd93eb05/_attrs", :method =>
>> :get
>> r.to_s
=> "<?xml version="1.0"?>\n<object>\n\t<object_body
path="http://localhost:9090/images/f4650089-9716-41cb-86e8-bb1efd93eb05"/>\n\t<object_attr_list
path="http://localhost:9090/images/f4650089-9716-41cb-86e8-bb1efd93eb05/_attrs"/>\n\t<object_attr
name="latest_build"
path="http://localhost:9090/images/f4650089-9716-41cb-86e8-bb1efd93eb05/latest_build"/>\n\t<object_attr
name="object_type"
path="http://localhost:9090/images/f4650089-9716-41cb-86e8-bb1efd93eb05/object_type"/>\n\t<object_attr
name="template"
path="http://localhost:9090/images/f4650089-9716-41cb-86e8-bb1efd93eb05/template"/>\n\t<object_attr
name="uuid"
path="http://localhost:9090/images/f4650089-9716-41cb-86e8-bb1efd93eb05/uuid"/>\n</object>\n"

The deleted template is still referenced in the _attrs list (towards the
end of the XML), although it no longer exists.

Again, this is not happening in normal usage -- I was manually removing
the Template in an attempt to test some code relating to Images without
Templates -- so this is possibly an edge case.

-- Matt


More information about the iwhd-devel mailing list