Skip to content

Turning ERROR message to debug when multiple daemons attempt to remove an agent simultaneously#6185

Merged
vikman90 merged 2 commits intomasterfrom
authd-monitor-ID-error
Nov 30, 2020
Merged

Turning ERROR message to debug when multiple daemons attempt to remove an agent simultaneously#6185
vikman90 merged 2 commits intomasterfrom
authd-monitor-ID-error

Conversation

@pereyra-m
Copy link
Copy Markdown
Contributor

@pereyra-m pereyra-m commented Oct 2, 2020

Description

It was found that Wazuh Manager v4.0 prints an ERROR message like the following one due to a race condition trying to delete an agent:

2020/10/02 20:11:00 ossec-authd[23049] local-server.c:414 at local_remove(): ERROR: ERROR 9011: Agent ID not found.

It happens because the auth daemon received a message from remoted to remove an agent, but it can't find it because it was already erased before.
This situation isn't considered an error, and a double try to delete the agent will be printed only as a debug message.

How to reproduce it

If we activate the mond.delete_old_agents option and after the selected time expires, the old disconnected agents will be removed. Then, we can find that error log.

Tests

  • Compilation without warnings in every supported platform
    • Linux
  • Source installation

@pereyra-m pereyra-m changed the base branch from 4.0 to master October 7, 2020 04:38
@pereyra-m pereyra-m force-pushed the authd-monitor-ID-error branch from 441c9ae to 15355ba Compare October 7, 2020 04:44
@pereyra-m pereyra-m marked this pull request as ready for review October 7, 2020 05:03
@pereyra-m pereyra-m self-assigned this Oct 7, 2020
Comment thread src/os_auth/local-server.c Outdated

if (index = OS_IsAllowedID(&keys, id), index < 0) {
merror("ERROR %d: %s.", ERRORS[ENOAGENT].code, ERRORS[ENOAGENT].message);
mdebug1("Error code %d: %s.", ERRORS[ENOAGENT].code, ERRORS[ENOAGENT].message);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the word code. Usually, this kind of logs just say Error X: message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Copy Markdown
Contributor

@DProvinciani DProvinciani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@pereyra-m pereyra-m closed this Oct 14, 2020
@pereyra-m pereyra-m force-pushed the authd-monitor-ID-error branch from 8bf2d8f to 79b33fa Compare October 14, 2020 21:15
@pereyra-m pereyra-m reopened this Oct 14, 2020
@DProvinciani DProvinciani changed the title Turning an ERROR message to debug Turning ERROR message to debug when multiple daemons attempt to remove an agent Oct 15, 2020
@DProvinciani DProvinciani changed the title Turning ERROR message to debug when multiple daemons attempt to remove an agent Turning ERROR message to debug when multiple daemons attempt to remove an agent simultaneously Oct 15, 2020

if (index = OS_IsAllowedID(&keys, id), index < 0) {
merror("ERROR %d: %s.", ERRORS[ENOAGENT].code, ERRORS[ENOAGENT].message);
mdebug1("Error %d: %s.", ERRORS[ENOAGENT].code, ERRORS[ENOAGENT].message);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 433 of local-server.c has the same log for the get option. I think that log should be a debug too.
And both messages can be identical.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

Copy link
Copy Markdown
Contributor

@DProvinciani DProvinciani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@vikman90 vikman90 merged commit fc52ebe into master Nov 30, 2020
@vikman90 vikman90 deleted the authd-monitor-ID-error branch November 30, 2020 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERROR message generated when multiple daemons attempt to remove an agent simultaneously

4 participants