Skip to content
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

Error messages on a clean install—error app log messages #4203

Closed
Tracked by #4209
gdiazlo opened this issue Jun 5, 2022 · 2 comments · Fixed by #4235
Closed
Tracked by #4209

Error messages on a clean install—error app log messages #4203

gdiazlo opened this issue Jun 5, 2022 · 2 comments · Fixed by #4235
Assignees
Labels
type/enhancement Enhancement issue

Comments

@gdiazlo
Copy link
Member

gdiazlo commented Jun 5, 2022

Describe the solution you'd like

After installing the Wazuh UI, the application shows some errors. We need to avoid the generation of these errors, as it leads the user to think the application might have a problem when there is none.

We need to examine the errors shown in the different platforms we support and devise solutions to make the first start more robust.

Error in a clean install in the error app log message page:

image

Related issues:

@gdiazlo gdiazlo added the type/enhancement Enhancement issue label Jun 5, 2022
@gdiazlo gdiazlo moved this to Todo in Release 4.4.0 Jun 5, 2022
@gdiazlo gdiazlo moved this from Todo to Triage in Release 4.4.0 Jun 5, 2022
@gdiazlo gdiazlo removed this from Release 4.4.0 Jun 6, 2022
@gdiazlo gdiazlo moved this to Triage in Release 4.3.5 Jun 6, 2022
@Desvelao Desvelao self-assigned this Jun 6, 2022
@gdiazlo gdiazlo changed the title Error messages on a clean install Error messages on a clean install—error app log messages Jun 6, 2022
@Desvelao
Copy link
Member

Desvelao commented Jun 6, 2022

Research

I was researching the problem, and this could be related to the statistics jobs done by the plugin's backend to index data related to the manager or cluster (depending on if cluster is disabled or not).

Checking the plugin logs, I got:

error: 2022/06/06 8:46:0: cron-scheduler|SaveDocument: resource_already_exists_exception

The log is coming from https://github.com/wazuh/wazuh-kibana-app/blob/c700a23da7054dc8be889199c8c81a6405e39ea3/server/start/cron-scheduler/save-document.ts#L66

The error is caused when trying to create an index that already exists. This error is logged by the plugin.

The statistics plugin job defines 4 jobs:

  • 2 for manager mode
  • 2 for cluster mode

Each job checks the existence of the index before indexing data, and if it doesn't exist, they attempt to create it. These jobs run in parallel and periodically, so there is a race condition here, as when the second job reaches this section of the code, the previous one has already created the index, logging the resource_already_exists_exception message.

Proposed solution

This behavior does not represent an error condition, but a race condition that has no harmful consequences. The most efficient solution would be to solve this race condition using any of the mutual exclusion techniques, but as we won't redesign the jobs for now, the proposed solution is to check the nature of the error and, if it is due to this race condition, then don't log any error, as this behavior is expected due to the current design.

https://github.com/wazuh/wazuh-kibana-app/blob/c700a23da7054dc8be889199c8c81a6405e39ea3/server/start/cron-scheduler/save-document.ts#L45-L69

@jnasselle jnasselle moved this to Triage in Release 4.3.4 Jun 8, 2022
@davidjiglesias davidjiglesias moved this from Triage to Todo in Release 4.3.5 Jun 8, 2022
Desvelao added a commit that referenced this issue Jun 9, 2022
…creating an existent index

The statistics jobs runs in paralell and they try to create the same
index. One of them, runs the request to create the index succesful, but
the other one fails due the index already exists. This error is caught
and logged.

If the error is not related to the index exists, this is thrown and it
is caught and logged in another method related to the statistics job

More information in:
- #4203 (comment)
Desvelao added a commit that referenced this issue Jun 9, 2022
…creating an existent index

The statistics jobs run in parallel and they try to create the same
index. One of them runs the request to create the index successfully, but
the other one fails due to the index already existing. This error is caught
and logged.

If the error is not related to the index exists, this is thrown and it
is caught and logged in another method related to the statistics job

More information in:
- #4203 (comment)
@Desvelao Desvelao moved this from Todo to In progress in Release 4.3.5 Jun 9, 2022
@Desvelao Desvelao moved this from In progress to In review in Release 4.3.5 Jun 9, 2022
@Desvelao
Copy link
Member

Desvelao commented Jun 9, 2022

Solved in #4235.

Desvelao added a commit that referenced this issue Jun 14, 2022
…nt index (#4235)

* fix(statistics): remove the logging when there is an error caused by creating an existent index

The statistics jobs run in parallel and they try to create the same
index. One of them runs the request to create the index successfully, but
the other one fails due to the index already existing. This error is caught
and logged.

If the error is not related to the index exists, this is thrown and it
is caught and logged in another method related to the statistics job

More information in:
- #4203 (comment)

* changelog: add the PR entry

* changelog: fixes Wazuh version and revision

* Update CHANGELOG.md

Co-authored-by: Álex <[email protected]>
Desvelao added a commit that referenced this issue Jun 14, 2022
…nt index (#4235)

* fix(statistics): remove the logging when there is an error caused by creating an existent index

The statistics jobs run in parallel and they try to create the same
index. One of them runs the request to create the index successfully, but
the other one fails due to the index already existing. This error is caught
and logged.

If the error is not related to the index exists, this is thrown and it
is caught and logged in another method related to the statistics job

More information in:
- #4203 (comment)

* changelog: add the PR entry

* changelog: fixes Wazuh version and revision

* Update CHANGELOG.md

Co-authored-by: Álex <[email protected]>
Desvelao added a commit that referenced this issue Jun 14, 2022
…nt index (#4235)

* fix(statistics): remove the logging when there is an error caused by creating an existent index

The statistics jobs run in parallel and they try to create the same
index. One of them runs the request to create the index successfully, but
the other one fails due to the index already existing. This error is caught
and logged.

If the error is not related to the index exists, this is thrown and it
is caught and logged in another method related to the statistics job

More information in:
- #4203 (comment)

* changelog: add the PR entry

* changelog: fixes Wazuh version and revision

* Update CHANGELOG.md

Co-authored-by: Álex <[email protected]>
Repository owner moved this from In review to Done in Release 4.3.5 Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Enhancement issue
Projects
No open projects
Status: Done
2 participants