-
Notifications
You must be signed in to change notification settings - Fork 594
HDDS-8437. [FSO] S3A compatibility - dfs -mkdir creates a zero byte file instead of a directory #5124
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
Conversation
errose28
left a comment
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.
Thanks for working on the S3a compatibility @mladjan-gadzic.
My understanding of IOUtils#toString is that it is going to do a full buffer copy and load the result into memory. I don't think we can do this for all data coming into s3g put. Can we just say if ozone.s3g.fso.directory.creation is enabled and a file is written with a trailing slash to an FSO bucket, we will treat it as a directory? Another more complicated option may be to seek past the auth header information in the stream to see if any content remains after that, but I'm not very familiar with the chunked layout authorization header format to know if this is feasible.
|
Also please check the failing unit test which looks related. |
|
There is no notion of the directory in S3; can we elaborate on the exact ask here? There is a reverse request to skip directory objects on listing for FSO buckets in S3. If we create directories for zero-byte objects in S3G over FSO, what should the behavior be for listing directories? |
Thanks @errose28 for taking the time to review this PR! I will try suggestions and let you know how it went. |
It is due to |
Directories are already being created by default for zero-byte files over FSO bucket layout. Please check this PR for more context. Current PR is only extension on previous to be compatible with S3a (specifically I am not familiar with request to skip directory objects on listing. Could you please provide more context how current PR breaks it? |
|
Hi @mladjan-gadzic. @kerneltime and I had some offline discussion about these changes and this is what we found:
|
|
Hi @mladjan-gadzic have you had a chance to see if using the |
Hi @errose28. Yes, using mentioned header resolves the issue. Thanks for the suggestion. I also did round of manual tests to confirm it works. |
errose28
left a comment
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.
Thanks for the update @mladjan-gadzic. Just left some minor comments but the approach looks good overall.
| bucket.getBucketLayout() == BucketLayout.FILE_SYSTEM_OPTIMIZED; | ||
|
|
||
| String amzDecodedLength = | ||
| headers.getHeaderString("x-amz-decoded-content-length"); |
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.
Let's define "x-amz-decoded-content-length" in S3Consts where we have other x-amz header strings defined.
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.
Done.
| private static boolean hasTrailingSlash(String keyPath) { | ||
| return keyPath.charAt(keyPath.length() - 1) == '/'; | ||
| } |
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.
Looks like this method is not used anymore, I think we can remove it.
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.
Done.
| private void createDirectory(String volumeName, | ||
| String bucketName, String keyPath) throws IOException { | ||
| getClientProtocol() | ||
| .createDirectory(volumeName, bucketName, keyPath); | ||
| } |
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.
In the current change set this helper method is only called once. I think it can be removed.
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.
Done.
Thanks @errose28 for the quick review! |
errose28
left a comment
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.
Thanks for the updates and testing @mladjan-gadzic. LGTM.
|
I just approved the CI on this PR. Once it is green I can merge it. |
I run tests that failed and it succeeded both locally and on remote. If you can, please re-run. |
|
Test failure looks like it is being fixed in #5217, which should be merged soon. I will wait for that to go in before merging this. |
|
Looks like #5217 is still being worked on. Since this is a known issue that is failing multiple times, I will go ahead and merge this. |
|
@errose28 thank you for reviewing this! |
… zero byte file instead of a directory (apache#5124) (cherry picked from commit 1f57ff6) Change-Id: Idbb33446be3b5faee0b129f54b86fa01bdc88af8
What changes were proposed in this pull request?
Content length is not reliable measure to determine wheter dir should be created. In this case Hadoop does not provide any content, but because body is still chunk signed, length is not 0 but 86. Because of this, zero byte file is created instead of dir.
Proposed solution is to have additional check wheter key path has trailing slash. If it has, dir will be created, otherwise file.
Info on the Marker Retention Property:
In order for Hadoop to be 100% compatible with FSO layout, it is necessary to set property:
The following shows how the marker.retention property is needed for FSO to be compatible with Hadoop's S3A fs. It is here for reference purposes but understanding it isn't necessary to review this PR.
To demonstrate this, let's use simple case such as:
a1b1undera1Dir
a1can be safely created. Listing of keys on Ozone side would show key asa1/with size of 0. Attempt to createb1asa1/b1/would succeed on Ozone's side. Listing of keys on it would show keys such asa1/anda1/b1/both with size of 0. Issue happens on Hadoop side because issued command would hang (never finish) with warning logs such as:The reason for this is that Hadoop tries to delete
a1/key and just leavea1/b1/which is alright for OBS, but FSO does not work like that. Because of this above-mentioned propery is necesarry in order for Hadoop to be compatible with FSO over S3a. After setting above property there are no warning logs, but instead something like this:Full logs from Hadoop side:
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-8437
How was this patch tested?
For info on steps how to reproduce the issue check linked Apache Jira.