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 will operate with its default configuration out of the box #304

Merged
merged 6 commits into from
Nov 15, 2024

Conversation

aritosteles
Copy link
Contributor

@aritosteles aritosteles commented Nov 13, 2024

Related issue
285

Description

This PR aims to allow the agent to use default settings in case some or all settings are not specified in the configuration file or if the configuration file does not exist.

Configuration options

Logs/Alerts example

Tests

  • Compilation without warnings in every supported platform
    • Linux
    • Windows
    • MAC OS X

@aritosteles aritosteles force-pushed the enhancement/285-default-settings branch 2 times, most recently from 3d9a378 to 5b8ca1f Compare November 14, 2024 13:25
Copy link
Member

@jr0me jr0me left a comment

Choose a reason for hiding this comment

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

I'm not sure about the choice of interface for the default value, we are passing it all the way down to the configuration parser only to get it back if it can't find the requested key.

There's a similar end user case that you could achieve by changing the returned type to an optional, see https://en.cppreference.com/w/cpp/utility/optional/value_or .

Instead of T GetConfig(T defaultValue, Keys... keys) const and passing the default value all the way down, you can do std::optional<T> GetConfig(Keys... keys) and when used configurationParser.GetConfig<int>("table", "key").value_or(DEFAULT_VALUE_FOR_KEY).

src/cmake/config.cmake Show resolved Hide resolved
src/modules/inventory/src/inventory.cpp Outdated Show resolved Hide resolved
src/agent/src/agent_registration.cpp Show resolved Hide resolved
@aritosteles aritosteles force-pushed the enhancement/285-default-settings branch from 5b8ca1f to c9a3b11 Compare November 14, 2024 22:52
@aritosteles aritosteles marked this pull request as ready for review November 14, 2024 22:53
@aritosteles aritosteles requested a review from jr0me November 14, 2024 22:53
src/cmake/config.cmake Outdated Show resolved Hide resolved
constexpr auto DEFAULT_RELOAD_INTERVAL = @DEFAULT_RELOAD_INTERVAL@;
namespace logcollector
{
constexpr auto BUFFER_SIZE = @BUFFER_SIZE@;
Copy link
Member

Choose a reason for hiding this comment

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

Note: In the future we need to evaluate if this setting should also be included in the wazuh-agent.yml file.

@aritosteles aritosteles force-pushed the enhancement/285-default-settings branch 2 times, most recently from 168cca8 to b5c3682 Compare November 15, 2024 15:34
@aritosteles aritosteles force-pushed the enhancement/285-default-settings branch from b5c3682 to c53ec86 Compare November 15, 2024 15:47
Copy link
Member

@jr0me jr0me left a comment

Choose a reason for hiding this comment

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

LGTM

@TomasTurina TomasTurina merged commit e0ba259 into master Nov 15, 2024
5 checks passed
@TomasTurina TomasTurina deleted the enhancement/285-default-settings branch November 15, 2024 17:31
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.

Critical Error at Agent Startup Due to Missing retry_interval_secs Key in Default Configuration
3 participants