Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public int toProtoValue() {
return version;
}

public int getVersion() {
return version;
}

public static ClientVersion fromProtoValue(int value) {
return BY_PROTO_VALUE.getOrDefault(value, FUTURE_VERSION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public static OMRequest handleCreateBucketWithBucketLayoutDuringPreFinalize(
* they do not understand.
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How is this different than what is happening on lines 469-470?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With Ozone 1.4.0, client supports bucket layout. The feature validator is wrongly rejecting the request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rejection does not happen in the annotation. The annotation determines when the method should be called. In this case this method is called when we get an older client request. That's why the method to check the condition is called shouldApply. The body of the method determines whether to reject or modify the request. The body of the method has a more specific check for specific client version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have multiple such validations, this method takes care but other methods don't.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The annotation determines when the method should be called. In this case this method is called when we get an older client request. That's why the method to check the condition is called shouldApply. The body of the method determines whether to reject or modify the request.

It's very confusing for both the annotation and the method to have conditions. If the method checks the client request anyway, it can be called regardless of client version.

@errose28 errose28 Jul 10, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. I also suggested a refactor, but in a follow up. The refactor done here is not good because it requires updates to two enums for each client layout version.

Ideally all the compat requirements would be specified in the annotation

processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CreateBucket
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private boolean bucketContainsSnapshotInCache(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.DeleteBucket
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public static OMRequest disallowCreateDirectoryWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CreateDirectory
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public static OMRequest disallowCreateFileWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CreateFile
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static OMRequest disallowAllocateBlockWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.AllocateBlock
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public static OMRequest disallowCommitKeyWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CommitKey
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public static OMRequest disallowCreateKeyWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CreateKey
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.DeleteKey
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private Map<String, String> buildAuditMap(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.RenameKey
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ protected static void addDeletedKeys(Map<String, String> auditMap,
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.DeleteKeys
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private Map<String, String> buildAuditMap(Map<String, String> auditMap,
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.RenameKeys
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.AddAcl
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.RemoveAcl
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.SetAcl
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected void logResult(OzoneManager ozoneManager,
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.InitiateMultiPartUpload
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static OMRequest disallowAbortMultiPartUploadWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.AbortMultiPartUpload
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public static OMRequest disallowCommitMultiPartUploadWithECReplicationConfig(
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CommitMultiPartUpload
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ private void updateCache(OMMetadataManager omMetadataManager,
* @throws OMException if the request is invalid
*/
@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.PRE_PROCESS,
requestType = Type.CompleteMultiPartUpload
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ public boolean shouldApply(OMRequest req, ValidationContext ctx) {

/**
* Classifies validations that has to run, when the client uses an older
* protocol version than the server.
* protocol version than the bucket layout version i.e the version where
* bucket types where introduced.
*/
OLDER_CLIENT_REQUESTS {
OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@errose28 This fixes the issue.

@Override
public boolean shouldApply(OMRequest req, ValidationContext ctx) {
return req.getVersion() < ClientVersion.CURRENT_VERSION;
return req.getVersion() < ClientVersion.BUCKET_LAYOUT_SUPPORT.getVersion();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ private GetKeyInfoResponse getKeyInfo(GetKeyInfoRequest request,
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.LookupKey
)
Expand All @@ -656,7 +656,7 @@ public static OMResponse disallowLookupKeyResponseWithECReplicationConfig(
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.LookupKey
)
Expand Down Expand Up @@ -743,7 +743,7 @@ private ListKeysLightResponse listKeysLight(ListKeysRequest request)
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.ListKeys
)
Expand All @@ -770,7 +770,7 @@ public static OMResponse disallowListKeysResponseWithECReplicationConfig(
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.ListKeys
)
Expand Down Expand Up @@ -831,7 +831,7 @@ private ListTrashResponse listTrash(ListTrashRequest request,
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.ListTrash
)
Expand Down Expand Up @@ -861,7 +861,7 @@ public static OMResponse disallowListTrashWithECReplicationConfig(
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.ListTrash
)
Expand Down Expand Up @@ -1048,7 +1048,7 @@ private RefetchSecretKeyResponse refetchSecretKey() {
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.GetFileStatus
)
Expand Down Expand Up @@ -1078,7 +1078,7 @@ public static OMResponse disallowGetFileStatusWithECReplicationConfig(


@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.GetFileStatus
)
Expand Down Expand Up @@ -1127,7 +1127,7 @@ private LookupFileResponse lookupFile(LookupFileRequest request,
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.LookupFile
)
Expand Down Expand Up @@ -1155,7 +1155,7 @@ public static OMResponse disallowLookupFileWithECReplicationConfig(
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.LookupFile
)
Expand Down Expand Up @@ -1237,7 +1237,7 @@ private ListStatusLightResponse listStatusLight(
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.ListStatus
)
Expand Down Expand Up @@ -1265,7 +1265,7 @@ public static OMResponse disallowListStatusResponseWithECReplicationConfig(
}

@RequestFeatureValidator(
conditions = ValidationCondition.OLDER_CLIENT_REQUESTS,
conditions = ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS,
processingPhase = RequestProcessingPhase.POST_PROCESS,
requestType = Type.ListStatus
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private Compilation compile(List<String> source) {

private ValidationCondition[] someConditions() {
return
new ValidationCondition[] {ValidationCondition.OLDER_CLIENT_REQUESTS};
new ValidationCondition[] {ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS };
}

private ValidationCondition[] emptyConditions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import static org.apache.hadoop.ozone.om.request.validation.RequestProcessingPhase.POST_PROCESS;
import static org.apache.hadoop.ozone.om.request.validation.RequestProcessingPhase.PRE_PROCESS;
import static org.apache.hadoop.ozone.om.request.validation.ValidationCondition.CLUSTER_NEEDS_FINALIZATION;
import static org.apache.hadoop.ozone.om.request.validation.ValidationCondition.OLDER_CLIENT_REQUESTS;
import static org.apache.hadoop.ozone.om.request.validation.ValidationCondition.OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS;
import static org.apache.hadoop.ozone.om.request.validation.testvalidatorset1.GeneralValidatorsForTesting.startValidatorTest;
import static org.apache.hadoop.ozone.om.request.validation.testvalidatorset1.GeneralValidatorsForTesting.finishValidatorTest;
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type.CreateDirectory;
Expand Down Expand Up @@ -107,7 +107,7 @@ public void testRegistryHasTheOldClientPreProcessCreateKeyValidator() {
ValidatorRegistry registry = new ValidatorRegistry(PACKAGE);
List<Method> validators =
registry.validationsFor(
asList(OLDER_CLIENT_REQUESTS), CreateKey, PRE_PROCESS);
asList(OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS), CreateKey, PRE_PROCESS);

assertEquals(2, validators.size());
List<String> methodNames =
Expand All @@ -121,7 +121,7 @@ public void testRegistryHasTheOldClientPostProcessCreateKeyValidator() {
ValidatorRegistry registry = new ValidatorRegistry(PACKAGE);
List<Method> validators =
registry.validationsFor(
asList(OLDER_CLIENT_REQUESTS), CreateKey, POST_PROCESS);
asList(OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS), CreateKey, POST_PROCESS);

assertEquals(2, validators.size());
List<String> methodNames =
Expand All @@ -138,7 +138,7 @@ public void testRegistryHasTheMultiPurposePreProcessCreateVolumeValidator() {
asList(CLUSTER_NEEDS_FINALIZATION), CreateVolume, PRE_PROCESS);
List<Method> newClientValidators =
registry.validationsFor(
asList(OLDER_CLIENT_REQUESTS), CreateVolume, PRE_PROCESS);
asList(OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS), CreateVolume, PRE_PROCESS);

assertEquals(1, preFinalizeValidators.size());
assertEquals(1, newClientValidators.size());
Expand All @@ -155,7 +155,7 @@ public void testRegistryHasTheMultiPurposePostProcessCreateVolumeValidator() {
asList(CLUSTER_NEEDS_FINALIZATION), CreateVolume, POST_PROCESS);
List<Method> oldClientValidators =
registry.validationsFor(
asList(OLDER_CLIENT_REQUESTS), CreateVolume, POST_PROCESS);
asList(OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS), CreateVolume, POST_PROCESS);

assertEquals(1, preFinalizeValidators.size());
assertEquals(1, oldClientValidators.size());
Expand All @@ -169,7 +169,8 @@ public void testValidatorsAreReturnedForMultiCondition() {
ValidatorRegistry registry = new ValidatorRegistry(PACKAGE);
List<Method> validators =
registry.validationsFor(
asList(CLUSTER_NEEDS_FINALIZATION, OLDER_CLIENT_REQUESTS),
asList(CLUSTER_NEEDS_FINALIZATION,
OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS),
CreateKey, POST_PROCESS);

assertEquals(3, validators.size());
Expand All @@ -185,7 +186,7 @@ public void testNoValidatorForRequestsAtAllReturnsEmptyList() {
ValidatorRegistry registry = new ValidatorRegistry(PACKAGE_WO_VALIDATORS);

assertTrue(registry.validationsFor(
asList(OLDER_CLIENT_REQUESTS), CreateKey, PRE_PROCESS).isEmpty());
asList(OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS), CreateKey, PRE_PROCESS).isEmpty());
}

@Test
Expand All @@ -207,7 +208,7 @@ public void testNoDefinedValidationForRequestReturnsEmptyList() {
ValidatorRegistry registry = new ValidatorRegistry(PACKAGE);

assertTrue(registry.validationsFor(
asList(OLDER_CLIENT_REQUESTS), CreateDirectory, null).isEmpty());
asList(OLDER_BUCKET_LAYOUT_CLIENT_REQUESTS), CreateDirectory, null).isEmpty());
}

}
Loading