You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by js...@apache.org on 2016/01/19 17:32:16 UTC

aurora git commit: Make required mesos log args required.

Repository: aurora
Updated Branches:
  refs/heads/master b56367902 -> c96d5b8ad


Make required mesos log args required.

Both -native_log_file_path and -native_log_zk_group_path are required
but they were not validated (-native_log_file_path) and validated too
late in a provider (-native_log_zk_group_path) to provide useful
failure messages.  Correct this and make the arguments required in
the arg parsing phase.

Testing Done:
```
./gradlew clean distZip
unzip -qd /tmp/ dist/distributions/aurora-scheduler-0.12.0-SNAPSHOT.zip
/tmp/aurora-scheduler-0.12.0-SNAPSHOT/bin/aurora-scheduler \
  -mesos_master_address=localhost:5050 \
  -backup_dir=/tmp \
  -serverset_path=/aurora \
  -cluster_name=test -zk_endpoints=localhost:2181
...
I0115 20:18:37.890 [main, ArgScanner:443] zk_in_proc (org.apache.aurora.scheduler.zookeeper.guice.client.flagged.FlaggedClientConfig.zk_in_proc): false
I0115 20:18:37.890 [main, ArgScanner:443] zk_session_timeout (org.apache.aurora.scheduler.zookeeper.guice.client.flagged.FlaggedClientConfig.zk_session_timeout): (4, secs)
I0115 20:18:37.890 [main, ArgScanner:445] -------------------------------------------------------------------------
Exception in thread "main" java.lang.IllegalStateException: A value for the -native_log_file_path flag must be supplied
	at org.apache.aurora.scheduler.log.mesos.MesosLogStreamModule.getRequiredArg(MesosLogStreamModule.java:99)
	at org.apache.aurora.scheduler.log.mesos.MesosLogStreamModule.<init>(MesosLogStreamModule.java:110)
	at org.apache.aurora.scheduler.app.SchedulerMain.main(SchedulerMain.java:209)
```

Bugs closed: AURORA-1587

Reviewed at https://reviews.apache.org/r/42375/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/c96d5b8a
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/c96d5b8a
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/c96d5b8a

Branch: refs/heads/master
Commit: c96d5b8ad96cbcbf42ee031f15ccaeb7a08963e9
Parents: b563679
Author: John Sirois <js...@apache.org>
Authored: Tue Jan 19 09:32:10 2016 -0700
Committer: John Sirois <js...@apache.org>
Committed: Tue Jan 19 09:32:10 2016 -0700

----------------------------------------------------------------------
 .../log/mesos/MesosLogStreamModule.java         | 24 +++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/c96d5b8a/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule.java b/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule.java
index 906b349..5daafa9 100644
--- a/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/log/mesos/MesosLogStreamModule.java
@@ -93,10 +93,30 @@ public class MesosLogStreamModule extends PrivateModule {
   private static final Arg<Amount<Long, Time>> WRITE_TIMEOUT =
       Arg.create(Amount.of(3L, Time.SECONDS));
 
+  private static <T> T getRequiredArg(Arg<T> arg, String name) {
+    if (!arg.hasAppliedValue()) {
+      throw new IllegalStateException(
+          String.format("A value for the -%s flag must be supplied", name));
+    }
+    return arg.get();
+  }
+
   private final ClientConfig zkClientConfig;
+  private final File logPath;
+  private final String zkLogGroupPath;
 
   public MesosLogStreamModule(ClientConfig zkClientConfig) {
+    this(zkClientConfig,
+        getRequiredArg(LOG_PATH, "native_log_file_path"),
+        getRequiredArg(ZK_LOG_GROUP_PATH, "native_log_zk_group_path"));
+  }
+
+  public MesosLogStreamModule(ClientConfig zkClientConfig, File logPath, String zkLogGroupPath) {
     this.zkClientConfig = Objects.requireNonNull(zkClientConfig);
+    this.logPath = Objects.requireNonNull(logPath);
+
+    PathUtils.validatePath(zkLogGroupPath); // This checks for null.
+    this.zkLogGroupPath = zkLogGroupPath;
   }
 
   @Override
@@ -114,7 +134,6 @@ public class MesosLogStreamModule extends PrivateModule {
   @Provides
   @Singleton
   Log provideLog() {
-    File logPath = LOG_PATH.get();
     File parentDir = logPath.getParentFile();
     if (!parentDir.exists() && !parentDir.mkdirs()) {
       addError("Failed to create parent directory to store native log at: %s", parentDir);
@@ -123,14 +142,13 @@ public class MesosLogStreamModule extends PrivateModule {
     String zkConnectString = Joiner.on(',').join(
         Iterables.transform(zkClientConfig.servers, InetSocketAddressHelper::toString));
 
-    PathUtils.validatePath(ZK_LOG_GROUP_PATH.get());
     return new Log(
         QUORUM_SIZE.get(),
         logPath.getAbsolutePath(),
         zkConnectString,
         zkClientConfig.sessionTimeout.getValue(),
         zkClientConfig.sessionTimeout.getUnit().getTimeUnit(),
-        ZK_LOG_GROUP_PATH.get(),
+        zkLogGroupPath,
         zkClientConfig.credentials.scheme(),
         zkClientConfig.credentials.authToken());
   }