You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by el...@apache.org on 2020/06/15 14:15:32 UTC
[hadoop-ozone] branch master updated: HDDS-3787. Make CSI command
configurable. (#1067)
This is an automated email from the ASF dual-hosted git repository.
elek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 2505b5c HDDS-3787. Make CSI command configurable. (#1067)
2505b5c is described below
commit 2505b5c4d735a18c1e286c5d7281faf1f288c7bf
Author: maobaolong <30...@qq.com>
AuthorDate: Mon Jun 15 22:15:21 2020 +0800
HDDS-3787. Make CSI command configurable. (#1067)
---
.../java/org/apache/hadoop/ozone/csi/CsiServer.java | 16 +++++++++++++---
.../java/org/apache/hadoop/ozone/csi/NodeService.java | 17 +++++++++--------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java
index 88ab8d3..0ef69c1 100644
--- a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java
+++ b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java
@@ -129,6 +129,15 @@ public class CsiServer extends GenericCli implements Callable<Void> {
tags = ConfigTag.STORAGE)
private String volumeOwner;
+ @Config(key = "mount.command",
+ defaultValue = "goofys --endpoint %s %s %s",
+ description =
+ "This is the mount command which is used to publish volume."
+ + " these %s will be replicated by s3gAddress, volumeId "
+ + " and target path.",
+ tags = ConfigTag.STORAGE)
+ private String mountCommand;
+
public String getSocketPath() {
return socketPath;
}
@@ -137,12 +146,10 @@ public class CsiServer extends GenericCli implements Callable<Void> {
return volumeOwner;
}
-
public void setVolumeOwner(String volumeOwner) {
this.volumeOwner = volumeOwner;
}
-
public void setSocketPath(String socketPath) {
this.socketPath = socketPath;
}
@@ -151,7 +158,6 @@ public class CsiServer extends GenericCli implements Callable<Void> {
return defaultVolumeSize;
}
-
public void setDefaultVolumeSize(long defaultVolumeSize) {
this.defaultVolumeSize = defaultVolumeSize;
}
@@ -163,5 +169,9 @@ public class CsiServer extends GenericCli implements Callable<Void> {
public void setS3gAddress(String s3gAddress) {
this.s3gAddress = s3gAddress;
}
+
+ public String getMountCommand() {
+ return mountCommand;
+ }
}
}
diff --git a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java
index 8edda59..45784a4 100644
--- a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java
+++ b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java
@@ -47,11 +47,12 @@ public class NodeService extends NodeImplBase {
private static final Logger LOG = LoggerFactory.getLogger(NodeService.class);
+ private final String mountCommand;
private String s3Endpoint;
public NodeService(CsiConfig configuration) {
this.s3Endpoint = configuration.getS3gAddress();
-
+ this.mountCommand = configuration.getMountCommand();
}
@Override
@@ -60,14 +61,14 @@ public class NodeService extends NodeImplBase {
try {
Files.createDirectories(Paths.get(request.getTargetPath()));
- String mountCommand =
- String.format("goofys --endpoint %s %s %s",
+ String command =
+ String.format(mountCommand,
s3Endpoint,
request.getVolumeId(),
request.getTargetPath());
- LOG.info("Executing {}", mountCommand);
+ LOG.info("Executing {}", command);
- executeCommand(mountCommand);
+ executeCommand(command);
responseObserver.onNext(NodePublishVolumeResponse.newBuilder()
.build());
@@ -79,9 +80,9 @@ public class NodeService extends NodeImplBase {
}
- private void executeCommand(String mountCommand)
+ private void executeCommand(String command)
throws IOException, InterruptedException {
- Process exec = Runtime.getRuntime().exec(mountCommand);
+ Process exec = Runtime.getRuntime().exec(command);
exec.waitFor(10, TimeUnit.SECONDS);
LOG.info("Command is executed with stdout: {}, stderr: {}",
@@ -89,7 +90,7 @@ public class NodeService extends NodeImplBase {
IOUtils.toString(exec.getErrorStream(), "UTF-8"));
if (exec.exitValue() != 0) {
throw new RuntimeException(String
- .format("Return code of the command %s was %d", mountCommand,
+ .format("Return code of the command %s was %d", command,
exec.exitValue()));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org