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

Agent centralized configuration #32

Open
Tracked by #22887
vikman90 opened this issue Jul 11, 2024 · 6 comments · Fixed by #223
Open
Tracked by #22887

Agent centralized configuration #32

vikman90 opened this issue Jul 11, 2024 · 6 comments · Fixed by #223
Assignees
Labels

Comments

@vikman90
Copy link
Member

vikman90 commented Jul 11, 2024

Parent issue:

Description

This MVP issue focuses on developing the "Agent centralized configuration command" use case. The agent will utilize the "command manager" component to receive requests from the manager. Two types of request will be:

  • set-group:
    This command should set its group set, and will include one or more groups which the agent belongs to.
  • update-group:
    It indicates that the group-related configuration has changed in the manager.

In both cases, the agent will then respond with the following actions:

  1. Download the related files from the server.
  2. Read them in the order specified by the request and validate them.
  3. Once validated, either apply them to all modules or restart the agent.

Functional requirements

  1. Command Reception:
    • The agent must be able to receive the configuration related requests from the manager through the "command manager" component.
  2. File Download:
    • The agent must download the configuration files listed in the request from the server.
  3. File Reading and Validation:
    • The agent must read the configuration files in the specified order.
    • The agent must validate each configuration file to ensure it is error-free.
  4. Configuration Application:
    • If validation is successful, the agent must apply the new configuration to all relevant modules.
    • If required, the agent must be able to restart to apply the new configuration fully.

Non-functional requirements

  1. Performance:
    The configuration update process should be efficient and not significantly impact the agent’s performance.
  2. Reliability:
    The agent must reliably validate and apply configurations without causing errors or downtime.
  3. Security:
    The agent must securely download configuration files, ensuring they are not tampered with.
  4. Scalability:
    The solution should scale with the number of configuration files and the size of the agent’s environment.

Implementation restrictions

  1. Command-Based Implementation:
    This functionality must be implemented as a command within the agent.
  2. Configuration Format:
    The configuration will be in YAML format, spread across multiple files (one per agent group).
  3. Validation:
    The configuration must be validated before application. The agent should never accept a configuration that produces errors.

Plan

  1. Module Integration:
    Integrate with the existing configuration module to handle the reading and validation of YAML files.
  2. Request Format Definition:
    Define the format for the centralized configuration request to ensure compatibility between the manager and the agent.
  1. Server-Side Implementation:
    Implement the necessary server-side logic to send the update-configuration requests with the appropriate configuration files.
  2. Agent-Side Implementation:
    Implement the agent-side logic to:
  3. Testing and Validation:
    • Thoroughly test the entire workflow to ensure reliability, security, and performance.
    • Validate that the agent correctly handles valid and invalid configurations.
    • Ensure seamless integration with the server-side implementation.

Requirement Traceability Matrix

Requirement Description Plan part DRI
Functional 1 Receive update requests 4 @wazuh/devel-agent
Functional 2 Download config files 2, 3, 4 @wazuh/devel-agent , @wazuh/devel-pyserver
Functional 3 Read and validate config 4 @wazuh/devel-agent
Functional 4 Apply the configuration 1, 4 @wazuh/devel-agent-leaders
@aritosteles
Copy link
Contributor

aritosteles commented Aug 13, 2024

Update

  • (2024/08/13): Understanding the issue requeriments. Reviewing related issues, discussing with team issue details and doubts to deliver to management.
  • (2024/08/14): Putting this issue on hold to work on the Command Manager issue.

@wazuhci wazuhci moved this from Backlog to In progress in Release 5.0.0 Aug 13, 2024
@wazuhci wazuhci moved this from In progress to On hold in Release 5.0.0 Aug 14, 2024
@wazuhci wazuhci moved this from On hold to Backlog in Release 5.0.0 Sep 19, 2024
@wazuhci wazuhci removed this from Release 5.0.0 Sep 30, 2024
@wazuhci wazuhci moved this to Backlog in Release 5.0.0 Oct 1, 2024
@wazuhci wazuhci moved this from Backlog to In progress in Release 5.0.0 Oct 2, 2024
@Nicogp
Copy link
Member

Nicogp commented Oct 3, 2024

(2024/10/02):

  • Understanding the issue requeriments.
  • Review of last changes introduced in command_handler

(2024/10/03):

  • In a first test, I tried to start adding the functionality to the configurationParse module, I discarded the changes.
  • As a second approach, I am thinking about creating a new module to manage those commands.

(2024/10/07):

  • We coordinated with @jr0me the distribution of tasks
  • We made the module structure

(2024/10/08):

  • I started to make the changes to save the group to which the agent belongs, for this the AgentInfo and AgentInfoPersistance class will be used.

(2024/10/09):

  • I finalized the changes to AgentInfo and AgentInfoPersistance, the changes were manually tested and UT performed for each case

(2024/10/10):

  • I started modifications to the httpClient class to support file downloading. So far I have been able to test using http

@jr0me
Copy link
Member

jr0me commented Oct 8, 2024

Update

Discussed with @Nicogp how to start and distribute the work for this issue. We settled for a first approach with the CentralizedConfiguration being a class in the Modules section of the Agent. It will support the requirements to work with the ModuleManager (namely, implement the interface needed by the ModuleWrapper), and it will be configurable to minimize physical dependencies to other components of the Agent.

Branch is in place as https://github.com/wazuh/wazuh-agent/tree/enhancement/32-agent-centralized-configuration-class-mvp

@jr0me
Copy link
Member

jr0me commented Oct 9, 2024

Update

Implementing the ExecuteCommand method for the CentralizedConfiguration.

@jr0me
Copy link
Member

jr0me commented Oct 10, 2024

Update

Implementing setters for the various set-group and update-group handling functions. We want to avoid coupling the centralized configuration to other components like AgentInfo, HttpClient, ConfigurationParser, etc... for this we'll use lambdas as class members that will deal with specifics of each operation without exposing the other classes' details.

@jr0me
Copy link
Member

jr0me commented Oct 14, 2024

Update (October 10th)

Moving on to implement and test the function to set the file downloader. Adjusted functions to the parallel development led by Nico.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

6 participants