swiftclient raises Exception about resource not found

Bug #1646545 reported by Fabrizio Vanni
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ospurge
Invalid
Undecided
Unassigned

Bug Description

When I try to cleanup a project, I get an error from swiftclient.
I'm working on devstack stable/mitaka, the command is the following:

~/projects/ospurge $ ospurge --cleanup-project proj01
Traceback (most recent call last):
  File "/home/vannif/.venvs/ospurge/bin/ospurge", line 10, in <module>
    sys.exit(main())
  File "/home/vannif/.venvs/ospurge/local/lib/python2.7/site-packages/ospurge/client.py", line 850, in main
    args.insecure, **data)
  File "/home/vannif/.venvs/ospurge/local/lib/python2.7/site-packages/ospurge/client.py", line 662, in perform_on_project
    res_actions[action]()
  File "/home/vannif/.venvs/ospurge/local/lib/python2.7/site-packages/ospurge/base.py", line 154, in purge
    resources = self.list()
  File "/home/vannif/.venvs/ospurge/local/lib/python2.7/site-packages/ospurge/client.py", line 78, in list
    for cont in self.list_containers():
  File "/home/vannif/.venvs/ospurge/local/lib/python2.7/site-packages/ospurge/client.py", line 70, in list_containers
    http_conn=self.http_conn)[1]
  File "/home/vannif/.venvs/ospurge/local/lib/python2.7/site-packages/swiftclient/client.py", line 766, in get_account
    raise ClientException.from_response(resp, 'Account GET failed', body)
swiftclient.exceptions.ClientException: Account GET failed: http://192.168.122.15:8080/?format=json 404 Not Found [first 60 chars of response] <html><h1>Not Found</h1><p>The resource could not be found.<

HTTP traffic reports what I think is a wrong endpoint for the account details request:

GET /?format=json

instead of

GET /v1/{account}?format=json

The trace is the following

GET /?format=json HTTP/1.1
Host: 192.168.122.15:8080
user-agent: python-swiftclient-3.2.0
accept-encoding: gzip
x-auth-token: c01ebcff9b95460c8e360ff5ce1d762b

HTTP/1.1 404 Not Found
Content-Length: 70
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txa29bf16be1654a61a5ea8-0058404906
Date: Thu, 01 Dec 2016 16:00:06 GMT

<html><h1>Not Found</h1><p>The resource could not be found.</p></html>

I modified the following lines and it seems to be working fine:

--- a/ospurge/client.py
+++ b/ospurge/client.py
@@ -59,15 +59,11 @@ class SwiftResources(base.Resources):
         super(SwiftResources, self).__init__(session)
         self.endpoint = self.session.get_endpoint("object-store")
         self.token = self.session.token
- conn = swift_client.HTTPConnection(self.endpoint,
- insecure=self.session.insecure)
- self.http_conn = conn.parsed_url, conn
+ self.conn = swift_client.Connection(session=session.keystone_session)

     # This method is used to retrieve Objects as well as Containers.
     def list_containers(self):
- containers = swift_client.get_account(self.endpoint,
- self.token,
- http_conn=self.http_conn)[1]
+ containers = self.conn.get_account()[1]
         return (cont['name'] for cont in containers)

@@ -77,17 +73,13 @@ class SwiftObjects(SwiftResources):
         swift_objects = []
         for cont in self.list_containers():
             objs = [{'container': cont, 'name': obj['name']} for obj in
- swift_client.get_container(self.endpoint,
- self.token,
- cont,
- http_conn=self.http_conn)[1]]
+ self.conn.get_container(cont)[1]]
             swift_objects.extend(objs)
         return swift_objects

     def delete(self, obj):
         super(SwiftObjects, self).delete(obj)
- swift_client.delete_object(self.endpoint, token=self.token, http_conn=self.http_conn,
- container=obj['container'], name=obj['name'])
+ self.conn.delete_object(obj['container'], obj['name'])

     def resource_str(self, obj):
         return "object {} in container {}".format(obj['name'], obj['container'])
@@ -101,7 +93,7 @@ class SwiftContainers(SwiftResources):
     def delete(self, container):
         """Container must be empty for deletion to succeed."""
         super(SwiftContainers, self).delete(container)
- swift_client.delete_container(self.endpoint, self.token, container, http_conn=self.http_conn)
+ self.conn.delete_container(container)

     def resource_str(self, obj):
         return "container {}".format(obj)

Revision history for this message
Jordan Pittier (jordan-pittier) wrote :

Now that ospurge has been rewritten (https://review.openstack.org/#/c/406160/) I believe this is not a valid bug anymore. Please reopen if need be.

Changed in ospurge:
status: New → Invalid
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.