-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-4272. Volume namespace: add usedNamespace and update it when create and delete bucket #1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
R: @cxorm @ChenSammi @captainzmc Can you take a look please? |
cxorm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @amaliujia for working on this PR.
Some comments are added inline.
I have a question,
the usedNamespace seems not work for now (with ozone sh vol info),
and I go through the HDDS-541 and I don't found the tickets for making it work.
Feel free to correct me if I miss something, and if not, let's create a new Jira for it.
| private OmVolumeArgs(String adminName, String ownerName, String volume, | ||
| long quotaInBytes, long quotaInCounts, Map<String, String> metadata, | ||
| long usedBytes, OmOzoneAclMap aclMap, long creationTime, | ||
| long modificationTime, long objectID, long updateID) { | ||
| long usedBytes, long usedNamespace, OmOzoneAclMap aclMap, | ||
| long creationTime, long modificationTime, long objectID, long updateID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we update the comment of this constructor by add @param usedNamespace - volume quota usage in counts
The description of the parameter is IMHO, feel free to correct it if you have an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. @param usedNamespace and updated both description of @param usedNamespace and @param usedBytes
...e-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketCreateRequest.java
Outdated
Show resolved
Hide resolved
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConsts.java
Show resolved
Hide resolved
...manager/src/main/java/org/apache/hadoop/ozone/om/response/bucket/OMBucketCreateResponse.java
Show resolved
Hide resolved
| // Add default acls from volume. | ||
| addDefaultAcls(omBucketInfo, omVolumeArgs); | ||
|
|
||
| // quotaAdd used namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we update it this to add quota of used namespace or the same as update used namespace for volume in OMBucketDeleteRequest ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used update used namespace for volume for both now.
...e-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java
Outdated
Show resolved
Hide resolved
captainzmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Overall, some code style problems as suggested by Yisheng.
...manager/src/main/java/org/apache/hadoop/ozone/om/response/bucket/OMBucketDeleteResponse.java
Show resolved
Hide resolved
|
Thanks @cxorm and @captainzmc comments are addressed. Also created https://issues.apache.org/jira/browse/HDDS-4273 to track the work that make |
captainzmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1
|
@cxorm can you take another look please? Thanks! |
|
@amaliujia , could you add a new UT for bucket link case? Linked bucket should not be counted in the namespace quota. |
|
Thanks for the point that linked bucket case. Is there an example to show now linked bucket is tested (e.g. as a unit test)? I am trying to find a way to create a linked bucket and verify whether quota is impacted. |
|
It seems there is no example UT so far. You can refer to links.robot for CLI examples, and HDDS-3612. |
|
@ChenSammi thanks for your pointer. I find the way to create linked bucket from there: just construct a bucket args by setting source volume name and bucket name (see here: https://github.com/apache/hadoop-ozone/pull/1104/files#diff-bcaba1a52a6776044c68527cd7a442d394ad80c69db269c9873343d09a4b2290R60) Have added to the UT about linked bucket. |
|
Thank you @amaliujia for the fixes addressed comments. |
|
Hi @amaliujia. Now #1489 has been merged, I think we can continue this PR. The original implementation needs to be changed. we no longer need LongAdder to update volume usedNamespace(reason ). Since volume lock has been used by OMBucketCreateRequest and OMBucketDeleteRequest, we only need to obtain its copyObject after updating omVolumeArgs and then put it into Response. The specific amendment can refer to here. |
Agreed with @captainzmc 's proposal. Current implementation has the same problem of #1489 . |
|
@captainzmc @linyiqun thank you! I will follow up what has been done and see how to update this PR! |
…ate and delete bucket
|
PR is updated. Can you take a look please? |
captainzmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for @amaliujia's update. LGTM overall. Just few minor style comments.
| // update used namespace for volume | ||
| String volumeKey = omMetadataManager.getVolumeKey(volumeName); | ||
| OmVolumeArgs omVolumeArgs = | ||
| omMetadataManager.getVolumeTable().getReadCopy(volumeKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
| .setStorageType(StorageType.DEFAULT) | ||
| .setVersioning(false) | ||
| .setSourceVolume(volumeName) | ||
| .setSourceBucket(bucketName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
linyiqun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @amaliujia , there are few comments from me. Please have a look.
| public static final String USED_BYTES = "usedBytes"; | ||
| public static final String USED_NAMESPACE = "usedNamespace"; | ||
| public static final String QUOTA_IN_BYTES = "quotaInBytes"; | ||
| public static final String QUOTA_IN_COUNTS = "quotaInCounts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see we defined usedBytes corresponding to quotaInBytes, so quotaInCounts expected to be quotaInNamespace. This is just my first feeling for this variable name. We could revisit these later in a separate JIRA to make this more understandable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. quotaInCounts seems not very readable to me as well :) I didn't change it in this PR as it is not relevant.
Created https://issues.apache.org/jira/browse/HDDS-4582 to revisit it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to use quotaInNamespace in my new code. HDDS-4582 will be replacing existing quotaInCounts to quotaInNamesapce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
| volumeWithLinkedBucket.createBucket(targetBucketName, argsBuilder.build()); | ||
| // Used namespace should be 0 because linked bucket does not consume | ||
| // namespace quota | ||
| Assert.assertEquals(0L, volumeWithLinkedBucket.getUsedNamespace()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully get this point, why this bucket create way will not increased the namespace quota? Just curious for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amaliujia , could you add a new UT for bucket link case? Linked bucket should not be counted in the namespace quota.
This comes from one of the comment above. I consider this is more like a decision that linked bucket should not consume quota. At least linked bucket should not consume space quota. I think to make consistent, do not apply namespace quota also makes sense.
| // update used namespace for volume | ||
| String volumeKey = omMetadataManager.getVolumeKey(volumeName); | ||
| OmVolumeArgs omVolumeArgs = | ||
| omMetadataManager.getVolumeTable().getReadCopy(volumeKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an empty check for omVolumeArgs before updating the namespace used?
if (volumeArgs == null) {
throw new OMException("Volume " + volume + " is not found",
OMException.ResultCodes.VOLUME_NOT_FOUND);
}| // Update table cache. | ||
| metadataManager.getBucketTable().addCacheEntry(new CacheKey<>(bucketKey), | ||
| new CacheValue<>(Optional.of(omBucketInfo), transactionLogIndex)); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also update the volume table cache like above, as omVolumeArgs be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O I see. it make senses.
| OmVolumeArgs omVolumeArgs = | ||
| omMetadataManager.getVolumeTable().getReadCopy(volumeKey); | ||
| omVolumeArgs.incrUsedNamespace(-1L); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Volume table cache also need to be updated here as we update table cache in OMBucketCreateRequest.java
|
|
||
| // update used namespace for volume | ||
| omVolumeArgs.incrUsedNamespace(1L); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this update, we need to do the namespace quota check in checkQuotaBytesValid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also updated the test to test quota exceed case.
linyiqun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments, @amaliujia .
Almost looks good now, few minor comments below.
| private void checkQuotaInNamespace(OmVolumeArgs omVolumeArgs, | ||
| long allocatedNamespace) throws IOException { | ||
| if (omVolumeArgs.getQuotaInCounts() > OzoneConsts.QUOTA_RESET) { | ||
| long usedNamespace = omVolumeArgs.getUsedNamespace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use omVolumeArgs.getQuotaInCounts() != OzoneConsts.QUOTA_RESET to replace above condition check? That will be the better check in case maybe OzoneConsts.QUOTA_RESET value can be changed to the positive number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make senses! Done!
| omVolumeArgs.incrUsedNamespace(-1L); | ||
| // Update table cache. | ||
| omMetadataManager.getVolumeTable().addCacheEntry( | ||
| new CacheKey<>(omMetadataManager.getVolumeKey(volumeName)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could directly use volumeKey, don't need to invoke omMetadataManager.getVolumeKey again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O yes :)
|
Current PR looks good to me now. |
|
@linyiqun |
captainzmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1
@linyiqun If there are no other problems, we can merge this PR and continue other tasks.
linyiqun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also +1 from me.
|
Thanks for @amaliujia‘s patch. Thanks @ChenSammi @linyiqun @cxorm for the review. PR merged. |
What changes were proposed in this pull request?
Volume namespace: add usedNamespace and update it when create and delete bucket
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-4272
How was this patch tested?
Unit Test