Skip to content

Conversation

@amaliujia
Copy link
Contributor

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

@amaliujia
Copy link
Contributor Author

R: @cxorm @ChenSammi @captainzmc

Can you take a look please?

@cxorm cxorm self-requested a review September 24, 2020 06:51
Copy link
Member

@cxorm cxorm left a 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.

Comment on lines 70 to 73
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) {
Copy link
Member

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.

Copy link
Contributor Author

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

// Add default acls from volume.
addDefaultAcls(omBucketInfo, omVolumeArgs);

// quotaAdd used namespace
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Member

@captainzmc captainzmc left a 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.

@amaliujia
Copy link
Contributor Author

Thanks @cxorm and @captainzmc

comments are addressed.

Also created https://issues.apache.org/jira/browse/HDDS-4273 to track the work that make usedNamespace work with ozone sh vol info

Copy link
Member

@captainzmc captainzmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@amaliujia
Copy link
Contributor Author

@cxorm can you take another look please? Thanks!

@amaliujia amaliujia requested a review from cxorm October 7, 2020 19:00
@ChenSammi
Copy link
Contributor

@amaliujia , could you add a new UT for bucket link case? Linked bucket should not be counted in the namespace quota.

@amaliujia
Copy link
Contributor Author

@ChenSammi

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.

@ChenSammi
Copy link
Contributor

It seems there is no example UT so far. You can refer to links.robot for CLI examples, and HDDS-3612.

@amaliujia
Copy link
Contributor Author

amaliujia commented Oct 15, 2020

@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.

@cxorm
Copy link
Member

cxorm commented Oct 15, 2020

Thank you @amaliujia for the fixes addressed comments.
The work is great to me, but I think we would commit it after HDDS-4308.

@captainzmc captainzmc self-requested a review November 25, 2020 03:47
@captainzmc
Copy link
Member

captainzmc commented Nov 25, 2020

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.

@linyiqun
Copy link
Contributor

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 refe

Agreed with @captainzmc 's proposal. Current implementation has the same problem of #1489 .

@amaliujia
Copy link
Contributor Author

@captainzmc @linyiqun thank you! I will follow up what has been done and see how to update this PR!

@amaliujia
Copy link
Contributor Author

amaliujia commented Dec 11, 2020

@captainzmc @linyiqun

PR is updated. Can you take a look please?

Copy link
Member

@captainzmc captainzmc left a 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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Copy link
Contributor

@linyiqun linyiqun left a 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";
Copy link
Contributor

@linyiqun linyiqun Dec 11, 2020

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor

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());
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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));

Copy link
Contributor

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.

Copy link
Contributor Author

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);

Copy link
Contributor

@linyiqun linyiqun Dec 11, 2020

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);

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@linyiqun linyiqun left a 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();
Copy link
Contributor

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.

Copy link
Contributor Author

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)),
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O yes :)

@linyiqun
Copy link
Contributor

Current PR looks good to me now.
@amaliujia , would you mind looking into the failed building items below? It doesn't show green.

@amaliujia
Copy link
Contributor Author

amaliujia commented Dec 13, 2020

@linyiqun
CI is fixed. It was because that quotaInNamespace wasn't initialized correctly (meanwhile in this PR namespace quota enforcement is enabled).

Copy link
Member

@captainzmc captainzmc left a 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.

Copy link
Contributor

@linyiqun linyiqun left a 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.

@captainzmc captainzmc merged commit 1f5a965 into apache:master Dec 14, 2020
@captainzmc
Copy link
Member

Thanks for @amaliujia‘s patch. Thanks @ChenSammi @linyiqun @cxorm for the review. PR merged.

@amaliujia amaliujia deleted the HDDS-4272 branch December 14, 2020 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants