-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix overwriting agents when 'force' is less than '0' #3527
Conversation
Hi team, Issue #3431 is solved with this PR. # curl -u foo:bar -k -X POST -d '{"name":"NewHost_4","ip":"10.0.10.14","id":"010","key":"1abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi64", "force": "0"}' -H 'Content-Type:application/json' "http://127.0.0.1:55000/agents/insert?pretty"
{
"error": 0,
"data": {
"id": "010",
"key": "MDEwIE5ld0hvc3RfNCAxMC4wLjEwLjE0IDFhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5emFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6YWJjZGVmZ2hpNjQ="
}
}
# curl -u foo:bar -k -X POST -d '{"name":"NewHost_4","ip":"10.0.10.14","id":"010","key":"1abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi64", "force": "0"}' -H 'Content-Type:application/json' "http://127.0.0.1:55000/agents/insert?pretty"
{
"error": 0,
"data": {
"id": "010",
"key": "MDEwIE5ld0hvc3RfNCAxMC4wLjEwLjE0IDFhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5emFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6YWJjZGVmZ2hpNjQ="
}
} If # curl -u foo:bar -k -X POST -d '{"name":"NewHost_4","ip":"10.0.10.14","id":"010","key":"1abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi64"}' -H 'Content-Type:application/json' "http://127.0.0.1:55000/agents/insert?pretty"
{
"error": 9012,
"message": "Duplicated ID"
} Best regards, Demetrio. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the call is passed as force parameter with a positive integer, this option should, as described in the documentation, overwrite the agent entry if only if the agent's last keepalive was n seconds ago. Please check and fix it so that it will only be overwritten if this condition is met.
Hi team! I have tested that an agent is overwritten if another agent with the same id is registered. Regards, Eva TestModify agent IPFirst I registered an agent:
Check
I overwrite the agent with a different IP.
Check
Connect agent to the manager by adding key
Agent connects:
But
Overwrite the active agent's IP
As the agent is still in IP
client.keys update IP: Modify name, IP and keyRegister agent:
Check
Overwrite agent:
And agent connects:
But agent is connected:
Overwrite without force option doesn't workThere's a registered agent: I try to overwrite agent without force options:
But agent is not overwrite: It works
|
PD: TestMy agent is active:
Overwrite agent:
And
And
|
Description
authd
was overwriting an agent with the same IP whenforce
was less than0
.A case when this happens is making the following API call:
Logs/Alerts example
This is what was happening before while making that API call:
As it can be seen the process went well when it should say that the ID is duplicated. Also, it shouldn't overwrite the agent.
Tests
It's been checked that the agents with the same ID are not overwritten anymore making a call like the described above. Now the result is the following: