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

Removes driver downloads and driver candidates #1770

Merged
merged 2 commits into from
Aug 2, 2024
Merged
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: 0 additions & 2 deletions collector/collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ extern "C" {
#include "CollectorStatsExporter.h"
#include "Control.h"
#include "Diagnostics.h"
#include "DriverCandidates.h"
#include "EventNames.h"
#include "FileSystem.h"
#include "GRPC.h"
#include "GRPCUtil.h"
#include "GetKernelObject.h"
#include "GetStatus.h"
#include "HostInfo.h"
#include "LogLevel.h"
Expand Down
17 changes: 14 additions & 3 deletions collector/lib/CollectionMethod.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#include "CollectionMethod.h"

#include <sstream>

#include <sys/types.h>

#include "Logging.h"

namespace collector {

std::ostream& operator<<(std::ostream& os, CollectionMethod method) {
return os << CollectionMethodName(method);
}

const char* CollectionMethodName(CollectionMethod method) {
switch (method) {
case CollectionMethod::EBPF:
return os << "ebpf";
return "ebpf";
case CollectionMethod::CORE_BPF:
return os << "core_bpf";
return "core_bpf";
default:
return os << "unknown(" << static_cast<uint8_t>(method) << ")";
CLOG(WARNING) << "Unexpected CollectionMethod: " << static_cast<uint8_t>(method);
return "unknown";
Comment on lines +22 to +23
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would argue ERROR is a more appropriate severity, since we are not going to be able to continue working with an invalid collection method. I would go as far as to go into FATAL, but I'm an extremist.

Copy link
Collaborator Author

@Stringy Stringy Aug 2, 2024

Choose a reason for hiding this comment

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

Yeah I went for a warning just due to the function's purpose -- other parts of the codebase can be a bit more strict about validating the collection method (in fact in CollectorConfig.cpp it's switching to CORE_BPF on an invalid method, so I think we're safe)

}
}

Expand Down
3 changes: 2 additions & 1 deletion collector/lib/CollectionMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ namespace collector {
enum class CollectionMethod : uint8_t {
EBPF = 0,
CORE_BPF,

};

std::ostream& operator<<(std::ostream& os, CollectionMethod method);

const char* CollectionMethodName(CollectionMethod method);

} // namespace collector

#endif // COLLECTION_METHOD_H
34 changes: 8 additions & 26 deletions collector/lib/CollectorService.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "CollectorService.h"

#include "CollectionMethod.h"
#include "ContainerInfoInspector.h"

extern "C" {
Expand All @@ -14,7 +15,6 @@ extern "C" {
#include "Containers.h"
#include "Diagnostics.h"
#include "GRPCUtil.h"
#include "GetKernelObject.h"
#include "GetStatus.h"
#include "LogLevel.h"
#include "NetworkStatusInspector.h"
Expand Down Expand Up @@ -138,8 +138,8 @@ void CollectorService::RunForever() {
system_inspector_.CleanUp();
}

bool CollectorService::InitKernel(const DriverCandidate& candidate) {
return system_inspector_.InitKernel(config_, candidate);
bool CollectorService::InitKernel() {
return system_inspector_.InitKernel(config_);
}

bool CollectorService::WaitForGRPCServer() {
Expand All @@ -150,31 +150,13 @@ bool CollectorService::WaitForGRPCServer() {

bool SetupKernelDriver(CollectorService& collector, const std::string& GRPCServer, const CollectorConfig& config) {
auto& startup_diagnostics = StartupDiagnostics::GetInstance();
std::string cm_name(CollectionMethodName(config.GetCollectionMethod()));

std::vector<DriverCandidate> candidates = GetKernelCandidates(config.GetCollectionMethod());
if (candidates.empty()) {
CLOG(ERROR) << "No kernel candidates available";
return false;
}

CLOG(INFO) << "Candidate drivers: ";
for (const auto& candidate : candidates) {
CLOG(INFO) << candidate.GetName();
}
startup_diagnostics.DriverAvailable(cm_name);

for (const auto& candidate : candidates) {
if (!GetKernelObject(GRPCServer, config.TLSConfiguration(), candidate, config.CurlVerbose())) {
CLOG(WARNING) << "No suitable kernel object downloaded for " << candidate.GetName();
startup_diagnostics.DriverUnavailable(candidate.GetName());
continue;
}

startup_diagnostics.DriverAvailable(candidate.GetName());

if (collector.InitKernel(candidate)) {
startup_diagnostics.DriverSuccess(candidate.GetName());
return true;
}
if (collector.InitKernel()) {
startup_diagnostics.DriverSuccess(cm_name);
return true;
}

CLOG(ERROR) << "Failed to initialize collector kernel components.";
Expand Down
3 changes: 1 addition & 2 deletions collector/lib/CollectorService.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "CollectorConfig.h"
#include "Control.h"
#include "DriverCandidates.h"
#include "system-inspector/Service.h"

namespace collector {
Expand All @@ -14,7 +13,7 @@ class CollectorService {

void RunForever();

bool InitKernel(const DriverCandidate& candidate);
bool InitKernel();

private:
bool WaitForGRPCServer();
Expand Down
195 changes: 0 additions & 195 deletions collector/lib/DriverCandidates.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions collector/lib/DriverCandidates.h

This file was deleted.

Loading
Loading