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
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.
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.
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
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
Verified, rev2561, linux agent, windows server.
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-1320