Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 845114 Details for
Bug 994250
rhqctl always returns exit code 0
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
additional patch to be applied
0001-BZ-994250-fix-some-problems-that-caused-the-install-.patch (text/plain), 14.93 KB, created by
John Mazzitelli
on 2014-01-03 22:24:22 UTC
(
hide
)
Description:
additional patch to be applied
Filename:
MIME Type:
Creator:
John Mazzitelli
Created:
2014-01-03 22:24:22 UTC
Size:
14.93 KB
patch
obsolete
>From e62b61a819179672363c3bb48dec9ce2b9a1fcd7 Mon Sep 17 00:00:00 2001 >From: John Mazzitelli <mazz@redhat.com> >Date: Fri, 3 Jan 2014 17:22:35 -0500 >Subject: [PATCH] BZ 994250 - fix some problems that caused the install to > fail. fixed some other things as well > >--- > .../org/rhq/server/control/ControlCommand.java | 27 ++++++++---- > .../java/org/rhq/server/control/RHQControl.java | 2 - > .../server/control/command/AbstractInstall.java | 42 +++++--------------- > .../org/rhq/server/control/command/Install.java | 7 ++- > .../org/rhq/server/control/command/Status.java | 38 +++++++++++++++-- > .../org/rhq/server/control/command/Upgrade.java | 9 +++- > 6 files changed, 72 insertions(+), 53 deletions(-) > >diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java >index a13a598..52a45e7 100644 >--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java >+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java >@@ -162,9 +162,8 @@ public abstract class ControlCommand { > rValue = RHQControl.EXIT_CODE_INVALID_ARGUMENT; > } catch (ConfigurationException e) { > throw new RHQControlException("Failed to update " + getRhqCtlProperties(), e); >- } finally { >- return rValue; > } >+ return rValue; > } > > public void printUsage() { >@@ -457,7 +456,7 @@ public abstract class ControlCommand { > protected void killPid(String pid) throws IOException { > Executor executor = new DefaultExecutor(); > executor.setWorkingDirectory(getBinDir()); >- PumpStreamHandler streamHandler = new PumpStreamHandler(new NullOutputStream(), new NullOutputStream()); >+ PumpStreamHandler streamHandler = new PumpStreamHandler(createNullOutputStream(), createNullOutputStream()); > executor.setStreamHandler(streamHandler); > org.apache.commons.exec.CommandLine commandLine; > >@@ -469,19 +468,18 @@ public abstract class ControlCommand { > > Executor executor = new DefaultExecutor(); > executor.setWorkingDirectory(getBinDir()); >- PumpStreamHandler streamHandler = new PumpStreamHandler(new NullOutputStream(), new NullOutputStream()); >+ PumpStreamHandler streamHandler = new PumpStreamHandler(createNullOutputStream(), createNullOutputStream()); > executor.setStreamHandler(streamHandler); >- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine("/bin/kill") >- .addArgument("-0") >- .addArgument(pid); >+ org.apache.commons.exec.CommandLine commandLine; >+ commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument("-0").addArgument(pid); > > try { > int code = executor.execute(commandLine); >- if (code!=0) { >+ if (code != 0) { > return false; > } > } catch (ExecuteException ee ) { >- if (ee.getExitValue()==1) { >+ if (ee.getExitValue() == 1) { > // return code 1 means process does not exist > return false; > } >@@ -507,6 +505,17 @@ public abstract class ControlCommand { > } > } > >+ /** >+ * Call this method to get an output stream that throws away all data. Useful >+ * when executing commands which you don't care about seeing its output on stdout. >+ * Example usage: >+ * executor.setStreamHandler(new PumpStreamHandler(createNullOutputStream(), createNullOutputStream())); >+ * @return a null output stream >+ */ >+ protected OutputStream createNullOutputStream() { >+ return new NullOutputStream(); >+ } >+ > private class NullOutputStream extends OutputStream { > @Override > public void write(byte[] b, int off, int len) { >diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java >index 88b085f..3cfa665 100644 >--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java >+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java >@@ -61,8 +61,6 @@ public class RHQControl { > public static final int EXIT_CODE_OPERATION_FAILED = 1; > public static final int EXIT_CODE_INVALID_ARGUMENT = 2; > public static final int EXIT_CODE_NOT_INSTALLED = 5; >-// public static final int EXIT_CODE_OPERATION_NOT_RUNNING = 7; >- > > private Commands commands = new Commands(); > >diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java >index ed2b2f8..121aef5 100644 >--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java >+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java >@@ -43,7 +43,6 @@ import org.apache.commons.cli.CommandLineParser; > import org.apache.commons.cli.PosixParser; > import org.apache.commons.exec.DefaultExecuteResultHandler; > import org.apache.commons.exec.DefaultExecutor; >-import org.apache.commons.exec.ExecuteException; > import org.apache.commons.exec.Executor; > import org.apache.commons.exec.PumpStreamHandler; > >@@ -160,31 +159,6 @@ public abstract class AbstractInstall extends ControlCommand { > > } > >- protected boolean isUnixPidRunning(String pid) { >- >- Executor executor = new DefaultExecutor(); >- executor.setWorkingDirectory(getBinDir()); >- executor.setStreamHandler(new PumpStreamHandler()); >- org.apache.commons.exec.CommandLine commandLine; >- >- commandLine = new org.apache.commons.exec.CommandLine("/bin/kill").addArgument("-0").addArgument(pid); >- >- try { >- int code = executor.execute(commandLine); >- if (code != 0) { >- return false; >- } >- } catch (ExecuteException ee) { >- if (ee.getExitValue() == 1) { >- // return code 1 means process does not exist >- return false; >- } >- } catch (IOException e) { >- log.error("Checking for running process failed: " + e.getMessage()); >- } >- return true; >- } >- > protected void waitForRHQServerToInitialize() throws Exception { > try { > final long messageInterval = 30000L; >@@ -520,8 +494,12 @@ public abstract class AbstractInstall extends ControlCommand { > > executor.execute(commandLine, executeHandler); > log.info("The server installer is running"); >- return executeHandler.getExitValue(); >- } catch (IOException e) { >+ if (executeHandler.hasResult()) { >+ return executeHandler.getExitValue(); >+ } else { >+ return RHQControl.EXIT_CODE_OK; // the installer really didn't exit yet, but just indicate we started it OK >+ } >+ } catch (Exception e) { > log.error("An error occurred while starting the server installer: " + e.getMessage()); > return RHQControl.EXIT_CODE_NOT_INSTALLED; > } >@@ -575,7 +553,7 @@ public abstract class AbstractInstall extends ControlCommand { > } > > protected int installStorageNode(final File storageBasedir, CommandLine rhqctlCommandLine, boolean start) >- throws IOException { >+ throws Exception { > try { > log.info("Preparing to install RHQ storage node."); > >@@ -621,7 +599,7 @@ public abstract class AbstractInstall extends ControlCommand { > addUndoTaskToStopComponent("--storage"); > > return exitCode; >- } catch (IOException e) { >+ } catch (Exception e) { > log.error("An error occurred while running the storage installer: " + e.getMessage()); > if (e.getMessage().toLowerCase().contains("exit value: 3")) { > log.error("Try to point your root data directory via --" + STORAGE_DATA_ROOT_DIR >@@ -638,7 +616,7 @@ public abstract class AbstractInstall extends ControlCommand { > return rValue; > } > >- private int installAgent(final File agentBasedir) throws IOException { >+ private int installAgent(final File agentBasedir) throws Exception { > try { > log.info("Installing RHQ agent"); > >@@ -668,7 +646,7 @@ public abstract class AbstractInstall extends ControlCommand { > int exitValue = executor.execute(commandLine); > log.info("The agent installer finished running with exit value " + exitValue); > return exitValue; >- } catch (IOException e) { >+ } catch (Exception e) { > log.error("An error occurred while running the agent installer: " + e.getMessage()); > throw e; > } >diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java >index 3ab3f00..f8d37d9 100644 >--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java >+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java >@@ -164,8 +164,11 @@ public class Install extends AbstractInstall { > } else { > startedServer = true; > startRHQServerForInstallation(); >- rValue = Math.max(rValue, runRHQServerInstaller()); >- waitForRHQServerToInitialize(); >+ int installerStatusCode = runRHQServerInstaller(); >+ rValue = Math.max(rValue, installerStatusCode); >+ if (installerStatusCode == RHQControl.EXIT_CODE_OK) { >+ waitForRHQServerToInitialize(); >+ } > } > } > >diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java >index e52f0a8..9c6ed7f 100644 >--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java >+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java >@@ -131,7 +131,13 @@ public class Status extends ControlCommand { > commandLine = getCommandLine("rhq-storage", "status"); > try { > rValue = executor.execute(commandLine); >- >+ } catch (ExecuteException ee) { >+ log.debug("Failed to check storage service status", ee); >+ rValue = ee.getExitValue(); >+ if (rValue == RHQControl.EXIT_CODE_OK) { >+ // if somehow we were told it was OK, change it to unknown since it can't be OK >+ rValue = RHQControl.EXIT_CODE_STATUS_UNKNOWN; >+ } > } catch (Exception e) { > log.debug("Failed to check storage service status", e); > rValue = RHQControl.EXIT_CODE_STATUS_UNKNOWN; >@@ -154,7 +160,18 @@ public class Status extends ControlCommand { > Executor executor = new DefaultExecutor(); > executor.setWorkingDirectory(getBinDir()); > executor.setStreamHandler(new PumpStreamHandler()); >- return executor.execute(commandLine); >+ >+ int rValue; >+ try { >+ rValue = executor.execute(commandLine); >+ } catch (ExecuteException ee) { >+ rValue = ee.getExitValue(); >+ if (rValue == RHQControl.EXIT_CODE_OK) { >+ // if somehow we were told it was OK, change it to unknown since it can't be OK >+ rValue = RHQControl.EXIT_CODE_STATUS_UNKNOWN; >+ } >+ } >+ return rValue; > } > > private int checkAgentStatus() throws Exception { >@@ -166,16 +183,27 @@ public class Status extends ControlCommand { > Executor executor = new DefaultExecutor(); > executor.setWorkingDirectory(agentBinDir); > executor.setStreamHandler(new PumpStreamHandler()); >+ >+ int rValue; > try { >- return executor.execute(commandLine); >+ rValue = executor.execute(commandLine); > } catch (ExecuteException e) { > // For windows the JSW exit code for a status check is expected to be a mask value and the agent wrapper > // .bat will return it explicitly. We can ignore it and assume that the logged output is sufficient. > // See http://wrapper.tanukisoftware.com/doc/english/launch-win.html#standalone-status > if (!isWindows()) { >- throw e; >+ // UNIX script will exit with 1 if its not running, this is expected, so don't throw exception on 1 >+ if (e.getExitValue() != 1) { >+ throw e; >+ } >+ } >+ rValue = e.getExitValue(); >+ if (rValue == RHQControl.EXIT_CODE_OK) { >+ // if somehow we were told it was OK, change it to unknown since it can't be OK >+ rValue = RHQControl.EXIT_CODE_STATUS_UNKNOWN; > } >- return RHQControl.EXIT_CODE_STATUS_UNKNOWN; > } >+ >+ return rValue; > } > } >diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java >index e80edd9..8195284 100644 >--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java >+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java >@@ -351,8 +351,11 @@ public class Upgrade extends AbstractInstall { > > // start the server, the invoke the installer and wait for the server to be completely installed > startRHQServerForInstallation(); >- rValue = Math.max(rValue, runRHQServerInstaller()); >- waitForRHQServerToInitialize(); >+ int installerStatusCode = runRHQServerInstaller(); >+ rValue = Math.max(rValue, installerStatusCode); >+ if (installerStatusCode == RHQControl.EXIT_CODE_OK) { >+ waitForRHQServerToInitialize(); >+ } > > return rValue; > } >@@ -546,7 +549,7 @@ public class Upgrade extends AbstractInstall { > } > > // now merge the old settings in with the default properties from the new server install >- String newServerPropsFilePath = new File(getBaseDir(), "bin/rhq-server.properties").getAbsolutePath(); >+ String newServerPropsFilePath = getServerPropertiesFile().getAbsolutePath(); > PropertiesFileUpdate newServerPropsFile = new PropertiesFileUpdate(newServerPropsFilePath); > newServerPropsFile.update(oldServerProps); > >-- >1.7.6.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 994250
:
783521
|
839282
|
842792
|
844599
|
844601
| 845114 |
866289