-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-6182 Basic framework for Client and OM versioning #3031
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone; | ||
|
|
||
| import org.apache.hadoop.util.ComparableVersion; | ||
|
|
||
| /** | ||
| * Versioning for OM's APIs used by ozone clients. | ||
| */ | ||
| public final class OMProtocolVersion { | ||
|
|
||
| // OM Authenticates the user using the S3 Auth info embedded in request proto. | ||
| public static final String OM_SUPPORTS_S3AUTH_VIA_PROTO = "2.0.0"; | ||
| public static final String OM_SUPPORTS_EC = "2.1.0"; | ||
| public static final String OM_SUPPORTS_FSO = "2.1.0"; | ||
|
Comment on lines
+29
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the benefit of having a 3-digit version number? When would we increment each of the digits?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is follows semantic versioning... https://semver.org/
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have semantic versioning at the project level. I don't think we can introduce breaking changes without incrementing the project-level major version number. |
||
|
|
||
| // Points to the latest version in code, always update this when adding | ||
| // a new version. | ||
| public static final String OM_LATEST_VERSION = OM_SUPPORTS_S3AUTH_VIA_PROTO; | ||
|
|
||
| /** | ||
| * Checks if the OM is running a version at or greater than the desired | ||
| * version. A Client might leverage a version that breaks compatibility | ||
| * with older OMs and this method can be used to check the compatability. | ||
| * If the desired version is not specified, it assumes there is no minimum | ||
| * version requirement. | ||
| * @param desiredOMVersion Minimum version that is required for OM. | ||
| * @param actualOMVersion Actual version received. | ||
| * @return true if actual OM version is at or newer than the desired version. | ||
| */ | ||
| public static boolean isOMNewerThan( | ||
| String desiredOMVersion, | ||
| String actualOMVersion) { | ||
| if (desiredOMVersion == null || desiredOMVersion.isEmpty()) { | ||
| // Empty strings assumes client is fine with any OM version. | ||
| return true; | ||
| } | ||
| ComparableVersion comparableExpectedVersion = | ||
| new ComparableVersion(desiredOMVersion); | ||
| ComparableVersion comparableOMVersion = | ||
| new ComparableVersion(actualOMVersion); | ||
| return comparableOMVersion.compareTo(comparableExpectedVersion) >= 0; | ||
| } | ||
|
|
||
| private OMProtocolVersion() { | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
|
|
||
| import static org.apache.hadoop.ozone.OMProtocolVersion.OM_LATEST_VERSION; | ||
|
|
||
| class OMProtocolVersionTest { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ozone build expects tests to be named
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the reminder. |
||
| private enum ValidateOmVersionTestCases { | ||
| NULL_EXPECTED_NULL_OM( | ||
| null, // Expected version | ||
| null, // OM Version | ||
| true), // Should validation pass | ||
| EMPTY_EXPECTED_NULL_OM( | ||
| "", | ||
| null, | ||
| true), | ||
| EMPTY_EXPECTED_EMPTY_OM( | ||
| "", | ||
| "", | ||
| true), | ||
| NULL_EXPECTED_EMPTY_OM( | ||
| null, | ||
| "", | ||
| true), | ||
| OM_EXPECTED_LATEST_OM( | ||
| "1.0.0", | ||
| OM_LATEST_VERSION, | ||
| true), | ||
| OM_EXPECTED_NEWER_OM( | ||
| "1.1.0", | ||
| "1.11.0", | ||
| true), | ||
| NEWER_EXPECTED_OLD_OM( | ||
| "1.20.0", | ||
| "1.19.0", | ||
| false), | ||
| NULL_EXPECTED_OM( | ||
| null, | ||
| OM_LATEST_VERSION, | ||
| true); | ||
| private static final List<ValidateOmVersionTestCases> | ||
| TEST_CASES = new LinkedList<>(); | ||
|
|
||
| static { | ||
| for (ValidateOmVersionTestCases t : values()) { | ||
| TEST_CASES.add(t); | ||
| } | ||
| } | ||
| private final String expectedVersion; | ||
| private final String omVersion; | ||
| private final boolean validation; | ||
| ValidateOmVersionTestCases(String expectedVersion, | ||
| String omVersion, | ||
| boolean validation) { | ||
| this.expectedVersion = expectedVersion; | ||
| this.omVersion = omVersion; | ||
| this.validation = validation; | ||
| } | ||
|
|
||
| } | ||
| @Test | ||
| void isOMCompatible() { | ||
| } | ||
|
Comment on lines
+83
to
+84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be incomplete. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.protocolPB; | ||
|
|
||
| import org.apache.hadoop.ozone.ClientVersions; | ||
| import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * OMManagerClientVersionsValidations is a collection of all the validations | ||
| * that need to be run to maintain compatibility with varying versions of | ||
| * client. | ||
| */ | ||
| public final class OMManagerClientVersionValidations { | ||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(OMManagerClientVersionValidations.class); | ||
| private OMManagerClientVersionValidations() { | ||
|
|
||
| } | ||
|
|
||
| public static void validateClientVersionPostProcess( | ||
| OzoneManagerProtocolProtos.Type lookupKey, | ||
| OzoneManagerProtocolProtos.OMRequest request, | ||
| OzoneManagerProtocolProtos.InfoBucketResponse infoBucketResponse) { | ||
| // ToDo: Add EC specific rejection of request based on key info. | ||
| if (request.hasVersion() | ||
| && | ||
| ClientVersions.isClientCompatible( | ||
| ClientVersions.CLIENT_EC_CAPABLE, | ||
| request.getVersion())){ | ||
| return; | ||
| } | ||
| // TODO: Update the response and log message | ||
| LOG.debug("Request rejected as client version is not EC Compatible: {}", | ||
| request); | ||
| } | ||
| public static void validateClientVersionPostProcess( | ||
| OzoneManagerProtocolProtos.Type lookupKey, | ||
| OzoneManagerProtocolProtos.OMRequest request, | ||
| OzoneManagerProtocolProtos.LookupKeyResponse lookupKeyResponse) { | ||
| // ToDo: Add FSO specific rejection of request based on bucket info. | ||
kerneltime marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (request.hasVersion() | ||
| && | ||
| ClientVersions.isClientCompatible( | ||
| ClientVersions.CLIENT_FSO_CAPABLE, | ||
| request.getVersion())){ | ||
| return; | ||
| } | ||
| // TODO: Update the response and log message | ||
| LOG.debug("Request rejected as client version is not FSO Compatible: {}", | ||
| request); | ||
| } | ||
|
|
||
| } | ||
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 think "client version is equal to or newer" is opposite of
desiredClientVersion >= actualClientVersion.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.
Clients should be able to talk to older servers, a client can choose to mandate a minimum version for the server but a server can mandate the minimum version of client for a given capability.
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 think I understand that. But the method does exactly the opposite, it mandates a maximum version.
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.
To confirm this problem, try:
CURRENT_VERSIONto 4 (i.e. simulate the situation where we add a new feature and increment current version)OMManagerClientVersionValidationsto DEBUGNotice that client is
version: 4, but is "rejected".