brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/4] git commit: SoftwareProcess: don’t getShellEnv() if supplied
Date Wed, 05 Nov 2014 14:34:52 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master fcac7738c -> c323b00d3


SoftwareProcess: don’t getShellEnv() if supplied

- Calling getShellEnvironment() during jboss.install() was causing it
  to lookup the config, including sysprops. However, that required
  MySql to have a URL before it could resolve.
  On localhost (e.g. integration tests), the jboss.install() held a
  lock (SshMachineLocation.acquireMutex) which meant only one thing
  could be installed at a time - hence prevented MySql from being 
  installed. Therefore deadlock.
- Fixed by guarding the call to getShellEnvironment(), to only be
  done if env was not explicitly supplied.

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

Branch: refs/heads/master
Commit: b8ec67f7a5e7547f7d2d59f85b3f6699b0352e6e
Parents: fcac773
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Nov 5 13:18:53 2014 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Nov 5 13:18:53 2014 +0000

----------------------------------------------------------------------
 .../basic/AbstractSoftwareProcessSshDriver.java       | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b8ec67f7/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
index 0e54a20..1f21fb7 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
@@ -57,7 +57,6 @@ import brooklyn.util.text.StringPredicates;
 import brooklyn.util.text.Strings;
 import brooklyn.util.time.Duration;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -283,7 +282,12 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
             flags.putAll(getSshFlags());
         }
         flags.putAll(flags2);
-        Map<String, String> environment = Optional.fromNullable((Map<String,String>)
flags.get("env")).or(getShellEnvironment());
+        Map<String, String> environment = (Map<String, String>) flags.get("env");
+        if (environment == null) {
+            // Important only to call getShellEnvironment() if env was not supplied; otherwise
it
+            // could cause us to resolve config (e.g. block for attributeWhenReady) too early.
+            environment = getShellEnvironment();
+        }
         if (Tasks.current()!=null) {
             // attach tags here, as well as in ScriptHelper, because they may have just been
read from the driver
             if (environment!=null) {
@@ -368,7 +372,11 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
     @Override
     public void copyRuntimeResources() {
         try {
-            execute("mkdir -p " + getRunDir(), "create run directory");
+            // Ensure environment variables are not looked up here, otherwise sub-classes
might
+            // lookup port numbers and fail with ugly error if port is not set. It could
also
+            // cause us to block for attribute ready earlier than we need.
+            DynamicTasks.queue(SshEffectorTasks.ssh("mkdir -p " + getRunDir()).summary("create
run directory")
+                .requiringExitCodeZero()).get();
 
             Map<String, String> runtimeFiles = entity.getConfig(SoftwareProcess.RUNTIME_FILES);
             if (runtimeFiles != null && runtimeFiles.size() > 0) {


Mime
View raw message