-
Notifications
You must be signed in to change notification settings - Fork 496
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
Conversation
…nst bucket types. Change-Id: I421522b5367d8e36c229c81aa5e4d5a53561f8b9
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; |
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.
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:
- simplify this change,
- help avoid checkstyle problems,
- make the logic easier to understand for future readers of the code,
- prepare for the future refactoring discussed in HDDS-11132. Update the OLDER_CLIENT_REQUEST validations to check against bucket types. #6919.
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; |
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.
yeah sure will make this change add it in a separate if block
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 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()))
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'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
@swamirishi should we close this in favor of #6932 to avoid confusion? |
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.