generated from kestra-io/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set the vfs_cache in the task working directory to work with wor…
…ker isolation Worker isolation restricts file creating inside the task working directory. By default Common VFS will create a cache directory /tmp/vfs_cache which will not be allowed by Kestra's security manager. To fix that we need to init the FileRecplicator by ourselves and pass it a cache directory created inside the task working directory.
- Loading branch information
1 parent
54485a0
commit 95b1119
Showing
9 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/io/kestra/plugin/fs/vfs/KestraStandardFileSystemManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.kestra.plugin.fs.vfs; | ||
|
||
import io.kestra.core.runners.RunContext; | ||
import org.apache.commons.vfs2.impl.DefaultFileReplicator; | ||
import org.apache.commons.vfs2.impl.StandardFileSystemManager; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
|
||
class KestraStandardFileSystemManager extends StandardFileSystemManager { | ||
static final String CONFIG_RESOURCE = "providers.xml"; // same as StandardFileSystemManager.CONFIG_RESOURCE | ||
|
||
private final RunContext runContext; | ||
|
||
KestraStandardFileSystemManager(RunContext runContext) { | ||
super(); | ||
|
||
this.runContext = runContext; | ||
} | ||
|
||
@Override | ||
protected DefaultFileReplicator createDefaultFileReplicator() { | ||
// By default, the file replicator uses /tmp as the base temp directory; we create it manually to use the task working directory. | ||
File vfsCache = this.runContext.workingDir().resolve(Path.of("vfs_cache")).toFile(); | ||
if (!vfsCache.mkdirs()) { | ||
throw new RuntimeException("Unable to create directory " + vfsCache.getPath()); | ||
} | ||
|
||
return new DefaultFileReplicator(vfsCache); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters