Red Hat Bugzilla – Full Text Bug Listing
|Summary:||Passing agent command-line options via start script/environment prevents agent from starting as normal|
|Product:||[Other] RHQ Project||Reporter:||Larry O'Leary <loleary>|
|Component:||Agent||Assignee:||Charles Crouch <ccrouch>|
|Status:||CLOSED CURRENTRELEASE||QA Contact:||Mike Foley <mfoley>|
|Version:||4.2||CC:||ccrouch, hbrock, hrupp, mazz|
|Target Release:||JON 3.1.0, RHQ 4.3.0|
|Fixed In Version:||4.3||Doc Type:||Bug Fix|
|Doc Text:||Story Points:||---|
|Last Closed:||2013-08-31 06:09:47 EDT||Type:||---|
|oVirt Team:||---||RHEL 7.3 requirements from Atomic Host:|
|Bug Depends On:|
Description Larry O'Leary 2011-12-18 01:23:21 EST
Description of problem: When setting RHQ_AGENT_CMDLINE_OPTS, the agent no longer starts as expected. This is due to the RHQ_AGENT_CMDLINE_OPTS being used directly in the rhq-agent.sh, rhq-agent-wrapper.sh, rhq-agent.bat, and rhq-agent-wrapper.bat scripts. Essentially, the start scripts check to see if the variable is set and if it is, the default options are not added to the variable. This includes the processing of additional command-line arguments. Instead, the start scripts should probably use an RHQ_AGENT_ADDITIONAL_CMDLINE_OPTS similar to the RHQ_AGENT_ADDITIONAL_JAVA_OPTS environment variables. This will allow the defaults to continue to be used, along with arguments passed on the command-line itself and the additional options (such as the --pref=mynodename or --nonative) to be added to the start commands in addition to RHQ_AGENT_CMDLINE_OPTS and the options passed on the command-line directly. Version-Release number of selected component (if applicable): JON 2.4.1 How reproducible: Always Steps to Reproduce: 1. Edit rhq-agent-env.sh to set --pref=mynode in the RHQ_AGENT_CMDLINE_OPTS 2. Attempt to start the agent with rhq-agent.sh --cleanconfig Actual results: Agent starts using its current configuration and does not prompt for new configuration. Expected results: Agent should have prompted for new configuration. Additional info: Although the rhq-agent-env.[sh|bat] script indicates that $@ or %* can be added to have the command-line arguments also passed in, this does not fix all situations. For example, on Linux/UNIX the --daemon argument is expected when starting the agent using the rhq-agent-wrapper.sh script. However, if you add the --daemon argument to the RHQ_AGENT_CMDLINE_OPTS the result is the rhq-agent.sh script no longer works as expected. Instead, you must continue to edit the rhq-agent-env.sh script depending on which start option you want to use.
Comment 1 Ian Springer 2012-02-03 11:56:52 EST
I think the issue here is the following lines in rhq-agent-wrapper.sh and the equivalent lines in rhq-agent-wrapper.bat: if [ "x$RHQ_AGENT_CMDLINE_OPTS" = "x" ]; then RHQ_AGENT_CMDLINE_OPTS=--daemon fi export RHQ_AGENT_CMDLINE_OPTS These lines run after rhq-agent-env.sh is sourced. They should be replaced with something like: found_daemon_option=0 for opt in $RHQ_AGENT_CMDLINE_OPTS; do if [ "$opt" = "-d" ] || [ "$opt" = "--daemon" ]; then found_daemon_option=1 break fi done if [ "$found_daemon_option" = "0" ]; then RHQ_AGENT_CMDLINE_OPTS="--daemon $RHQ_AGENT_CMDLINE_OPTS" fi export RHQ_AGENT_CMDLINE_OPTS This way, we ensure the --daemon option always gets included in $RHQ_AGENT_CMDLINE_OPTS, whether or not the user defined RHQ_AGENT_CMDLINE_OPTS. Because the wrapper scripts always want the daemon option. I don't think we need to add support for a RHQ_AGENT_ADDITIONAL_CMDLINE_OPTS variable, since the wrapper script setting of --daemon is the one special case of a hard-coded option. The scripts don't set any default options that are only used when RHQ_AGENT_CMDLINE_OPTS is not predefined, so it's a bit of a different beast than RHQ_AGENT_JAVA_OPTS. Note, due to the fact that rhq-agent-env.sh is used by both rhq-agent-wrapper.sh and rhq-agent.sh, users should never include --daemon when setting RHQ_AGENT_CMDLINE_OPTS in rhq-agent-env.sh. We should remove it from the commented out "#RHQ_AGENT_CMDLINE_OPTS=" line in the default rhq-agent-env.sh and add a comment telling users to never include --daemon in the value. I'll create a separate BZ for that change.
Comment 2 John Mazzitelli 2012-02-03 12:04:13 EST
ian's proposed fix to rhq-agent-wrapper.sh looks good. I would recommend that solution. Yes, the point was to always make sure --daemon should be there (even though what we have didn't really do that 100% of the time). However we can ensure that --daemon is there, we should do it.
Comment 3 Mike Foley 2012-02-06 12:02:31 EST
per bz triage (asantos, ccrouch, mfoley. loleary)
Comment 4 Ian Springer 2012-02-15 14:41:55 EST
Fixed in master: http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=commitdiff;h=31181a3 and: http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=commitdiff;h=d838043 Note, the fix was not required on the Windows side, because rhq-agent-wrapper.bat does not use the RHQ_AGENT_CMDLINE_OPTS variable. Instead, when starting the Agent via rhq-agent-wrapper.bat, Agent command line options must be specified in wrapper\rhq-agent-wrapper.conf or wrapper\rhq-agent-wrapper.inc. I did add some better comments in rhq-agent-env.bat regarding RHQ_AGENT_CMDLINE_OPTS and a couple other variables not being used by rhq-agent-wrapper.bat.
Comment 6 Heiko W. Rupp 2013-08-31 06:09:47 EDT
Bulk close of old bugs in VERIFIED state.