Bug 789111

Summary: rhq-agent --fullcleanconfig is not working
Product: [Other] RHQ Project Reporter: Mike Foley <mfoley>
Component: AgentAssignee: John Mazzitelli <mazz>
Status: CLOSED NOTABUG QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: high    
Version: 3.0.1CC: hrupp
Target Milestone: ---   
Target Release: JON 3.0.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-09 23:46:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Mike Foley 2012-02-09 20:33:34 UTC
Description of problem: rhq-agent --fullcleanconfig is not working


Version-Release number of selected component (if applicable):  JON 3.01


How reproducible:
100%

Steps to Reproduce:
1.  install agent normally ... rhq-agent.sh --cleanconfig
2.  pass a bad token  ... rhq-agent.sh -Drhq.agent.security-token=ABC ...fails as expected 
3.  try to start the agent ... rhq-agent.sh  ... fails to connect ....meh ..ok
4.  now do a fullcleanconfig   rhq-agent.sh --fullcleanconfig  ...still fails to connect ... this is a fail 
  
Actual results:  --fullcleanconfig fully cleans the agent configuration including bad tokens

Expected results:  --fullcleanconfig does fully clean the agent configuration as old (bad) token is still there.  how then ... now .. do i get my agent to connect to the server?


Additional info:
/rhq-agent --fullcleanconfig  
Agent Name [foleymonsterbox1.foleyhomenetwork] : 
Agent Hostname or IP Address [!*] : 
Agent Port [16163] : 
RHQ Server Hostname or IP Address [192.168.0.102] : 
RHQ Server Port [7080] : 
The setup has been completed for the preferences at node [/rhq-agent/default].
The server has rejected the agent registration request. Cause: [org.rhq.core.clientapi.server.core.AgentRegistrationException:The agent [foleymonsterbox1.foleyhomenetwork] is attempting to re-register without a security token. Please consult an administrator to obtain the agent's proper security token and restart the agent with the option "-Drhq.agent.security-token=<the valid security token>"]
Will retry the agent registration request soon...

Comment 1 John Mazzitelli 2012-02-09 23:46:41 UTC
> 4.  now do a fullcleanconfig   rhq-agent.sh --fullcleanconfig
>  ...still fails to connect ... this is a fail 

This is not a fail - this is how it should be working now.

>how then ... now .. do i get my agent to connect to the server?

You do it by what the error messages tells you to do :)

"Please consult an administrator to obtain the agent's proper
security token and restart the agent with the option
"-Drhq.agent.security-token=<the valid security token>"]"

This is a known limitation now - yes, agreed that it will be more annoying to users getting an agent like this back to life. But that's just due to our security rules now. Your agent name is now taken - you MUST register with that agent's token now everytime that agent starts/registers with that name. No longer are you allowed to sneak in and attempt to reuse an agent name withOUT knowing the token. No token, no soup for you!

This is documented here:

http://rhq-project.org/display/JOPR2/Agent+Registration

where it says the following:

If you delete that security token (e.g. restarting the agent with --fullcleanconfig), that agent will attempt to register as a new, unidentified agent but it will not be able to register under the same name "foo" as before nor can it register with the same IP/port combination. This is because that security token is now associated with agent "foo" on IP 1.2.3.4 listening to port 16163 - no other agent can register using that name or IP/port combination without the proper security token. Any agent that wants to identify itself with the name "foo" must have the associated security token. If you wish to re-register that agent with the same name "foo", you must re-install the security token. One way you can do this is:

    1. Stop the agent
    2. Log into the GUI as a user with MANAGE_SECURITY permissions (such as "rhqadmin") and go to Administration>Agents and find your agent. View its details and copy down its security token - let's call it "security-token-foo".
    3. Start the agent with command line option "-Drhq.agent.security-token=security-token-foo"

At this point, the agent should be able to re-register with the same name "foo" as before, now that its security token has been reinstalled. You no longer need to start the agent with that -D option, you only needed to do it once to get that new security token stored in the agent's configuration.