You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/12/30 07:28:36 UTC
[GitHub] [ozone] captainzmc opened a new pull request #1746: HDDS-4631. Fixed client set quota with 0.
captainzmc opened a new pull request #1746:
URL: https://github.com/apache/ozone/pull/1746
## What changes were proposed in this pull request?
Currently setting Quota is invalid if set to 0. It's actually going to be set to -1.
`store.getVolume(volumeName).getBucket(bucketName).setQuota(`
` OzoneQuota.parseQuota("0GB", 0));`
` Assert.assertEquals(-1, bucket.getQuotaInBytes());`
` Assert.assertEquals(-1, bucket.getQuotaInNamespace());`
This behavior is actually incorrect, and we should actually support quota setting to 0:
`store.getVolume(volumeName).getBucket(bucketName).setQuota(`
` OzoneQuota.parseQuota("0GB", 0));`
` Assert.assertEquals(0, bucket.getQuotaInBytes());`
` Assert.assertEquals(0, bucket.getQuotaInNamespace());`
This problem occurs because the original client quota type is long. If the user does not specify quota, the default value for this field is 0.
A backend validation fails to verify that the user did not specify quota or set quoat to 0, since both actions are passed to the backend to be 0.
So it would be more appropriate to change the long to a string. If the user does not specify quota, it is null. It's easier to judge.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-4631
## How was this patch tested?
ut added
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754432275
Hi @linyiqun @ayushtkn Sorry for the late reply, we can continue to discuss this problem.
Maybe I didn't make it clear before, let's do an example:
ozone sh bucket create vol1 (This should be success)
ozone sh bucket create vol1 --space-quota 0TB --namespace-quota 0 (This should be unsuccessful)
These are two different cases. But both cases in [CreateVolumeHandler quotaOptions.getQuotaInNamespace()](https://github.com/apache/ozone/blob/master/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java#L68) is 0.

Different cases receives the same parameters. Because the long variable is also 0 by default when it is not declared.
Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
Because of this, I changed long to a string.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557471199
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
Comments make sense to me, @captainzmc , @ChenSammi
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757949546
> I see OmVolumeArgs resets the quotaInBytes/quotaInNamespace to OzoneConsts.QUOTA_RESET in its builder function. We can also make this change in OmBucketArgs# builder constructor. In addition, we should also reset quota when 0 was passed in constructor method.
+1 Good advice. I found there are some bugs with creating volumes and buckets when quota is specified to 0 or not. This proposal can fix these problems. I will fix it in a new commit.
The previous Commit had add check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555132350
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
@captainzmc , can we rollback long to string convert for namspace quota now? As default quota 0 will all be converted to Quota.RESET based on above approach that we discussed. Or we can create a new PR for this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555508046
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
The above advice only solves the problem of creating a Volume or Bucket.
The string quotainNamespace in parseQuota is still useful for verifying whether the user passed quotainNamespace.
Let's look at this case:
If the original volume space and namespace quoat were 100 and 10T, respectively, we reset the space quota separately.
ozone sh volume setquota vol1 --space-quota 20TB
OzoneConsts.QUOTA_RESET is the default quota for VolumeArgs. The space and namespace quota for vol1 will change to -1 and 20T, which is not expected.
I think it makes more sense to handle these cases in Ozonequota #parseQuota. Also, spaceQuota is currently a String in parseQuota, which makes our client-side processing logic more consistent.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752655335
@ayushtkn Fixed review issues. Related to setting namespace quoat, cc @amaliujia @linyiqun.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ayushtkn commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ayushtkn commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753953517
I am even not sure about converting to string type. If the user hasn't specified, Can't we send specific constant like QUOTA_DONT_SET(Something like this is there in HdfsConstants) to distinguish. We can even just validate at client side and leave the server side as is, Like don't bother with 0. Might help for compatibility reasons.
The present aim is like we don't support 0, it is not taking affect also. We just need to tell the client it won't work and save an RPC, if he tends to shoot 0.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: WIP: HDDS-4631. Fixed client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752381135
> In general setting quota to 0 isn't a valid entry even in HDFS.
> It throws an exception
@ayushtkn Thanks for the tip. I think we can be consistent with HDFS on this part. I'll commit a new commit to fix it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752666197
@captainzmc , If setting quota to 0 is not allowed now, can we rollback unrelated change in this PR?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557425298
##########
File path: hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java
##########
@@ -59,13 +61,19 @@ protected void execute(OzoneClient client, OzoneAddress address)
VolumeArgs.Builder volumeArgsBuilder = VolumeArgs.newBuilder()
.setAdmin(adminName)
.setOwner(ownerName);
- if (quotaOptions.getQuotaInBytes() != null) {
- volumeArgsBuilder.setQuotaInBytes(OzoneQuota.parseQuota(
- quotaOptions.getQuotaInBytes(),
- quotaOptions.getQuotaInNamespace()).getQuotaInBytes());
+ if (!Strings.isNullOrEmpty(quotaOptions.getQuotaInBytes())) {
+ volumeArgsBuilder.setQuotaInBytes(OzoneQuota.parseSpaceQuota(
+ quotaOptions.getQuotaInBytes()).getQuotaInBytes());
+ } else {
+ volumeArgsBuilder.setQuotaInBytes(OzoneConsts.QUOTA_RESET);
Review comment:
This part is superfluous and can be deleted
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754432275
Hi @linyiqun @ayushtkn Sorry for the late reply, we can continue to discuss this problem.
Maybe I didn't make it clear before, let's do an example:
ozone sh bucket create vol1 (This should be success)
ozone sh bucket create vol1 --namespace-quota 0 (This should be unsuccessful)
These are two different cases. But both cases in [CreateVolumeHandler quotaOptions.getQuotaInNamespace()](https://github.com/apache/ozone/blob/master/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java#L68) is 0.

In client side, different cases has the same parameters. Because the long variable is also 0 by default when it is not declared.
Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
Because of this, I changed long to a string. This should be the most direct way.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-761948474
+1. Thanks @captainzmc for the contribution and @linyiqun @amaliujia @ayushtkn for the code review.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754432275
Hi @linyiqun @ayushtkn Sorry for the late reply, we can continue to discuss this problem.
Maybe I didn't make it clear before, let's do an example:
ozone sh bucket create vol1 (This should be success)
ozone sh bucket create vol1 --space-quota 0TB --namespace-quota 0 (This should be unsuccessful)
These are two different cases. But both cases in [CreateVolumeHandler quotaOptions.getQuotaInNamespace()](https://github.com/apache/ozone/blob/master/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java#L68) is 0.

Different cases receives the same parameters in client. Because the long variable is also 0 by default when it is not declared.
Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
Because of this, I changed long to a string.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fixed client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752381135
> In general setting quota to 0 isn't a valid entry even in HDFS.
> It throws an exception
@ayushtkn Thanks for the tip. I think we can be consistent with HDFS on this part. Later I will commit a new commit to fix it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753425854
{quote}
First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
{quote}
I don't fully get why we need to distinguish whether the user sets quota to 0. If the long undefined value is 0, we could return a Quota.RESET value instead of while get the quota value for this case. I don't think this is a problem here. And for other cases, we don't allow 0 could be set by cli command after above change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752830548
> @captainzmc , If setting quota to 0 is not allowed now, can we rollback unrelated change in this PR?
@linyiqun Thanks for the tip.
I think currently all changes to this PR are required。
First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
So, we need to change quotaInNamespace from long to String. In addition, it is also possible for users to specify either quotaInBytes or quotaInNamespace separately. Also, many cases of original UT are not covered, so I made a supplement separately.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi merged pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi merged pull request #1746:
URL: https://github.com/apache/ozone/pull/1746
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r550423090
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
Review comment:
If the user specifies quota when creating bucket and volume,the default is -1, indicating that quota is not enabled.
A quota value of -2 is a special case, because older clusters such as previous versions of Ozone1.0, volume Info and bucket Info do not have quotaInBytes and quotaInNamespace in them. After such a cluster is upgraded to Ozone1.1, these fields become to 0 when getting volume Info and bucket Info because they didn't exist before, so in HDDS-4562 proto is set to -2 by default, indicating that these volumes and buckets are old, and their quota is also not enabled. Currently, it is not recommended to enable quota for these volumes and buckets because their usedbyte and usedNamespace are incorrect. So, -2 is more used to distinguish between old volumes and buckets. Later if we can support recalculation of usedbyte and usedNamespace. This lets us know which volumes and buckets need to be recalculated.
To disable quota, use the clrquota method instead of setquota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557472535
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +207,48 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
Review comment:
Can you update quota to 'space quota' that will be more accurate for this exception?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557379762
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -145,21 +163,14 @@ public static String formatQuota(OzoneQuota quota) {
}
/**
- * Parses a user provided string and returns the
+ * Parses a user provided string space quota and returns the
* Quota Object.
*
* @param quotaInBytes Volume quota in bytes
- * @param quotaInNamespace Volume quota in counts
*
* @return OzoneQuota object
*/
- public static OzoneQuota parseQuota(String quotaInBytes,
- long quotaInNamespace) {
-
- if (Strings.isNullOrEmpty(quotaInBytes)) {
- throw new IllegalArgumentException(
- "Quota string cannot be null or empty.");
- }
Review comment:
Shall we keep this null check or add new Precondition check that quotaInBytes cannot be null or empty.
This suggestion also applies to parseNameSpaceQuota.
Because these two functions are public static, we need to do some kind of parameter check.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557473429
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +207,48 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ if (Strings.isNullOrEmpty(quotaInNamespace)) {
+ throw new IllegalArgumentException(
+ "Quota string cannot be null or empty.");
+ }
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
Review comment:
Similar comment: quota to namespace quota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun removed a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun removed a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752666197
@captainzmc , If setting quota to 0 is not allowed now, can we rollback unrelated change in this PR?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-755055918
> > Let's look at another example,this also has the same problem:
> > ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
> > ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
>
> @captainzmc , this will be not a problem.
We can reproduce the case I mentioned above using UT in the current master code. Add the following test code in UT:

Set the breakpoint in SetQuotaHandler. Execute the test. We can see that although namespace quota was not specified, 0 was passed in anyway. Because when this field is not defined get the default value (0) of long.

The first case can also reproduce with the testShQuota UT, adding a breakpoint at CreateVolumeHandler. Execute the test.

> For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
> So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
We need to distinguish whether this '0' was set by the user actively or user didn't set this field so that the code uses the default value of long.
At the moment, I can't think of anything better than replacing a long with a string (which is easier to judge because the default value of a String is null not 0). Is any advice here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557392904
##########
File path: hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java
##########
@@ -59,13 +61,19 @@ protected void execute(OzoneClient client, OzoneAddress address)
VolumeArgs.Builder volumeArgsBuilder = VolumeArgs.newBuilder()
.setAdmin(adminName)
.setOwner(ownerName);
- if (quotaOptions.getQuotaInBytes() != null) {
- volumeArgsBuilder.setQuotaInBytes(OzoneQuota.parseQuota(
- quotaOptions.getQuotaInBytes(),
- quotaOptions.getQuotaInNamespace()).getQuotaInBytes());
+ if (!Strings.isNullOrEmpty(quotaOptions.getQuotaInBytes())) {
+ volumeArgsBuilder.setQuotaInBytes(OzoneQuota.parseSpaceQuota(
+ quotaOptions.getQuotaInBytes()).getQuotaInBytes());
+ } else {
+ volumeArgsBuilder.setQuotaInBytes(OzoneConsts.QUOTA_RESET);
Review comment:
With default quotaInBytes and quotaInNamespace value, do we still need this and below else statement?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-755055918
> > Let's look at another example,this also has the same problem:
> > ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
> > ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
>
> @captainzmc , this will be not a problem.
We can reproduce the case I mentioned above using UT in the current master code. Add the following test code in UT:

Set the breakpoint in SetQuotaHandler. Execute the test. We can see that although namespace quota was not specified, 0 was passed in anyway. Because when this field is not defined get the default value (0) of long.

The first case can also reproduce with the testShQuota UT, adding a breakpoint at CreateVolumeHandler. Execute the test.

> For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
> So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,I also agree this. The point is, how do we do that?
We need to distinguish whether this '0' was set by the user actively or user didn't set it so that the code uses the default value of long.
At the moment, I can't think of anything better than replacing a long with a string (which is easier to judge because the default value of a String is null not 0). Is any advice here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753425854
>First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
I don't fully get why we need to distinguish whether the user sets quota to 0. If the long undefined value is 0, we could return a Quota.RESET value instead of while get the quota value for this case. I don't think this is a problem here. And for other cases, we don't allow 0 could be set by cli command after above change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r550423090
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
Review comment:
If the user not specifies quota when creating bucket and volume,the default is -1, indicating that quota is not enabled.
A quota value of -2 is a special case, because older clusters such as previous versions of Ozone1.0, volume Info and bucket Info do not have quotaInBytes and quotaInNamespace in them. After such a cluster is upgraded to Ozone1.1, these fields become to 0 when getting volume Info and bucket Info because they didn't exist before, so in HDDS-4562 proto is set to -2 by default, indicating that these volumes and buckets are old, and their quota is also not enabled. Currently, it is not recommended to enable quota for these volumes and buckets because their usedbyte and usedNamespace are incorrect. So, -2 is more used to distinguish between old volumes and buckets. Later if we can support recalculation of usedbyte and usedNamespace. This lets us know which volumes and buckets need to be recalculated.
To disable quota, use the clrquota method instead of setquota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555508046
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
The above advice only solves our problem of creating volume or bucket, not setquota.
The string quotainNamespace in parseQuota is still useful for verifying whether the user passed quotainNamespace.Let's look at this case:
If the original volume space and namespace quoat were 100 and 10T, respectively, we reset the space quota separately:
ozone sh volume setquota vol1 --space-quota 20TB
OzoneConsts.QUOTA_RESET is the default quota for VolumeArgs. The space and namespace quota for vol1 will change to -1 and 20T, which is not expected.
I think it makes more sense to handle these cases in Ozonequota #parseQuota. Also, spaceQuota is currently a String in parseQuota, which makes our client-side processing logic more consistent, making the code easier to maintain.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555132350
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
@captainzmc , can we rollback long to string convert for namspace quota now? As default quota 0 will all be converted to Quota.RESET based on above approach that we discussed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753425854
>First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
I don't fully get why we need to distinguish whether the user sets quota to 0. If the long undefined value is 0, we could return a Quota.RESET value instead of while get the quota value for this case. I don't think this is a problem here. And for other cases, we don't allow 0 could be set by cli command after above change. It looks confused we pass a string type value for namespace quota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753425854
>First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
I don't fully get why we need to distinguish whether the user sets quota to 0. Above two cases both means the quota is disabled. If the long undefined value is 0, we could return a Quota.RESET value instead of. I don't think this is a problem here. In addition, we don't allow 0 could be set by cli command after above change. It looks confused we pass a string type value for namespace quota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555616799
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
Hi @linyiqun , thanks for review the code. We found bugs in production cluster with the previous implementation which doesn't distinguish the cases that user doesn't set the quota and user set the quota to 0. So it's better to make it clear to avoid bugs caused by concept vague.
In summary, for quota in bucket and volume,
1) quota value will be -2 to indicates it's 1.0.0 bucket/volume
2) quota value will be -1 if bucket/volume created without explicitly set quota value in 1.1.0
3) quota > 0 indicates quota is enabled
4) throw exception if user set quota to 0 to keep consistent with current HDFS behavior
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752655335
@ayushtkn Fixed review issues. Related to setting namespace quota, cc @amaliujia @linyiqun.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754432275
Hi @linyiqun @ayushtkn Sorry for the late reply, we can continue to discuss this problem.
Maybe I didn't make it clear before, let's do an example:
ozone sh bucket create vol1 (This should be success)
ozone sh bucket create vol1 --space-quota 0TB --namespace-quota 0 (This should be unsuccessful)
These are two different cases. But in both cases in [CreateVolumeHandler quotaOptions.getQuotaInNamespace()](https://github.com/apache/ozone/blob/master/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java#L68) is 0.

Different cases receives the same parameters. Because the long variable is also 0 by default when it is not declared.
Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
Because of this, I changed long to a string.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557398818
##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/volume/OMVolumeSetQuotaRequest.java
##########
@@ -189,7 +189,7 @@ public boolean checkQuotaBytesValid(OMMetadataManager metadataManager,
long volumeQuotaInBytes, String volumeName) throws IOException {
long totalBucketQuota = 0;
- if (volumeQuotaInBytes == 0) {
+ if (volumeQuotaInBytes < OzoneConsts.QUOTA_RESET) {
Review comment:
(volumeQuotaInBytes < OzoneConsts.QUOTA_RESET || volumeQuotaInBytes == 0) ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-759956010
Is any review update here? @linyiqun @amaliujia @ChenSammi
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757158465
>I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
@captainzmc , here I mean don't allow 0 can be set in quota from the client side. So we can just add check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota. Does this make sense to you?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557474988
##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetPropertyRequest.java
##########
@@ -239,7 +239,7 @@ public boolean checkQuotaBytesValid(OMMetadataManager metadataManager,
OMException.ResultCodes.QUOTA_ERROR);
}
- if (quotaInBytes == 0) {
+ if (quotaInBytes < OzoneConsts.QUOTA_RESET) {
Review comment:
Seems this should be update to quotaInBytes < OzoneConsts.QUOTA_RESET || quotaInBytes == 0 as well.
##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetPropertyRequest.java
##########
@@ -239,7 +239,7 @@ public boolean checkQuotaBytesValid(OMMetadataManager metadataManager,
OMException.ResultCodes.QUOTA_ERROR);
}
- if (quotaInBytes == 0) {
+ if (quotaInBytes < OzoneConsts.QUOTA_RESET) {
Review comment:
Seems this should be updated to quotaInBytes < OzoneConsts.QUOTA_RESET || quotaInBytes == 0 as well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757158465
>I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
@captainzmc , here I mean don't allow 0 can be set in quota from the client side. So we can just add limit check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota.
I see OmVolumeArgs resets the quotaInBytes/quotaInNamespace to OzoneConsts.QUOTA_RESET in its builder function. We can also make this change in OmBucketArgs# builder constructor. In addition, we should also reset quota when 0 was passed in constructor method.
```java
private OmBucketArgs(String volumeName, String bucketName,
Boolean isVersionEnabled, StorageType storageType,
Map<String, String> metadata, long quotaInBytes, long quotaInNamespace) {
this.volumeName = volumeName;
this.bucketName = bucketName;
this.isVersionEnabled = isVersionEnabled;
this.storageType = storageType;
this.metadata = metadata;
// if quota is 0, reset to OzoneConsts.QUOTA_RESET
this.quotaInBytes = quotaInBytes;
this.quotaInNamespace = quotaInNamespace;
}
```
Does this make sense to you?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754432275
Hi @linyiqun @ayushtkn Sorry for the late reply, we can continue to discuss this problem.
Maybe I didn't make it clear before, let's do an example:
ozone sh bucket create vol1 (This should be success)
ozone sh bucket create vol1 --space-quota 0TB --namespace-quota 0 (This should be unsuccessful)
These are two different cases. But both cases in [CreateVolumeHandler quotaOptions.getQuotaInNamespace()](https://github.com/apache/ozone/blob/master/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java#L68) is 0.

In client side, different cases has the same parameters. Because the long variable is also 0 by default when it is not declared.
Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
Because of this, I changed long to a string. This should be the most direct way.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754693002
>I am even not sure about converting to string type. If the user hasn't specified, Can't we send specific constant like QUOTA_DONT_SET(Something like this is there in HdfsConstants) to distinguish.
Suppose current logic already implement this logic(see below assert), if user hasn't specified quota. 0 means it comes from the long type default value as user.
```java
store.getVolume(volumeName).setQuota(OzoneQuota.parseQuota(
"0GB", 0L));
volume = store.getVolume(volumeName);
Assert.assertEquals(OzoneConsts.QUOTA_RESET, volume.getQuotaInBytes());
Assert.assertEquals(OzoneConsts.QUOTA_RESET, volume.getQuotaInNamespace());
```
>Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
@captainzmc , this will be not a problem. For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753425854
>First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
I don't fully get why we need to distinguish whether the user sets quota to 0. Could we just make this two cases be quota disabled? If the quota returned value is 0, we could return a Quota.RESET value instead of. In addition, we don't allow 0 could be set by cli command after above change. It looks confused we pass a string type value for namespace quota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757949546
> I see OmVolumeArgs resets the quotaInBytes/quotaInNamespace to OzoneConsts.QUOTA_RESET in its builder function. We can also make this change in OmBucketArgs# builder constructor. In addition, we should also reset quota when 0 was passed in constructor method.
Good advice. I found there are some bugs with creating volumes and buckets when quota is specified to 0 or not. This proposal can fix these problems. I will fix it in the new Commit.
The previous Commit had add check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757158465
>I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
@captainzmc , here I mean don't allow 0 can be set in quota from the client side. So we can just add limit check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota. Does this make sense to you?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757158465
>I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
@captainzmc , here I mean don't allow 0 can be set in quota from the client side. So we can just add check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota. Does this make sense to you?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754432275
Hi @linyiqun @ayushtkn Sorry for the late reply, we can continue to discuss this problem.
Maybe I didn't make it clear before, let's do an example:
ozone sh bucket create vol1 (This should be success)
ozone sh bucket create vol1 --space-quota 0TB --namespace-quota 0 (This should be unsuccessful)
These are two different cases. But both cases in [CreateVolumeHandler quotaOptions.getQuotaInNamespace()](https://github.com/apache/ozone/blob/master/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/CreateVolumeHandler.java#L68) is 0.

In client side, different cases has the same parameters. Because the long variable is also 0 by default when it is not declared.
Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
Because of this, I changed long to a string.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-760918923
Fixed review issues. cc @ChenSammi
CI runs normally on my [personal branch](https://github.com/captainzmc/hadoop-ozone/runs/1707185948). Failed UT is irrelevant.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-755055918
> > Let's look at another example,this also has the same problem:
> > ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
> > ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
>
> @captainzmc , this will be not a problem.
We can reproduce the case I mentioned above using UT in the current master code. Add the following test code in UT:

Set the breakpoint in SetQuotaHandler. Execute the test. We can see that although namespace quota was not specified, 0 was passed in anyway. Because when this field is not defined get the default value (0) of long.

The first case can also reproduce with the testShQuota UT, adding a breakpoint at CreateVolumeHandler. Execute the test.

> For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
> So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
We need to distinguish whether this '0' was set by the user actively or user didn't set this field so that the code uses the default value of long.
Is there anything better solution than replacing a long with a string (which is easier to judge because the default value of a String is null not 0)? any advice here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557475323
##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketSetPropertyRequest.java
##########
@@ -273,8 +273,7 @@ public boolean checkQuotaNamespaceValid(OmVolumeArgs omVolumeArgs,
OmBucketArgs omBucketArgs) {
long quotaInNamespace = omBucketArgs.getQuotaInNamespace();
- if ((quotaInNamespace <= 0
- && quotaInNamespace != OzoneConsts.QUOTA_RESET)) {
+ if (quotaInNamespace < OzoneConsts.QUOTA_RESET) {
Review comment:
Same comment for this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-754693002
>I am even not sure about converting to string type. If the user hasn't specified, Can't we send specific constant like QUOTA_DONT_SET(Something like this is there in HdfsConstants) to distinguish.
Suppose current logic already implement this logic(see below assert [TestOzoneRpcClientAbstract.java#L292](https://github.com/apache/ozone/blob/master/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java#L292)), if user hasn't specified quota. 0 means it comes from the long type default value as user.
```java
store.getVolume(volumeName).setQuota(OzoneQuota.parseQuota(
"0GB", 0L));
volume = store.getVolume(volumeName);
Assert.assertEquals(OzoneConsts.QUOTA_RESET, volume.getQuotaInBytes());
Assert.assertEquals(OzoneConsts.QUOTA_RESET, volume.getQuotaInNamespace());
```
>Let's look at another example,this also has the same problem:
ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
@captainzmc , this will be not a problem. For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555616799
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
Hi @linyiqun , thanks for review the code. We found bugs in production cluster with the previous implementation which doesn't distinguish the cases that user doesn't set the quota and user set the quota to 0. So it's better to make it clear to avoid bugs caused by concept vague.
In summary, for quota in bucket and volume,
1) quota value will be -2 to indicates it's 1.0.0 bucket/volume
2) quota value will be -1 if bucket/volume created without explicitly set quota value in 1.1.0
3) quota > 0 indicates quota is enabled
4) throw exception if user set quota to 0 to keep consistent with current HDFS behavior
I‘m not sure If I have answered your question. Let me know if a further explanation is needed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557379762
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -145,21 +163,14 @@ public static String formatQuota(OzoneQuota quota) {
}
/**
- * Parses a user provided string and returns the
+ * Parses a user provided string space quota and returns the
* Quota Object.
*
* @param quotaInBytes Volume quota in bytes
- * @param quotaInNamespace Volume quota in counts
*
* @return OzoneQuota object
*/
- public static OzoneQuota parseQuota(String quotaInBytes,
- long quotaInNamespace) {
-
- if (Strings.isNullOrEmpty(quotaInBytes)) {
- throw new IllegalArgumentException(
- "Quota string cannot be null or empty.");
- }
Review comment:
Shall we keep this null check?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-755055918
> > Let's look at another example,this also has the same problem:
> > ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
> > ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
>
> @captainzmc , this will be not a problem.
We can reproduce the case I mentioned above using UT in the current master code. Add the following test code in UT:

Set the breakpoint in SetQuotaHandler. Execute the test. We can see that although namespace quota was not specified, 0 was passed in anyway. Because when this field is not defined get the default value (0) of long.

The first case can also reproduce with the testShQuota UT, adding a breakpoint at CreateVolumeHandler. Execute the test.

> For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
> So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
We need to distinguish whether this '0' was set by the user actively or user didn't set it so that the code uses the default value of long.
At the moment, I can't think of anything better than replacing a long with a string (which is easier to judge because the default value of a String is null not 0). Is any advice here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-755055918
> > Let's look at another example,this also has the same problem:
> > ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
> > ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
>
> @captainzmc , this will be not a problem.
We can reproduce the case I mentioned above using UT in the current master code. Add the following test code in UT:

Set the breakpoint in SetQuotaHandler. Execute the test. We can see that although namespace quota was not specified, 0 was passed in anyway. Because when this field is not defined get the default value (0) of long.

The first case can also reproduce with the testShQuota UT, adding a breakpoint at CreateVolumeHandler. Execute the test.

> For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
> So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
We need to distinguish whether this '0' was set by the user actively or user didn't set this field so that the code uses the default value of long.
Is there anything better solution than replacing a long with a string (which is easier to judge because the default value of a String is null not 0)? Any advice here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757158465
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fixed client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752655335
Fixed review issues. cc @ayushtkn
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752830548
> @captainzmc , If setting quota to 0 is not allowed now, can we rollback unrelated change in this PR?
@linyiqun Thanks for the tip.
I think currently all changes to this PR are required。
First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
So, we need to change quotaInNamespace from long to String. In addition, it is also possible for users to specify either quotaInBytes or quotaInNamespace separately. In addition, many cases of original UT are not covered, so I made a supplement separately.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557399018
##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/volume/OMVolumeSetQuotaRequest.java
##########
@@ -213,8 +213,7 @@ public boolean checkQuotaBytesValid(OMMetadataManager metadataManager,
public boolean checkQuotaNamespaceValid(long quotaInNamespace) {
- if ((quotaInNamespace <= 0
- && quotaInNamespace != OzoneConsts.QUOTA_RESET)) {
+ if (quotaInNamespace < OzoneConsts.QUOTA_RESET) {
Review comment:
Same question as as above comment.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r550402535
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
Review comment:
Question: how to set QUOTA.RESET? (basically how to disable quota by set the quota). In the past I guess we can set -2 but now it seems disallowed.
For example, is there a case that a bucket is enabled quota, later users decide to disable the quota by setting a quota value?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-753425854
>First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
I don't fully get why we need to distinguish whether the user sets quota to 0. If the long undefined value is 0, we could return a Quota.RESET value instead of while get the quota value for this case. If user already set 0 in original logic, return Quota.RESET also make the sense for 0 quota value. I don't think this is a problem here. In addition, we don't allow 0 could be set by cli command after above change. It looks confused we pass a string type value for namespace quota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r555508046
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +201,44 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for quota: " + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseQuota(String quotaInBytes,
+ String quotaInNamespace) {
Review comment:
The above advice only solves our problem of creating volume or bucket, not setquota.
The string quotainNamespace in parseQuota is still useful for verifying whether the user passed quotainNamespace.Let's look at this case:
If the original volume space and namespace quoat were 100 and 10T, respectively, we reset the space quota separately:
ozone sh volume setquota vol1 --space-quota 20TB
OzoneConsts.QUOTA_RESET is the default quota for VolumeArgs. The space and namespace quota for vol1 will change to -1 and 20T, which is not expected.
I think it makes more sense to handle these cases in Ozonequota #parseQuota. Also, spaceQuota is currently a String in parseQuota, which makes our client-side processing logic more consistent.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-757949546
> I see OmVolumeArgs resets the quotaInBytes/quotaInNamespace to OzoneConsts.QUOTA_RESET in its builder function. We can also make this change in OmBucketArgs# builder constructor. In addition, we should also reset quota when 0 was passed in constructor method.
+1 Good advice. I found there are some bugs with creating volumes and buckets when quota is specified to 0 or not. This proposal can fix these problems. I will fix it in the new Commit.
The previous Commit had add check in OzoneQuota#parseQuota and RpcClient#verifyCountsQuota/verifySpaceQuota.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-755055918
> > Let's look at another example,this also has the same problem:
> > ozone sh volume setquota vol1 --space-quota 10TB (This should be success)
> > ozone sh volume setquota vol1 --space-quota 10TB --namespace-quota 0 (This should be unsuccessful)
>
> @captainzmc , this will be not a problem.
Hi @linyiqun. Thanks for the reply.
We can reproduce the case I mentioned above using UT in the current master code. Add the following test code in UT:

Set the breakpoint in SetQuotaHandler. Execute the test. We can see that although namespace quota was not specified, 0 was passed in anyway. Because when this field is not defined get the default value (0) of long.

The first case can also reproduce with the testShQuota UT, adding a breakpoint at CreateVolumeHandler. Execute the test.

> For first case that don't specified namespace quota, now the real meaning is the quota unset not means namepsace quota was 0.
> So I prefer only to make the adjustment that don't allow 0 can be set in this PR change.
I agree that we need to distinguish between these two different behaviors of the user. ”Don't allow 0 can be set“ It's our purpose,also agree this. The point is, how do we do that?
We need to distinguish whether this '0' was set by the user actively or user didn't set this field so that the code uses the default value of long.
Is there anything better solution than replacing a long with a string (which is easier to judge because the default value of a String is null not 0)? Any advice here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi edited a comment on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi edited a comment on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-761948474
+1. Thanks @captainzmc for the contribution and @linyiqun @amaliujia for the code review.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557393254
##########
File path: hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/CreateBucketHandler.java
##########
@@ -80,12 +81,19 @@ public void execute(OzoneClient client, OzoneAddress address)
}
}
- if (quotaOptions.getQuotaInBytes() != null) {
- bb.setQuotaInBytes(OzoneQuota.parseQuota(quotaOptions.getQuotaInBytes(),
- quotaOptions.getQuotaInNamespace()).getQuotaInBytes());
+ if (!Strings.isNullOrEmpty(quotaOptions.getQuotaInBytes())) {
+ bb.setQuotaInBytes(OzoneQuota.parseSpaceQuota(
+ quotaOptions.getQuotaInBytes()).getQuotaInBytes());
+ } else {
+ bb.setQuotaInBytes(OzoneConsts.QUOTA_RESET);
Review comment:
Same as below comment.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] linyiqun commented on a change in pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
linyiqun commented on a change in pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#discussion_r557834504
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -145,16 +164,14 @@ public static String formatQuota(OzoneQuota quota) {
}
/**
- * Parses a user provided string and returns the
+ * Parses a user provided string space quota and returns the
* Quota Object.
*
* @param quotaInBytes Volume quota in bytes
Review comment:
volume quota should be ozone quota since this quota can also the bucket quota
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +207,49 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for space quota: "
+ + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
Review comment:
Same comment as above.
##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/OzoneQuota.java
##########
@@ -190,14 +207,49 @@ public static OzoneQuota parseQuota(String quotaInBytes,
" value cannot be greater than Long.MAX_VALUE BYTES");
}
- if (nSize < 0) {
- throw new IllegalArgumentException("Quota cannot be negative.");
+ if (nSize <= 0) {
+ throw new IllegalArgumentException("Invalid values for space quota: "
+ + nSize);
}
- return new OzoneQuota(quotaInNamespace,
- new RawQuotaInBytes(currUnit, nSize));
+ return new OzoneQuota(new RawQuotaInBytes(currUnit, nSize));
}
+ /**
+ * Parses a user provided string Namespace quota and returns the
+ * Quota Object.
+ *
+ * @param quotaInNamespace Volume quota in counts
+ *
+ * @return OzoneQuota object
+ */
+ public static OzoneQuota parseNameSpaceQuota(String quotaInNamespace) {
+ if (Strings.isNullOrEmpty(quotaInNamespace)) {
+ throw new IllegalArgumentException(
+ "Quota string cannot be null or empty.");
+ }
+ long nameSpaceQuota = Long.parseLong(quotaInNamespace);
+ if (nameSpaceQuota <= 0) {
+ throw new IllegalArgumentException(
+ "Invalid values for namespace quota: " + nameSpaceQuota);
+ }
+ return new OzoneQuota(nameSpaceQuota, new RawQuotaInBytes(Units.BYTES, -1));
+ }
+
+ /**
+ * Parses a user provided string and returns the
+ * Quota Object.
+ *
+ * @param quotaInBytes Volume quota in bytes
+ * @param quotaInNamespace Volume quota in counts
Review comment:
Same comment as above.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] ChenSammi commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
ChenSammi commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-761948474
+ 1.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] captainzmc commented on pull request #1746: HDDS-4631. Fix client set quota with 0.
Posted by GitBox <gi...@apache.org>.
captainzmc commented on pull request #1746:
URL: https://github.com/apache/ozone/pull/1746#issuecomment-752830548
> @captainzmc , If setting quota to 0 is not allowed now, can we rollback unrelated change in this PR?
@linyiqun Thanks for the tip.
I think currently all changes to this PR are required。
First we need to be able to distinguish whether the user sets quota to 0 (users may not specify Quoat when creating volumes and buckets, long is undefined as 0 by default and should be successful), and then judge the validity based on this.
Therefore, we need to change quotaInNamespace from long to String. In addition, it is also possible for users to specify either quotaInBytes or quotaInNamespace separately. In addition, many cases of original UT are not covered, so I made a supplement separately.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org