[ 
https://issues.apache.org/jira/browse/JCLOUDS-334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13786300#comment-13786300
 ] 

Diwaker Gupta commented on JCLOUDS-334:
---------------------------------------

Turns out this is broken in different ways for different blobstores.

* AFAICT (from the wire logs), AWS-S3 does NOT return "409 Conflict" when the 
PUT Bucket is re-issued using the same credentials; instead, it just returns 
200. Google Cloud Storage, on the other hand, does return 409 and thus 
createContainerInLocation returns false as expected on the second invocation.

* AtmosBlobStore always returns true, whether or not the call failed:

```
   @Override
   public boolean createContainerInLocation(Location location, String 
container) {
      sync.createDirectory(container);
      return true;
   }
```

Note that sync.createDirectory returns a URI, so it is unclear how one would 
even use that return value to translate to a bool in a sane way.

* As documented at 
(http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_Container-d1e1694.html),
 Cloudfiles returns "201 Created" on the first call and "202 Accepted" on the 
second. Jclouds doesn't seem to be translating this properly. This is identical 
to vanilla Openstack Swift behavior 
(http://docs.openstack.org/api/openstack-object-storage/1.0/content/create-container.html)
 so likely impacts all Swift providers.

The only sensible options I see are:

* Deprecate the boolean return value and introduce a variant that returns void. 
Let callers explicitly call `containerExists` if they need.
* Alternatively, rewrite the base implementation of `createContainerInLocation` 
to explicitly call `containerExists` first. This can be optimized for 
blobstores that actually indicate the correct status in the create container 
call.

> createContainerInLocation returns true even if container exists
> ---------------------------------------------------------------
>
>                 Key: JCLOUDS-334
>                 URL: https://issues.apache.org/jira/browse/JCLOUDS-334
>             Project: jclouds
>          Issue Type: Bug
>          Components: jclouds-blobstore
>    Affects Versions: 1.6.2
>            Reporter: Diwaker Gupta
>
> Javadocs for `createContainerInLocation` state (from 
> http://javadocs.jclouds.cloudbees.net/org/jclouds/blobstore/BlobStore.html):
> "Returns: true if the container was created, false if it already existed."
> The following simple test snippet verifies this:
> ```
>         assertThat(blobStore.createContainerInLocation(
>             /*location=*/ null, name)).isTrue();
>         assertTrue(blobStore.containerExists(name));
>         assertThat(blobStore.createContainerInLocation(
>             /*location=*/ null, name)).isFalse();
> ```
> I ran the test above for a variety of blobstores, and the test fails for 
> pretty much everyblobstore including aws-s3, cloudfiles, hpcloud, azureblob, 
> atmos etc. In my tests, it does pass when using generic S3 endpoints like 
> with Google cloud storage.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to