GJL commented on a change in pull request #11250: [FLINK-16302][rest]add log
list and read log by name for taskmanager
URL: https://github.com/apache/flink/pull/11250#discussion_r391803582
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
##########
@@ -915,29 +936,21 @@ public void heartbeatFromResourceManager(ResourceID
resourceID) {
default:
filePath = null;
}
+ return requestFileUploadByFilePath(filePath, timeout,
fileType.toString());
+ }
- if (filePath != null && !filePath.isEmpty()) {
- final File file = new File(filePath);
-
- if (file.exists()) {
- final TransientBlobCache transientBlobService =
blobCacheService.getTransientBlobService();
- final TransientBlobKey transientBlobKey;
- try (FileInputStream fileInputStream = new
FileInputStream(file)) {
- transientBlobKey =
transientBlobService.putTransient(fileInputStream);
- } catch (IOException e) {
- log.debug("Could not upload file {}.",
fileType, e);
- return
FutureUtils.completedExceptionally(new FlinkException("Could not upload file "
+ fileType + '.', e));
- }
+ @Override
+ public CompletableFuture<TransientBlobKey>
requestFileUploadByName(String fileName, Time timeout) {
+ log.debug("Request file name is {} upload.", fileName);
- return
CompletableFuture.completedFuture(transientBlobKey);
- } else {
- log.debug("The file {} does not exist on the
TaskExecutor {}.", fileType, getResourceID());
- return FutureUtils.completedExceptionally(new
FlinkException("The file " + fileType + " does not exist on the
TaskExecutor."));
- }
+ final String filePath;
+ final String logDir =
taskManagerConfiguration.getTaskManagerLogDir();
+ if (logDir != null && !logDir.isEmpty() && fileName != null &&
!fileName.isEmpty()) {
+ filePath = logDir + "/" + fileName;
Review comment:
This won't work on windows. It's better to use `new File(logDir,
fileName).getPath()`
_Edit:_
This method could be vulnerable against a path traversal attack:
https://wiki.owasp.org/index.php/Path_Traversal
So maybe:
`new File(logDir, new File(fileName).getName()).getPath()`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services