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

Token variable is empty in manager check #44

Closed
davidcr01 opened this issue Aug 30, 2024 · 0 comments · Fixed by #45
Closed

Token variable is empty in manager check #44

davidcr01 opened this issue Aug 30, 2024 · 0 comments · Fixed by #45
Assignees
Labels
level/task Task issue type/bug Bug issue

Comments

@davidcr01
Copy link
Contributor

davidcr01 commented Aug 30, 2024

Description

Related:

In the #20 and wazuh/wazuh-virtual-machines#20, we have observed that the Wazuh AIO installation is failing:

  "30/08/2024 09:55:12 INFO: Starting service wazuh-manager.",
  "Created symlink from /etc/systemd/system/multi-user.target.wants/wazuh-manager.service to /usr/lib/systemd/system/wazuh-manager.service.",
  "30/08/2024 09:55:23 INFO: wazuh-manager service started.",
  "30/08/2024 09:55:23 INFO: Checking Wazuh API connection",
  "30/08/2024 09:55:23 ERROR: Wazuh API connection Error. ",
  "wazuh-clusterd not running...",
  "wazuh-modulesd is running...",
  "wazuh-monitord is running...",
  "wazuh-logcollector is running...",
  "wazuh-remoted is running...",
  "wazuh-syscheckd is running...",
  "wazuh-analysisd is running...",
  "wazuh-maild not running...",
  "wazuh-execd is running...",
  "wazuh-db is running...",
  "wazuh-authd is running...",
  "wazuh-agentlessd not running...",
  "wazuh-integratord not running...",
  "wazuh-dbd not running...",
  "wazuh-csyslogd not running...",
  "wazuh-apid is running...",
  "30/08/2024 09:55:23 INFO: --- Removing existing Wazuh installation ---",

Note

This behavior seems to be random, and independent from the chosen OS.

After debugging this problem, we have detected that the TOKEN variable used to call the Wazuh API to check the status is empty:

++ curl -k -s -X GET 'https://127.0.0.1:55000/agents/outdated?pretty=true' -H 'Authorization: Bearer '\n+ wm_error=\n+ [[ '' =~ \"error\": 0 ]]\n+ common_logger -e 'Wazuh API connection Error

Probably, it has no value because the assistant calls the API immediately after starting the manager, and surely the API is not yet ready to receive requests, the TOKEN remains empty and the Wazuh API check fails.

Approach

A possible workaround is to ensure that the TOKEN variable is not empty before calling the Wazuh API, and perform several calls to the API to fetch the TOKEN until the Wazuh API is ready.

@davidcr01 davidcr01 added level/task Task issue type/bug Bug issue labels Aug 30, 2024
@davidcr01 davidcr01 self-assigned this Aug 30, 2024
@wazuhci wazuhci moved this to In progress in Release 4.9.0 Aug 30, 2024
@wazuhci wazuhci moved this to In progress in Release 4.10.0 Aug 30, 2024
@wazuhci wazuhci removed this from Release 4.9.0 Aug 30, 2024
@wazuhci wazuhci moved this from In progress to Pending review in Release 4.10.0 Aug 30, 2024
@teddytpc1 teddytpc1 linked a pull request Sep 2, 2024 that will close this issue
@c-bordon c-bordon closed this as completed Sep 2, 2024
@wazuhci wazuhci moved this from Pending review to Done in Release 4.10.0 Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/bug Bug issue
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants