Bug 1158228 - The --agent-preference and --agent-config options for rhqctl install don't work as expected on Windows
Summary: The --agent-preference and --agent-config options for rhqctl install don't wo...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: Agent, Installer
Version: JON 3.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR01
: JON 3.3.0
Assignee: John Mazzitelli
QA Contact: Armine Hovsepyan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-28 21:23 UTC by Michael Burman
Modified: 2015-09-03 00:03 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: When installing the agent on Windows and where the agent service that gets installed will run as a different user as that user who installed the agent via rhqctl. Consequence: The agent configuration stored by the installer goes in a different Java Preferences store (since Java Preferences are stored in a user-specific location). In some cases (like when installing a standalone storage node+agent without a local JON Server on the same Windows box) the agent will fail to start and register properly Fix: Instead of using --agent-preferences command line option to rhqctl, you need to preconfigure a full agent-configuration.xml file (see documentation on preconfiguring the agent for more details). You then pass that preconfigured agent-configuration.xml to "rhqctl install" via the --agent-config command line option. Result: The agent will ensure to load the preconfigured agent-configuration.xml when it starts up for the first time, thus getting its true configuration settings, which can include remote JON Server endpoint information.
Clone Of:
Environment:
Last Closed: 2014-12-11 14:04:14 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1187527 None None None Never

Internal Links: 1187527

Description Michael Burman 2014-10-28 21:23:54 UTC
Description of problem: In Windows, JON/RHQ are run as Services and are installed by default as such. Services on the other hand are by default run with the "Local system account", which is non-user account and different from the installer's account.

This means for example that when we want to install additional storage node, we will give for example the following parameter: --agent-preference="rhq.agent.server.bind-address=0.0.0.0"

This parameter is stored to the JavaPrefs (in the registry), but under the installer's user, which is not used to run the agent itself. This will end up with failure like this:

2014-10-28 20:45:21,574 INFO  [WrapperSimpleAppMain] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.no-auto-detect}Server auto-detection is not enabled - starting the poller immediately

And the agent will most likely not find anything. 


Version-Release number of selected component (if applicable): JON 3.3.0.ER05 & current master.


How reproducible: Always.


Steps to Reproduce:
1. Install additional storage node with --agent-preference
2. rhqctl start
3.

Actual results: Agent will never connect to the server.


Expected results: Agent would use the given parameters.


Additional info:

Comment 2 Jay Shaughnessy 2014-10-29 15:00:29 UTC
It is only a default that the windows service is installed to run as the system default user.  It can be installed as different user with the RUN_AS or RUN_AS_ME settings.  This could be one workaround assuming the user doing the install was also the user under which the service was running.

Other than that, I'm not sure how to get the command line pref set in the correct java preferences.

Could you just use the --agent-config option instead?

Comment 3 Michael Burman 2014-10-29 15:18:01 UTC
I clarified the title of this. So any scenario where agent is started as a service will not work with any configuration mode.

So these options:

- Downloading only the rhq-agent.jar and installing it. The configuration entered will not be taken into account once the agent is started with wrapper that installed it on Windows.

- Any rhqctl installation (including additional storage nodes or other reasons to use rhqctl)

The only installation which will work out of the box is installing JON server on Windows. But no Windows machine can be monitored without manual tinkering.

Comment 5 Jay Shaughnessy 2014-10-29 16:00:37 UTC
I re-clarified the summary for the BZ to hopefully be more specific.

The issue being that using either of:

  'rhqctl install --agent-preference <pref>'
  'rhqctl install --agent-config <config-file>'

will apply the settings to the registry settings of the user executing the rhqctl command, and not necessarily to the user running the installed service.

So, the only way this will work, currently, as far as I know, is if the RHQ_SERVER_RUN_AS_ME=true property has been set prior to the install command.  This will install the service to run as the current user. In that case all of the preferences will be set correctly.

Another possible workaround, I think, would be to not use those options on the 'rhqctl install' command line.  And later, after the install has been performed and the agent is started, use the agent prompt commands ['config' and 'setconfig'] to update the config settings as needed.

