Skip to content
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

HDDS-11132. Update the OLDER_CLIENT_REQUEST validations so that validations don't fail #6922

Closed
wants to merge 3 commits into from

Conversation

swamirishi
Copy link
Contributor

@swamirishi swamirishi commented Jul 10, 2024

What changes were proposed in this pull request?

With the introduction of a new client version in https://issues.apache.org/jira/browse/HDDS-10983, the latest version is 4.
The OLDER_CLIENT_REQUEST validation checked against the latest versions for access to newer non-legacy buckets but since the addition of a newer version all client versions prior to 4 becomes an older client. This blocks access to OBS/FSO buckets and EC key lookups for older clients version 2 & 3.
This is related to the original patch submitted by @sadanand48 #6919

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11132

How was this patch tested?

Unit tests need to be added.

…nst bucket types.

Change-Id: I421522b5367d8e36c229c81aa5e4d5a53561f8b9
Comment on lines 291 to 301
if (ClientVersion.fromProtoValue(req.getVersion())
.compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
DeleteBucketRequest request = req.getDeleteBucketRequest();

if (request.hasBucketName() && request.hasVolumeName()) {
BucketLayout bucketLayout = ctx.getBucketLayout(
request.getVolumeName(), request.getBucketName());
bucketLayout.validateSupportedOperation();
}
}
return req;
Copy link
Contributor

@adoroszlai adoroszlai Jul 10, 2024

Choose a reason for hiding this comment

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

The same "return early if client is new enough" check can be added in all methods (changing only the enum value being compared to, and the return type (request/response)):

    ClientVersion clientVersion = ClientVersion.fromProtoValue(req.getVersion());
    if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
      return req;
    }

That would:

Suggested change
if (ClientVersion.fromProtoValue(req.getVersion())
.compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
DeleteBucketRequest request = req.getDeleteBucketRequest();
if (request.hasBucketName() && request.hasVolumeName()) {
BucketLayout bucketLayout = ctx.getBucketLayout(
request.getVolumeName(), request.getBucketName());
bucketLayout.validateSupportedOperation();
}
}
return req;
ClientVersion clientVersion = ClientVersion.fromProtoValue(req.getVersion());
if (ClientVersion.BUCKET_LAYOUT_SUPPORT.compareTo(clientVersion) <= 0) {
return req;
}
DeleteBucketRequest request = req.getDeleteBucketRequest();
if (request.hasBucketName() && request.hasVolumeName()) {
BucketLayout bucketLayout = ctx.getBucketLayout(
request.getVolumeName(), request.getBucketName());
bucketLayout.validateSupportedOperation();
}
return req;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah sure will make this change add it in a separate if block

Copy link
Contributor

Choose a reason for hiding this comment

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

I would even go further a bit...
What if we define a method in the ClientVersion enum, call it let's say isNewerThan(ClientVersion), and use that instead of the compareTo?
With that this block can be reduced to an if (ClientVersion.fromProtoValue(req.getVersion()).isNewerThan(ClientVersion.BUCKET_LAYOUT_SUPPORT))

An other option may be (though it means introducing a new method for every version) to add a static method named like isNewerThanBucketLayout(int version), do the proto to enum conversion in the method than the compareTo, and return a boolen, so that the usage would look like:
if (ClientVersion.isNewerThanBucketLayout(req.getVersion()))

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest:

ClientVersion.BUCKET_LAYOUT_SUPPORT.isSupportedByClient(req.getVersion())

(which also highlights why "SUPPORT" shouldn't be part of the enum constant name...)

Change-Id: Ib3a1c2c86e2898deca55c81865b00fb4e61c98c1
Change-Id: Ib3f891f60006afed10779d45fee161e66a294379
@errose28
Copy link
Contributor

@swamirishi should we close this in favor of #6932 to avoid confusion?

@swamirishi swamirishi closed this Jul 12, 2024
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.

4 participants