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

Run collector in ‘standalone’ mode #852

Open
Molter73 opened this issue Oct 3, 2022 · 0 comments
Open

Run collector in ‘standalone’ mode #852

Molter73 opened this issue Oct 3, 2022 · 0 comments

Comments

@Molter73
Copy link
Collaborator

Molter73 commented Oct 3, 2022

Right now collector requires a gRPC server for it to run, when we need to debug an issue we have to either:

  • Deploy it alongside a full StackRox deployment.
  • Deploy it with a mock gRPC server that mocks sensor’s behaviour

It’d be great if we could directly run the collector binary without any external requirements, since it would make debugging quick changes a lot faster (compile the binary and run vs. compile, create the image, setup the environment, deploy the image with the change, etc.).

In order to get this done, the first requirement would be to make the grpc connection optional:

if (!useGRPC) {
CLOG(INFO) << "GRPC is disabled. Specify GRPC_SERVER='server addr' env and signalFormat = 'signal_summary' and signalOutput = 'grpc'";
}
std::shared_ptr<grpc::Channel> grpc_channel;
if (useGRPC) {
grpc_channel = createChannel(args);
}
config.grpc_channel = std::move(grpc_channel);

I believe there are some checks in the configuration that also fail and prevent collector from running but I can’t find the exact place, it’s in either of these files:
https://github.com/stackrox/collector/blob/master/collector/lib/CollectorArgs.cpp
https://github.com/stackrox/collector/blob/master/collector/lib/CollectorConfig.cpp

We also want to keep the behavior of running with the GRPC server to still be the default, so any changes need to be placed behind a feature flag, an environment variable like COLLECTOR_STANDALONE set to a none empty string would be nice. Here is an example on how we handle these flags:

const char* GetModuleDownloadBaseURL() {
const char* module_download_base_url = std::getenv("MODULE_DOWNLOAD_BASE_URL");
if (module_download_base_url && *module_download_base_url) return module_download_base_url;
CLOG(DEBUG) << "MODULE_DOWNLOAD_BASE_URL not set";
return "";
}

The final step would be to adjust the signal handlers we currently have to either be ignored or print to stdout. I think the easiest way would be to create a new signal handler and set it here:

if (conn_tracker) {
AddSignalHandler(MakeUnique<NetworkSignalHandler>(inspector_.get(), conn_tracker, &userspace_stats_));
}
if (config.grpc_channel) {
AddSignalHandler(MakeUnique<ProcessSignalHandler>(inspector_.get(), config.grpc_channel, &userspace_stats_));
}

For a first implementation, a signal handler printing process information to stdout would be nice and the network signal can be directly turned off when running in standalone, leaving its implementation for a follow up.

We have instructions on running the collector-builder image as a development environment in our how to start guide, running the collector binary directly in that container without any companion containers is the end goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant