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

Fix bug running wazuh-cluster process when it was already running #8394

Merged
merged 1 commit into from Apr 28, 2021

Conversation

Selutario
Copy link
Member

Related issue
Closes #7189

Description

Hi team!

There was a bug that leads the Wazuh cluster to stop working until the manager was restarted. If wazuh-clusterd was running and the /var/ossec/bin/wazuh-clusterd was used, the socket was redefined and the process stopped working.

A condition has been added to the wazuh-clusterd.py script in order to check if the process is running before trying to launch it. In that case, the script is exited:

root@wazuh-master:/# /var/ossec/bin/wazuh-clusterd -f
2021/04/27 12:49:59 ERROR: [Cluster] [Main] Cluster is already running.

Regards,
Selu.

@Selutario Selutario self-assigned this Apr 27, 2021
Copy link
Member

@davidjiglesias davidjiglesias left a comment

Choose a reason for hiding this comment

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

Please review possible time increment to start clusterd process with this change.

@Selutario
Copy link
Member Author

Time measurement

The new code block to check if the service is already running:

    cluster_status = wazuh.core.cluster.utils.get_cluster_status()
    if cluster_status['running'] == 'yes':
        main_logger.error("Cluster is already running.")
        sys.exit(1)

The new function takes between 0.0044s and 0.0052s to execute when the condition is not met, which is negligible.

In addition, it is executed after the execution of the configuration test (/var/ossec/bin/wazuh-clusterd -t) so it is not affected/delayed.

Regards,
Selu.

@Selutario Selutario marked this pull request as ready for review April 28, 2021 09:55
@Selutario Selutario force-pushed the fix/7189-rerun-cluster-process branch from faf0ca4 to ed1fe70 Compare April 28, 2021 11:25
@davidjiglesias davidjiglesias merged commit 97f57d8 into master Apr 28, 2021
@davidjiglesias davidjiglesias deleted the fix/7189-rerun-cluster-process branch April 28, 2021 11:52
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 when running wazuh-clusterd with wazuh-clusterd already running
2 participants