Skip to content

Commit 01be768

Browse files
committed
Update PR to work around the create bucket mandatory quota setting
The CloudStack UI and API now require a quota setting to be configured on all buckets. HyperStore does not support a bucket quota limit setting. As a work around, this commit allows a quota setting of 0 to indicate there is no quota limit. Any other non-zero value will cause the quota setting to fail. HyperStore may add a bucket quota limit setting in a future version at which time we will address this further. Additionally fix pom to update version
1 parent 7430c0c commit 01be768

4 files changed

Lines changed: 31 additions & 14 deletions

File tree

plugins/storage/object/cloudian/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Cloudian HyperStore is a fully AWS-S3 compatible Object Storage solution. The fo
2020

2121
1. Enable Bucket Usage Statistics
2222

23-
Bucket Level QoS settings must be set to true. On HyperStore 8+, this can be done as follows. Earlier versions require puppet configuration not documented here.
23+
Bucket Level QoS settings must be set to true. On HyperStore 8+, this can be done as follows. Earlier versions require puppet configuration which is not documented here.
2424

2525
```shell
2626
hsh$ hsctl config set s3.qos.bucketLevel=true
27-
hsh$ hsctl config apply s3
28-
hsh$ hsctl service restart --nodes=ALL
27+
hsh$ hsctl config apply s3 cmc
28+
hsh$ hsctl service restart s3 cmc --nodes=ALL
2929
```
3030

3131
2. The Admin API Username and Password
@@ -104,7 +104,7 @@ The following are noteworthy.
104104

105105
### Bucket Quota is Unsupported
106106

107-
This operation is not supported by this plugin. Cloudian HyperStore does not currently support restricting the size of a bucket to a particular quota.
107+
Cloudian HyperStore does not currently support restricting the size of a bucket to a particular quota limit. The plugin accepts a quota value of 0 to indicate no quota setting. When creating a bucket in the CloudStack UI, the user is required to set a quota of 0. Any other value will fail.
108108

109109
### Bucket Usage
110110

plugins/storage/object/cloudian/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<parent>
2525
<groupId>org.apache.cloudstack</groupId>
2626
<artifactId>cloudstack-plugins</artifactId>
27-
<version>4.20.0.0-SNAPSHOT</version>
27+
<version>4.21.0.0-SNAPSHOT</version>
2828
<relativePath>../../../pom.xml</relativePath>
2929
</parent>
3030
<dependencies>

plugins/storage/object/cloudian/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudianHyperStoreObjectStoreDriverImpl.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,17 +728,27 @@ public boolean deleteBucketVersioning(BucketTO bucket, long storeId) {
728728
}
729729

730730
/**
731-
* Set the bucket quota to size bytes.
731+
* Set the bucket quota to a size limit specified in GiB.
732+
*
733+
* Cloudian HyperStore does not currently support bucket quota limits.
734+
* CloudStack itself requires a quota to be set. HyperStore may add
735+
* Bucket Quota support in a future version. Currently, we only support
736+
* setting the quota to zero to indicate no quota.
737+
*
732738
* @param bucket the bucket
733739
* @param storeId the store
734-
* @param size the GB (1000^3) size to set the quota to.
735-
* @throws CloudRuntimeException is always thrown as Cloudian does not currently
736-
* implement bucket quotas.
740+
* @param size the GiB (1024^3) size to set the quota to. Only 0 is supported.
741+
* @throws CloudRuntimeException is thrown for any other value other than 0.
737742
*/
738743
@Override
739744
public void setBucketQuota(BucketTO bucket, long storeId, long size) {
740-
logger.warn("Unable to set quota for bucket \"{}\" to {}GB. Cloudian does not implement Bucket Quota.", bucket.getName(), size);
741-
throw new CloudRuntimeException("This bucket does not support quotas.");
745+
if (size == 0) {
746+
logger.debug("Bucket \"{}\" quota set to 0 (no quota).", bucket.getName());
747+
return;
748+
}
749+
// Any other setting, throw an exception.
750+
logger.warn("Unable to set quota for bucket \"{}\" to {}GiB. Only 0 is supported.", bucket.getName(), size);
751+
throw new CloudRuntimeException("This bucket does not support a quota. Use 0 to specify no quota.");
742752
}
743753

744754
/**

plugins/storage/object/cloudian/src/test/java/org/apache/cloudstack/storage/datastore/driver/CloudianHyperStoreObjectStoreDriverImplTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,18 @@ public void testSetBucketPolicyPublic() throws Exception {
556556
}
557557

558558
@Test(expected = CloudRuntimeException.class)
559-
public void testSetBucketQuota() {
559+
public void testSetBucketQuotaNonZero() {
560560
BucketTO bucket = mock(BucketTO.class);
561561
when(bucket.getName()).thenReturn(TEST_BUCKET_NAME);
562-
// Quota is not implemented by HyperStore, we throw an CloudRuntimeException.
563-
cloudianHyperStoreObjectStoreDriverImpl.setBucketQuota(bucket, TEST_STORE_ID, 5000L);
562+
// Quota is not implemented by HyperStore. Throws a CloudRuntimeException if not 0.
563+
cloudianHyperStoreObjectStoreDriverImpl.setBucketQuota(bucket, TEST_STORE_ID, 5L);
564+
}
565+
566+
public void testSetBucketQuotaToZero() {
567+
BucketTO bucket = mock(BucketTO.class);
568+
when(bucket.getName()).thenReturn(TEST_BUCKET_NAME);
569+
// A zero quota indicates no quota and should be an accepted value.
570+
cloudianHyperStoreObjectStoreDriverImpl.setBucketQuota(bucket, TEST_STORE_ID, 0);
564571
}
565572

566573
@Test

0 commit comments

Comments
 (0)