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

Debug #1803

Draft
wants to merge 5 commits into
base: release-3.19
Choose a base branch
from
Draft

Debug #1803

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile-constants.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endif

USE_VALGRIND ?= false
ADDRESS_SANITIZER ?= false
CMAKE_BUILD_TYPE ?= Release
CMAKE_BUILD_TYPE ?= Debug
COLLECTOR_APPEND_CID ?= false
PLATFORM ?= linux/amd64
TRACE_SINSP_EVENTS ?= false
Expand Down
1 change: 1 addition & 0 deletions collector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ container/bin/collector: cmake-build/collector
mkdir -p container/bin
cp "$(COLLECTOR_BIN_DIR)/collector" container/bin/collector
cp "$(COLLECTOR_BIN_DIR)/self-checks" container/bin/self-checks
cp "$(COLLECTOR_BIN_DIR)/test/ProcessSignalFormatterTest" container/bin/ProcessSignalFormatterTest

.PHONY: collector
collector: container/bin/collector txt-files
Expand Down
1 change: 1 addition & 0 deletions collector/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ COPY container/THIRD_PARTY_NOTICES/ /THIRD_PARTY_NOTICES/
COPY kernel-modules /kernel-modules
COPY container/bin/collector /usr/local/bin/
COPY container/bin/self-checks /usr/local/bin/self-checks
COPY container/bin/ProcessSignalFormatterTest /usr/local/bin/ProcessSignalFormatterTest
COPY container/status-check.sh /usr/local/bin/status-check.sh

RUN echo "${MODULE_VERSION}" > /kernel-modules/MODULE_VERSION.txt && \
Expand Down
2 changes: 1 addition & 1 deletion collector/container/konflux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ARG BUILD_DIR
ARG SRC_ROOT_DIR=${BUILD_DIR}
ARG CMAKE_BUILD_DIR
# TODO(ROX-20240): CMAKE_BUILD_TYPE should probably not be Release for PR, normal branch builds
ARG CMAKE_BUILD_TYPE=Release
ARG CMAKE_BUILD_TYPE=Debug
# Appends an argument to the driver download URL that is used for filtering alerts on missing kernels.
# TODO(ROX-20240): This needs to be true on PRs only.
ARG COLLECTOR_APPEND_CID=false
Expand Down
2 changes: 1 addition & 1 deletion collector/container/rhel/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eo pipefail

# UBI 9 requires confirmation with -y flag.
microdnf upgrade -y --nobest
microdnf install -y kmod findutils elfutils-libelf
microdnf install -y kmod findutils elfutils-libelf gdb procps

microdnf clean all
rpm --query --all 'curl' '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*' 'findutils' | xargs -t rpm -e --nodeps
Expand Down
3 changes: 3 additions & 0 deletions collector/lib/CollectorConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ BoolEnvVar use_podman_ce("ROX_COLLECTOR_CE_USE_PODMAN", false);

BoolEnvVar enable_introspection("ROX_COLLECTOR_INTROSPECTION_ENABLE", false);

BoolEnvVar disable_process_arguments("ROX_COLLECTOR_NO_PROCESS_ARGUMENTS", false);

} // namespace

