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

ROX-26344: adds runtime configuration to collector #1866

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

Stringy
Copy link
Collaborator

@Stringy Stringy commented Sep 26, 2024

Description

Includes support for enabling/disabling external IPs based on runtime config, deferring to existing feature flag if none is provided

In subsequent PRs, the runtime configuration will be populated.

Checklist

  • Investigated and inspected CI test results
    - [x] Updated documentation accordingly

Automated testing

  • Added unit tests
    - [ ] Added integration tests
    - [ ] Added regression tests

If any of these don't apply, please comment below.

Testing Performed

Unit tests added to exercise the intended behaviour. It is not possible to integration-test this until Sensor->Collector communication has been built.

Includes support for enabling/disabling external IPs
based on runtime config, deferring to existing feature
flag if none is provided
@Stringy Stringy requested a review from a team as a code owner September 26, 2024 09:40
Copy link
Contributor

@ovalenti ovalenti left a comment

Choose a reason for hiding this comment

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

Using the CollectorConfig object makes sense, good idea !

I think that the next steps should be:

  • on the Sensor side:
    • Update the proto defs to introduce an enum type wrapping and replacing NetworkFlowsControlMessage
    • introduce the runtime-config object in the new enum
    • implement a switch-case in NetworkStatusNotifier in onRecvControlMessage or its successor
    • when receiving a runtime-config in the new switch-case, update the value in CollectorConfig
  • on the ConnTracker side:
    • everytime we start a scrape in either NetworkStatusNotifier::RunSingle or NetworkStatusNotifier::RunSingleAfterglow, set the ExtIP attribute using ConnectionTracker::EnableExternalIPs

Copy link
Contributor

@ovalenti ovalenti left a comment

Choose a reason for hiding this comment

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

As discussed previously and in #11746 , we should remember to unify the names of the environment variables that enable the ExtIP feature.

BoolEnvVar enable_external_ips("ROX_ENABLE_EXTERNAL_IPS", false);

I think that it would make sense to update CollectorConfig's env var name to match the one in Central (ROX_EXTERNAL_IPS) as part of this PR.

@ovalenti ovalenti dismissed their stale review September 26, 2024 14:10

The proposed change has been made, thanks !

collector/lib/CollectorConfig.h Show resolved Hide resolved
runtime_config_ = std::move(runtime_config);
}

std::optional<sensor::CollectorConfig> GetRuntimeConfig() const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets not copy the object every time it's accessed.

Suggested change
std::optional<sensor::CollectorConfig> GetRuntimeConfig() const {
const std::optional<sensor::CollectorConfig>& GetRuntimeConfig() const {

collector/lib/CollectorConfig.h Show resolved Hide resolved
@@ -47,7 +47,7 @@ BoolEnvVar set_import_users("ROX_COLLECTOR_SET_IMPORT_USERS", false);

BoolEnvVar collect_connection_status("ROX_COLLECT_CONNECTION_STATUS", true);

BoolEnvVar enable_external_ips("ROX_ENABLE_EXTERNAL_IPS", false);
BoolEnvVar enable_external_ips("ROX_EXTERNAL_IPS", false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually think the ENABLE makes it clearer what the env variable is for. But I would argue a variable in the form <PROGRAM>_<FEATURE>_<PARAM> is even more clear, so in this case we might want to name the variable ROX_EXTERNAL_IPS_ENABLE or ROX_COLLECTOR_EXTERNAL_IPS_ENABLE

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In general I think I agree. @ovalenti what do you think? should we update the central feature flag?

Copy link
Contributor

@ovalenti ovalenti Sep 27, 2024

Choose a reason for hiding this comment

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

In Central, it looks like the convention is to use short names and no verb... https://github.com/stackrox/stackrox/blob/0b83c7607cb58d28e0165e20936f30d0c11d12c0/pkg/features/list.go

Although unifying the flag names seemed like a good idea at first, the collector one is likely not going to be used directly by any customer. So I am starting to think that we could keep the names as they were, or as Mauro suggests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think ENABLE is needed in the name. In stackrox/stackrox the function to check the value of feature flags is Enable(), so it would seem to be redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In stackrox/stackrox the function to check the value of feature flags is Enable(), so it would seem to be redundant.

It wouldn't be redundant to a user that is trying to configure collector without any knowledge of what the code in the main repo looks like 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will revert this for now and we can decide on naming conventions later on

Copy link
Contributor

@JoukoVirtanen JoukoVirtanen left a comment

Choose a reason for hiding this comment

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

Approving, but before merging update the stackrox/stackrox submodule as I merged the internal protobuf definitions. Also get approvals from others before merging.

@Stringy Stringy requested a review from Molter73 October 1, 2024 08:17
Copy link
Collaborator

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +87 to +89
const auto& cfg = runtime_config_.value();
const auto& network_cfg = cfg.network_connection_config();
return network_cfg.enable_external_ips();
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could've also done something like...

return runtime_config_.value()
  .network_connection_config()
  .enable_external_ips();

But meh, this is good too.

@Stringy Stringy merged commit d7ceed3 into master Oct 1, 2024
49 of 51 checks passed
@Stringy Stringy deleted the giles/ROX-26344-integrate-runtime-config branch October 1, 2024 10:18
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.

4 participants