Bug 534533 (RHQ-1320) - agent `failover` command sets rhq.agent.server.bind-address, even if value is bogus.
Summary: agent `failover` command sets rhq.agent.server.bind-address, even if value is...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: RHQ-1320
Product: RHQ Project
Classification: Other
Component: Agent
Version: 1.2
Hardware: All
OS: All
medium
medium
Target Milestone: ---
: ---
Assignee: John Mazzitelli
QA Contact: Jeff Weiss
URL: http://jira.rhq-project.org/browse/RH...
Whiteboard:
Depends On:
Blocks: RHQ-1010
TreeView+ depends on / blocked
 
Reported: 2009-01-06 18:30 UTC by Corey Welton
Modified: 2014-11-09 22:48 UTC (History)
1 user (show)

Fixed In Version: 1.2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Red Hat Enterprise Linux Server release 5.2 (Tikanga) Kernel \r on an \m Linux rlx-0-12.rhndev.redhat.com 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 09:29:46 EST 2008 i686 i686 i386 GNU/Linux java version "1.6.0_11" Java(TM) SE Runtime Environment (build 1.6.0_1
Last Closed:
Embargoed:
cwelton: archived+


Attachments (Terms of Use)

Description Corey Welton 2009-01-06 18:30:00 UTC
If user supplies a bogus value to the --switch parameter in the new `failover` command, it is rejected, but rhq.agent.server.bind-address gets changed anyway.

Steps to repro
1. Run agent in interactive mode.
2. > failover --switch example.com 
3. wait for error prompt to return
4. > getconfig
5. View results

Expected result
* Error message is returned, and thus nothing gets set/changed in the config

Current result:
* Error message occurs, but the changed value appears in the config

> failover --switch example.com
Failed to switch over to server [example.com]. See log file for details.
>getconfig
[...]
rhq.agent.server.bind-address=example.com


Comment 1 John Mazzitelli 2009-01-06 18:40:57 UTC
I see this:

shutdown> failover -s example.com
Failed to switch over to server [example.com]. See log file for details.
shutdown> getconfig rhq.agent.server.bind-address
rhq.agent.server.bind-address=mazzthink

But, my agent was currently in shutdown mode, so maybe the behavior is different if the agent has been started.  Will look into this behavior and see why it does what it does.

Comment 2 John Mazzitelli 2009-01-06 18:44:38 UTC
sending> failover -s foo
Failed to switch over to server [foo]. See log file for details.
sending> getconfig rhq.agent.server.bind-address
rhq.agent.server.bind-address=foo

Looks like the change to the preference is committed when in started.

Comment 3 John Mazzitelli 2009-01-06 18:52:33 UTC
I see the problem. I got half way there :) I reverted the comm object but not the preferences - from AgentMain.switchToServer():

        // remember this in case we fail - we have to revert back to the original server we were talking to
        String originalServerEndpoint = comm.getRemoteEndpoint();

        // need to synch on last failover time so we don't clash with the real failover stuff
        synchronized (m_lastFailoverTime) {
            boolean ok = switchCommServer(comm, newServer, newTransport, newTransportParams);
            if (!ok) {
                try {
                    // we are switching back to the original server because our switch failed
                    comm.setRemoteEndpoint(originalServerEndpoint);
                } catch (Exception e) {
                    // this should never happen
                    LOG.warn(AgentI18NResourceKeys.CANNOT_SWITCH_TO_INVALID_SERVER, originalServerEndpoint, e);
                }
            }
            return ok;
        }

I need to switch back the preferences too, in the if (!ok) block

Comment 4 John Mazzitelli 2009-01-06 19:07:43 UTC
Will check in a fix that does this now (this is running the fix on my local box):

sending> getconfig rhq.agent.server.bind-address
rhq.agent.server.bind-address=mazzthink
sending> failover -s foo
Failed to switch over to server [foo]. See log file for details.
sending> getconfig rhq.agent.server.bind-address
rhq.agent.server.bind-address=mazzthink

Comment 5 Jeff Weiss 2009-01-09 19:23:30 UTC
Verified, rev2561, linux agent, windows server.

Comment 6 Red Hat Bugzilla 2009-11-10 20:30:29 UTC
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-1320



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