Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

409 Client Error #10

Closed
benmccann opened this Issue Nov 5, 2012 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

benmccann commented Nov 5, 2012

Deleting a container often gives me a "409 Client Error". I don't understand what this error is being caused by and it seems very random. The files are still deleted, but the exception causes my code to bomb out and the error message "client error" gives me no insight into what is causing the error. It would be nice to fix it so that this error does not happen or so that the error message is more helpful.

Contributor

sudorandom commented Nov 5, 2012

Hey, could you paste an example trace stack? Deleting a container with objects in it gives a 409 error signifying that the container you are deleting currently has objects in it that need to be deleted before the container can be deleted. However, it should raise a 'ContainerNotEmpty' error.

If you're using the recursive option, be warned that that is currently an experimental feature which may have some issues for large containers with > 10,000 objects.

Contributor

benmccann commented Nov 5, 2012

I was getting the error with and without the recursive option. I'm using the version available from pip.

$ ./modules/mongodb_backup/files/delete_backup.py
Traceback (most recent call last):
File "./modules/mongodb_backup/files/delete_backup.py", line 9, in
sl_storage[container].delete(recursive=True)
File "/usr/local/lib/python2.7/dist-packages/object_storage/container.py", line 173, in delete
return self.client.delete_container(self.name, recursive=recursive)
File "/usr/local/lib/python2.7/dist-packages/object_storage/client.py", line 256, in delete_container
return self.make_request('DELETE', [name], params=params, formatter=_formatter)
File "/usr/local/lib/python2.7/dist-packages/object_storage/client.py", line 336, in make_request
result = self.conn.make_request(method, url, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/object_storage/transport/httplib2conn.py", line 59, in make_request
response.raise_for_status()
File "/usr/local/lib/python2.7/dist-packages/object_storage/transport/init.py", line 31, in raise_for_status
raise ResponseError(self.status_code, '%s Client Error' % self.status_code)
object_storage.errors.ResponseError: 409: 409 Client Error

Contributor

sudorandom commented Nov 6, 2012

If it's likely that only one process will be deleting this container at the same time this code should be sufficient.

container.delete_all_objects()
container.delete()

If it's likely that something else is adding to that container at the same time, I recommend catching object_storage.errors.ContainerNotEmpty errors and retrying a number of times before failing.

The commit above fixes it so that the ContainerNotEmpty error is raised instead of a generic ClientError which you'd have to inspect before knowing how to handle it.

More details on deleting containers: http://docs.openstack.org/api/openstack-object-storage/1.0/content/delete-container.html

Contributor

benmccann commented Nov 8, 2012

@benmccann benmccann closed this Nov 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment