diff options
author | Chetan Risbud <crisbud@redhat.com> | 2014-03-04 19:35:24 +0530 |
---|---|---|
committer | Chetan Risbud <crisbud@redhat.com> | 2014-03-12 06:00:20 -0700 |
commit | 1a6b55714fddf7a1b526a31ee3f27589f01e98e5 (patch) | |
tree | 8d51f9dfa85e6eb17d1fa214949ed7de9daf8fda /gluster/swift/obj/server.py | |
parent | 47cbf09a228040ea33918a472481f464ef9ad261 (diff) |
PUT of a Directory failed
PUT of a directory fails with gluster-swift when there exists
object of a same name. This is because the objects and directories are placed on
the glusterfs. And hence the filesystem semantics are applicable there.
Exceptions raised in such situation are needed to be handled and reported
correctly back to proxy-server with HTTPConflict as a error code. Although
swift still continues to choose 503 as the best respose in such cases. No
tracebacks reported.
Fix covers the case when there exists a directory and object of the same
name is PUT.
Code changes fixes both the failure cases mentioned in the bug.
Examples of failing PUT requests:
1) curl -v -X PUT http://127.0.0.1:8080/v1/AUTH_test/c1/dir1/obj2/anotherobject
-d'asdasdsadA'
-- obj2 was already an object.
2)curl -v -H 'Content-Length: 0' -H 'Content-Type: application/directory' -X PUT
http://127.0.0.1:8080/v1/AUTH_test/c1/obj1
-- obj1 was already and object
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1071021
Change-Id: Id3042d920e3f99e740d4042ef5907ac8c59e04db
Signed-off-by: Chetan Risbud <crisbud@redhat.com>
Reviewed-on: http://review.gluster.org/7181
Reviewed-by: Prashanth Pai <ppai@redhat.com>
Tested-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'gluster/swift/obj/server.py')
-rw-r--r-- | gluster/swift/obj/server.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gluster/swift/obj/server.py b/gluster/swift/obj/server.py index 6417475..3cdd3c0 100644 --- a/gluster/swift/obj/server.py +++ b/gluster/swift/obj/server.py @@ -1,4 +1,4 @@ -# Copyright (c) 2012-2013 Red Hat, Inc. +# Copyright (c) 2012-2014 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,6 +18,11 @@ # Simply importing this monkey patches the constraint handling to fit our # needs import gluster.swift.common.constraints # noqa +from swift.common.swob import HTTPConflict +from swift.common.utils import public, timing_stats +from gluster.swift.common.exceptions import AlreadyExistsAsFile, \ + AlreadyExistsAsDir +from swift.common.request_helpers import split_and_validate_path from swift.obj import server @@ -80,6 +85,16 @@ class ObjectController(server.ObjectController): """ return + @public + @timing_stats() + def PUT(self, request): + try: + return server.ObjectController.PUT(self, request) + except (AlreadyExistsAsFile, AlreadyExistsAsDir): + device = \ + split_and_validate_path(request, 1, 5, True) + return HTTPConflict(drive=device, request=request) + def app_factory(global_conf, **local_conf): """paste.deploy app factory for creating WSGI object server apps""" |