Closed AlexRuiz7 closed 1 year ago
In the current plugin there is some methods that are being reused:
Management/Configuration/Edit configuration
: Restart <node_name>
/ Restart manager
Restart selected manager node: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/configuration/utils/wz-fetch.js#L270-L287 Restart manager: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/configuration/utils/wz-fetch.js#L293-L309
Restart cluster or manager: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/configuration/utils/wz-fetch.js#L528-L549
:warning: this could be similar to another method. We should review if we could unify the behavior.
For another hand, there is another logic used by Management/Status
that restarts the manager/cluster.
Restart manager: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/status/actions-buttons-main.js#L97-L117
Restart cluster: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/status/actions-buttons-main.js#L68-L92
We could try to refactor to use the same service/functions and unify the behavior.
Possible tasks:
Because of Wazuh 4.4.0 could only exist the cluster mode, we would need to remove logic to control when is in manager/cluster mode, we will have to refactor some methods to restart the cluster nodes or cluster, so we could do this refactor for that Wazuh version.
these functions were moved to a service to handle the restarting (wz-restart.js)
restartManager and restartCluster were changed by 1 function restart
Restart selected manager node: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/configuration/utils/wz-fetch.js#L270-L287
Restart cluster or manager: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/configuration/utils/wz-fetch.js#L528-L549
Change
For another hand, there is another logic used by Management/Status
that restarts the manager/cluster.
The 2 functions were eliminated as they were doing the same things and we started using the created service
Change
Restart manager: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/status/actions-buttons-main.js#L97-L117
Restart cluster: https://github.com/wazuh/wazuh-kibana-app/blob/v4.3.4-7.10.2/public/controllers/management/components/management/status/actions-buttons-main.js#L68-L92
and it is also called in the file restart-cluster-manager-callout.tsx
~Blocked by https://github.com/wazuh/wazuh/issues/14776~ Blocked by https://github.com/wazuh/wazuh/issues/14918
Closed until priorities change
Related issue: #4181
Description
To follow the discussion on issue #4181, we need to centralize the restart of Wazuh using a React service or component, so any view of the App will be able to restart the environment in the same way.
Restrictions and considerations
In cluster mode, a delay of at least 15 seconds needs to be applied when a cluster restart is immediately triggered after changing the ruleset files, in order to allow the cluster to synchronize the changes along the nodes. This is the safety time the Framework team told us to use. For a detailed explanation, head to the Wazuh Cluster documentation.
It's possible that Wazuh will only exist as a cluster in the future, and the single-instance mode will exist as a single-node cluster instead. Take this in EXTRAORDINARY consideration during design and coding, so we can easily adjust this service if this eventually happens.
Requirements
Design
Flow
The current flow to restart Wazuh has been modeled in the following activity diagram:
Outdated.- Reason: delay to restart the cluster is no longer required. Note: rev.2 - Last updated: Thu, 04 Aug 2022 13:40:42 +0200
User Interface
Note: be aware the UI design might change over time, do not take this design as final, unless explicitly specified so.
New, custom, UI components will be needed. We'll work on a PoC using several built-in components from EUI, which will include:
A modal-like element to display the restart status. We'll use the EUI Empty prompt component.
An overlay mask component, used to move the focus to the modal, block user interaction and reinforce the feeling of a task that takes some time to complete.
A progress bar. There are two options here: a) countdown, starting at _delay totalattempts (2 30), and updated each second. b) current attempt, starting at 0 until _totalattempts (30), and updated on each attempt. We need to discuss which design we like the most. Option B Note: the progress bar will only reach 0% (option A) or 100% (option B) in the worst case scenario. Wazuh should be completely restarted before this happens.
Preview
Work in progress
This is a demo for the desired design: https://codesandbox.io/s/wazuh-restart-forked-7mnxj1?file=/demo.js