Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 1032039 - JON server cannot restart itself
Browse files Browse the repository at this point in the history
The fix implements DiscoveryCallback and ResourceUpgradeCallback in
rhq-server plugin and sets proper start script parameters (uses rhqctl) for
RHQ Server resources.

When non-HA server is restarted via RHQ Server scheduled operation (agent
attempting to restart the server is also reporting to the same server)
restart operation will not succeed (although server was in fact restarted)
and it will timeout - this happens, because when agent wants to deliver
operation result to server, server goes immediatelly down (as a consequence
of restart operation) and when it comes up, agent is unable to resend
operation result data anymore (this maybe a separate bug/edge case)

(cherry picked from commit a6beed4)
Signed-off-by: Libor Zoubek <lzoubek@redhat.com>
  • Loading branch information
Libor Zoubek committed Mar 21, 2015
1 parent b76f9f3 commit f64d2a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Expand Up @@ -34,12 +34,13 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryCallback;
import org.rhq.core.pluginapi.util.StartScriptConfiguration;
import org.rhq.core.system.ProcessInfo;
import org.rhq.core.util.obfuscation.Obfuscator;

public class DiscoveryCallbackImpl implements ResourceDiscoveryCallback {

private static final String PLUGIN_CONFIG_HOME_DIR = "homeDir";
public static final String PLUGIN_CONFIG_HOME_DIR = "homeDir";
private static final String PLUGIN_CONFIG_PASSWORD = "password";
private static final String PROP_SERVER_PROP_FILE = "../bin/rhq-server.properties";
private static final String PROP_SERVER_MGMT_USER_PASSWORD = "rhq.server.management.password";
Expand Down Expand Up @@ -106,6 +107,13 @@ public DiscoveryCallbackResults discoveredResources(DiscoveredResourceDetails di
discoveredDetails.setPluginConfiguration(pluginConfig);

pluginConfig.setSimpleValue("supportsPatching", "false");

// set rhqctl as start-script
StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfig);
startScriptConfig.setStartScriptPrefix(null);
startScriptConfig.setStartScriptArgs(Arrays.asList("start", "--server"));
startScriptConfig.setStartScript(new File(homeDirFile.getParentFile(), "bin" + File.separator + "rhqctl"));

} catch (Throwable t) {
log.warn(
"Problem setting RHQ Server management password - will not be able to connect to the RHQ Server instance",
Expand Down
Expand Up @@ -19,11 +19,15 @@

package org.rhq.plugins.server;

import java.io.File;
import java.util.Arrays;

import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.resource.ResourceUpgradeReport;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeCallback;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
import org.rhq.core.pluginapi.util.StartScriptConfiguration;
import org.rhq.core.system.ProcessInfo;

/**
Expand All @@ -35,7 +39,6 @@ public final class ResourceUpgradeCallbackImpl implements ResourceUpgradeCallbac
@Override
public void upgrade(ResourceUpgradeReport upgradeReport,
ResourceUpgradeContext<ResourceComponent<?>> inventoriedResource) {

ProcessInfo processInfo = inventoriedResource.getNativeProcess();

if (DiscoveryCallbackImpl.isRhqServer(processInfo)) {
Expand All @@ -61,6 +64,18 @@ public void upgrade(ResourceUpgradeReport upgradeReport,
resourceName = inventoriedResource.getName();
}

// set rhqctl as start-script
StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfiguration);
File startScriptFile = startScriptConfig.getStartScript();
if (startScriptFile != null && startScriptFile.getName().equals("standalone.sh")) {
startScriptConfig.setStartScriptPrefix(null);
startScriptConfig.setStartScriptArgs(Arrays.asList("start", "--server"));
File homeDirFile = new File(
pluginConfiguration.getSimpleValue(DiscoveryCallbackImpl.PLUGIN_CONFIG_HOME_DIR));
startScriptConfig.setStartScript(new File(new File(homeDirFile, "bin"), "rhqctl"));
upgradeReport.setNewPluginConfiguration(pluginConfiguration);
}

// this is not critical, we can live with the server being called a "wrong" name.
// report, but not enforce the change (i.e. don't use upgradeReport.setForceGenericPropertyUpgrade(true)).
if (!resourceName.endsWith(" RHQ Server")) {
Expand Down

0 comments on commit f64d2a1

Please sign in to comment.