constexpr bool CollectorConfig::kTurnOffScrape;
Expand Down Expand Up @@ -87,6 +89,7 @@ void CollectorConfig::InitCollectorConfig(CollectorArgs* args) {
use_docker_ce_ = use_docker_ce.value();
use_podman_ce_ = use_podman_ce.value();
enable_introspection_ = enable_introspection.value();
disable_process_arguments_ = disable_process_arguments.value();

for (const auto& syscall : kSyscalls) {
syscalls_.push_back(syscall);
Expand Down
3 changes: 3 additions & 0 deletions collector/lib/CollectorConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class CollectorConfig {
unsigned int GetSinspBufferSize() const;
unsigned int GetSinspTotalBufferSize() const { return sinsp_total_buffer_size_; }
unsigned int GetSinspThreadCacheSize() const { return sinsp_thread_cache_size_; }
bool DisableProcessArguments() const { return disable_process_arguments_; }

std::shared_ptr<grpc::Channel> grpc_channel;

Expand Down Expand Up @@ -122,6 +123,8 @@ class CollectorConfig {
double connection_stats_error_;
unsigned int connection_stats_window_;

bool disable_process_arguments_ = false;

// One ring buffer will be initialized for this many CPUs
unsigned int sinsp_cpu_per_buffer_ = 0;
// Size of one ring buffer, in bytes.
Expand Down
14 changes: 8 additions & 6 deletions collector/lib/ProcessSignalFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ std::string extract_proc_args(sinsp_threadinfo* tinfo) {

} // namespace

ProcessSignalFormatter::ProcessSignalFormatter(sinsp* inspector) : event_names_(EventNames::GetInstance()), event_extractor_(std::make_unique<system_inspector::EventExtractor>()), container_metadata_(inspector) {
ProcessSignalFormatter::ProcessSignalFormatter(sinsp* inspector, const CollectorConfig& config) : event_names_(EventNames::GetInstance()), event_extractor_(std::make_unique<system_inspector::EventExtractor>()), container_metadata_(inspector), config_(config) {
event_extractor_->Init(inspector);
}

Expand Down Expand Up @@ -135,11 +135,13 @@ ProcessSignal* ProcessSignalFormatter::CreateProcessSignal(sinsp_evt* event) {
signal->set_exec_file_path(name_sanitized ? *name_sanitized : *name);
}

// set process arguments
if (const char* args = event_extractor_->get_proc_args(event)) {
std::string args_str = args;
auto args_sanitized = SanitizedUTF8(args_str);
signal->set_args(args_sanitized ? *args_sanitized : args_str);
// set process arguments, if not explicitely disabled
if (!config_.DisableProcessArguments()) {
if (const char* args = event_extractor_->get_proc_args(event)) {
std::string args_str = args;
auto args_sanitized = SanitizedUTF8(args_str);
signal->set_args(args_sanitized ? *args_sanitized : args_str);
}
}

// set pid
Expand Down
5 changes: 4 additions & 1 deletion collector/lib/ProcessSignalFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "internalapi/sensor/signal_iservice.pb.h"
#include "storage/process_indicator.pb.h"

#include "CollectorConfig.h"
#include "CollectorStats.h"
#include "ContainerMetadata.h"
#include "EventNames.h"
Expand All @@ -25,7 +26,7 @@ namespace collector {

class ProcessSignalFormatter : public ProtoSignalFormatter<sensor::SignalStreamMessage> {
public:
ProcessSignalFormatter(sinsp* inspector);
ProcessSignalFormatter(sinsp* inspector, const CollectorConfig& config);
~ProcessSignalFormatter();

using Signal = v1::Signal;
Expand All @@ -52,6 +53,8 @@ class ProcessSignalFormatter : public ProtoSignalFormatter<sensor::SignalStreamM
const EventNames& event_names_;
std::unique_ptr<system_inspector::EventExtractor> event_extractor_;
ContainerMetadata container_metadata_;

CollectorConfig config_;
};

} // namespace collector
Expand Down
8 changes: 6 additions & 2 deletions collector/lib/ProcessSignalHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <grpcpp/channel.h>

#include "CollectorConfig.h"
#include "ProcessSignalFormatter.h"
#include "RateLimit.h"
#include "SignalHandler.h"
Expand All @@ -19,8 +20,9 @@ namespace collector {

class ProcessSignalHandler : public SignalHandler {
public:
ProcessSignalHandler(sinsp* inspector, ISignalServiceClient* client, system_inspector::Stats* stats)
: client_(client), formatter_(inspector), stats_(stats) {}
ProcessSignalHandler(sinsp* inspector, ISignalServiceClient* client, system_inspector::Stats* stats,
const CollectorConfig& config)
: client_(client), formatter_(inspector, config), stats_(stats), config_(config) {}

bool Start() override;
bool Stop() override;
Expand All @@ -34,6 +36,8 @@ class ProcessSignalHandler : public SignalHandler {
ProcessSignalFormatter formatter_;
system_inspector::Stats* stats_;
RateLimitCache rate_limiter_;

CollectorConfig config_;
};

} // namespace collector
Expand Down
3 changes: 2 additions & 1 deletion collector/lib/system-inspector/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ void Service::Init(const CollectorConfig& config, std::shared_ptr<ConnectionTrac
}
AddSignalHandler(MakeUnique<ProcessSignalHandler>(inspector_.get(),
signal_client_.get(),
&userspace_stats_));
&userspace_stats_,
config));

if (signal_handlers_.size() == 2) {
// self-check handlers do not count towards this check, because they
Expand Down
Loading
Loading