Skip to content

Commit

Permalink
Removes driver downloads and driver candidates (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stringy committed Aug 2, 2024
1 parent 0ebe16e commit 26b423f
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 1,493 deletions.
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";
}
}

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

0 comments on commit 26b423f

Please sign in to comment.