-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20172][Core] Add file permission check when listing files in FsHistoryProvider #17495
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 1 commit
10d254b
63142cc
1d1440b
9447011
4d3838a
ab5117b
b36fa75
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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ import scala.concurrent.duration._ | |
| import scala.language.postfixOps | ||
|
|
||
| import com.google.common.io.{ByteStreams, Files} | ||
| import org.apache.hadoop.fs.FileStatus | ||
| import org.apache.hadoop.hdfs.DistributedFileSystem | ||
| import org.json4s.jackson.JsonMethods._ | ||
| import org.mockito.Matchers.any | ||
|
|
@@ -571,6 +572,34 @@ class FsHistoryProviderSuite extends SparkFunSuite with BeforeAndAfter with Matc | |
| } | ||
| } | ||
|
|
||
| test("log without read permission should be filtered out before actual reading") { | ||
| class TestFsHistoryProvider extends FsHistoryProvider(createTestConf()) { | ||
|
||
| var mergeApplicationListingCall = 0 | ||
| override protected def mergeApplicationListing(fileStatus: FileStatus): Unit = { | ||
| super.mergeApplicationListing(fileStatus) | ||
| mergeApplicationListingCall += 1 | ||
| } | ||
| } | ||
|
|
||
| val provider = new TestFsHistoryProvider | ||
| val log = newLogFile("app1", Some("app1"), inProgress = true) | ||
| writeFile(log, true, None, | ||
| SparkListenerApplicationStart("app1", Some("app1"), System.currentTimeMillis(), | ||
| "test", Some("attempt1")), | ||
| SparkListenerApplicationEnd(System.currentTimeMillis())) | ||
|
|
||
| // Set the read permission to false to simulate access permission not allowed scenario. | ||
| log.setReadable(false) | ||
|
|
||
| updateAndCheck(provider) { list => | ||
| list.size should be (0) | ||
| } | ||
|
|
||
| // Because we already filter out logs without read permission, so it will get a empty file list | ||
| // and not invoke mergeApplicationListing() call. | ||
| provider.mergeApplicationListingCall should be (0) | ||
| } | ||
|
|
||
| /** | ||
| * Asks the provider to check for logs and calls a function to perform checks on the updated | ||
| * app list. Example: | ||
|
|
||
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.
This API is tagged with
@LimitedPrivate({"HDFS", "Hive"}), but I think it should be fine to call it here.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.
So, this API actually calls
fs.getFileStatus()which is a remote call and completely unnecessary in this context, since you already have theFileStatus.You could instead directly do the check against the
FsPermissionobject (same way thefs.access()does after it performs the remote call).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 see, let me change it. Thanks.