Other options or fixes will need to be investigated.

Comment 6 John Mazzitelli 2014-10-29 21:27:25 UTC
I think this will help:

https://github.com/rhq-project/rhq/commit/438e10b42c4d8725637eb4582b0a7d072b040ee2

now you can preconfigure an agent config xml with, say, remote server endpoint info and pass it in via rhqctl install --agent-config.

Comment 7 John Mazzitelli 2014-10-29 21:39:13 UTC
(In reply to John Mazzitelli from comment #6)
> I think this will help:
> 
> https://github.com/rhq-project/rhq/commit/
> 438e10b42c4d8725637eb4582b0a7d072b040ee2
> 
> now you can preconfigure an agent config xml with, say, remote server
> endpoint info and pass it in via rhqctl install --agent-config.

jay cherry-picked:

https://github.com/rhq-project/rhq/commit/65f745fc70ae63045476ba8e0cd641cda1000677

Comment 8 John Mazzitelli 2014-10-29 21:44:31 UTC
OK, here's the deal. Because we have multiple users here (user A running the installer and user B running the agent), the installer can't do what it wants in some cases - it can't alter user B's Java preferences. Under most cases, no one cares because the installer should be run by the user who will run the agent. But in some cases, this doesn't happen on Windows - and in this case you can't use things like the --agent-preference option in rhqctl.

So what we can do now with the code just committed is ask that the Windows user preconfigure an agent-configuration.xml (this would allow him to put the remote server address and port in the .xml, for example) and then pass it to the installer via rhqctl install --agent-config /my/custom/agent-configuration.xml

There is a new feature in the agent - if you put a file called "agent-configuration.xml.reload" in the /conf directory, the agent will do a one-time reload of the agent-configuration.xml file at startup. It will then delete that .reload file. The rhqctl installer will create this .reload file for you in the newly installed agent and will put your preconfigured agent-configuration.xml in the conf/ directory. So even if you have old preferences (or no preferences at all) it doesn't matter - your preconfigured agent .xml will get loaded thanks to the reload marker file. The reload marker file has the same effect as if you passed in "-c agent-configuration.xml" to the agent command line.

Comment 9 Jay Shaughnessy 2014-10-30 15:44:10 UTC
So, I believe there are three ways to get around this Windows install issue:

1) Install using RUN_AS_ME and use --agent-preference

   This will run the service as the same user executing rhqctl, so the
   command line --agent-preference settings will apply.

2) Install using --agent-config <custom-agent-configuration.xml>

   Without RUN_AS_ME the user executing rhqctl will be different that the
   user running the service.  But with the latest change the custom
   configuration file will be applied on the first startup of the agent.
   
3) Update the agent config post-install

   Without RUN_AS_ME the user executing rhqctl will be different that the
   user running the service.  Without --agent-config the installed agent will
   have default configuration.  After installation the agent config can be
   updated using the agent prompt commands (or direct manipulation of the
   registry - not recommended).

Comment 10 Simeon Pinder 2014-11-03 19:03:40 UTC
Moving to ON_QA as available to test with latest brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=396547

Comment 11 Armine Hovsepyan 2014-11-10 16:32:24 UTC
Scenario 1:
rhqctl install using pre-configued rhq-server-env.sh with 
set RHQ_AGENT_RUN_AS_ME=true
set RHQ_AGENT_PASSWORD=PASSWORD_OF_CURRENT_USER (Administrator in my case)

Scenario 2: 
rhqctl install --agent-config PATH_TO_AGENT_CONFIGURATION.xml


Scenario 3:
rhqctl install (without any config)
rhq-agent.bat -L 
rhqctl start OR rhq-agent-wrapper.bat start 


All 3 scenarios worked, agent connected to server (both remote and local)

Thank you for docs and hints, Jay.

verified in JON 3.3 CR01


Note You need to log in before you can comment on or make changes to this bug.