Github user NicoK commented on a diff in the pull request: https://github.com/apache/flink/pull/4939#discussion_r149077620 --- Diff: flink-yarn/src/main/java/org/apache/flink/yarn/Utils.java --- @@ -117,27 +118,50 @@ public static void setupYarnClassPath(Configuration conf, Map<String, String> ap } /** + * Copy a local file to a remote file system. + * + * @param fs + * remote filesystem + * @param appId + * application ID + * @param localRsrcPath + * path to the local file + * @param homedir + * remote home directory base (will be extended) + * @param relativeTargetPath + * relative target path of the file (will be prefixed be the full home directory we set up) + * * @return Path to remote file (usually hdfs) - * @throws IOException */ - public static Path setupLocalResource( - FileSystem fs, - String appId, Path localRsrcPath, - LocalResource appMasterJar, - Path homedir) throws IOException { + static Tuple2<Path, LocalResource> setupLocalResource( + FileSystem fs, + String appId, + Path localRsrcPath, + Path homedir, + String relativeTargetPath) throws IOException { + + if (new File(localRsrcPath.toUri().getPath()).isDirectory()) { + throw new IllegalArgumentException("File to copy must not be a directory: " + + localRsrcPath); + } // copy resource to HDFS - String suffix = ".flink/" + appId + "/" + localRsrcPath.getName(); + String suffix = ".flink/" + appId + "/" + relativeTargetPath + "/" + localRsrcPath.getName(); --- End diff -- Yes, but apparently this is filtered out by `new Path(homedir, suffix);` and the right path is created. I did stumble upon this as well and double-checked the results. The alternative is, for example, using `null` if no relative path is desired and setting the `suffix` appropriately which is a bit more ugly but may also be cleaner/safer... Would you rather go this way?
---