Skip to content
Open
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
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ gazelle(
# gazelle:resolve go px.dev/pixie/src/carnot/planner/compilerpb //src/carnot/planner/compilerpb:compiler_status_pl_go_proto
# gazelle:resolve go px.dev/pixie/src/carnot/planner/distributedpb //src/carnot/planner/distributedpb:distributed_plan_pl_go_proto
# gazelle:resolve go px.dev/pixie/src/carnot/planner/file_source/ir //src/carnot/planner/file_source/ir:logical_pl_go_proto
# gazelle:resolve go px.dev/pixie/src/carnot/planner/tetragon/ir //src/carnot/planner/tetragon/ir:logical_pl_go_proto
# gazelle:resolve go px.dev/pixie/src/carnot/planner/dynamic_tracing/ir/logicalpb //src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_go_proto
# gazelle:resolve go px.dev/pixie/src/carnot/planner/plannerpb //src/carnot/planner/plannerpb:service_pl_go_proto
# gazelle:resolve go px.dev/pixie/src/carnot/planpb //src/carnot/planpb:plan_pl_go_proto
Expand Down
1 change: 1 addition & 0 deletions src/carnot/planner/compiler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pl_cc_library(
"//src/carnot/planner/compiler_error_context:cc_library",
"//src/carnot/planner/compiler_state:cc_library",
"//src/carnot/planner/file_source:cc_library",
"//src/carnot/planner/tetragon:cc_library",
"//src/carnot/planner/ir:cc_library",
"//src/carnot/planner/metadata:cc_library",
"//src/carnot/planner/objects:cc_library",
Expand Down
2 changes: 2 additions & 0 deletions src/carnot/planner/compiler/ast_visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Status ASTVisitorImpl::SetupModules(
TraceModule::Create(mutations_, this));
PX_ASSIGN_OR_RETURN((*module_handler_)[LogModule::kLogModuleObjName],
LogModule::Create(mutations_, this));
PX_ASSIGN_OR_RETURN((*module_handler_)[TetragonModule::kTetragonModuleObjName],
TetragonModule::Create(mutations_, this));
PX_ASSIGN_OR_RETURN((*module_handler_)[ConfigModule::kConfigModuleObjName],
ConfigModule::Create(mutations_, this));
for (const auto& [module_name, module_text] : module_name_to_pxl_map) {
Expand Down
1 change: 1 addition & 0 deletions src/carnot/planner/compiler/ast_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "src/carnot/planner/ast/ast_visitor.h"
#include "src/carnot/planner/compiler_state/compiler_state.h"
#include "src/carnot/planner/file_source/log_module.h"
#include "src/carnot/planner/tetragon/tetragon_module.h"
#include "src/carnot/planner/ir/ast_utils.h"
#include "src/carnot/planner/ir/ir.h"
#include "src/carnot/planner/objects/dataframe.h"
Expand Down
3 changes: 3 additions & 0 deletions src/carnot/planner/plannerpb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pl_proto_library(
"//src/carnot/planner/distributedpb:distributed_plan_pl_proto",
"//src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_proto",
"//src/carnot/planner/file_source/ir:logical_pl_proto",
"//src/carnot/planner/tetragon/ir:logical_pl_proto",
"//src/carnot/planpb:plan_pl_proto",
"//src/common/base/statuspb:status_pl_proto",
"//src/shared/types/typespb:types_pl_proto",
Expand All @@ -44,6 +45,7 @@ pl_cc_proto_library(
"//src/carnot/planner/distributedpb:distributed_plan_pl_cc_proto",
"//src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_cc_proto",
"//src/carnot/planner/file_source/ir:logical_pl_cc_proto",
"//src/carnot/planner/tetragon/ir:logical_pl_cc_proto",
"//src/carnot/planpb:plan_pl_cc_proto",
"//src/common/base/statuspb:status_pl_cc_proto",
"//src/shared/types/typespb/wrapper:cc_library",
Expand All @@ -59,6 +61,7 @@ pl_go_proto_library(
"//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
"//src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_go_proto",
"//src/carnot/planner/file_source/ir:logical_pl_go_proto",
"//src/carnot/planner/tetragon/ir:logical_pl_go_proto",
"//src/carnot/planpb:plan_pl_go_proto",
"//src/common/base/statuspb:status_pl_go_proto",
"//src/shared/types/typespb:types_pl_go_proto",
Expand Down
9 changes: 9 additions & 0 deletions src/carnot/planner/plannerpb/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ option go_package = "plannerpb";

import "src/carnot/planner/dynamic_tracing/ir/logicalpb/logical.proto";
import "src/carnot/planner/file_source/ir/logical.proto";
import "src/carnot/planner/tetragon/ir/logical.proto";
import "src/common/base/statuspb/status.proto";
import "gogoproto/gogo.proto";
import "src/carnot/planner/distributedpb/distributed_plan.proto";
Expand Down Expand Up @@ -135,6 +136,11 @@ message DeleteFileSource {
string glob_pattern = 1;
}

message DeleteTetragon {
// The glob pattern to use to find files to read. Also doubles as the name of the tetragon log file.
string glob_pattern = 1;
}

// The definition of a mutation to perfom on Vizier. Mutations include operations
// that add and delete tables to the database.
message CompileMutation {
Expand All @@ -150,6 +156,9 @@ message CompileMutation {
carnot.planner.file_source.ir.FileSourceDeployment file_source = 5;
// Mutation that deletes a file source/poller
DeleteFileSource delete_file_source = 6;
carnot.planner.tetragon.ir.TetragonDeployment tetragon = 7;
// Mutation that deletes a tetragon/poller
DeleteTetragon delete_tetragon = 8;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/carnot/planner/probes/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pl_cc_library(
deps = [
"//src/carnot/planner/dynamic_tracing/ir/logicalpb:logical_pl_cc_proto",
"//src/carnot/planner/file_source/ir:logical_pl_cc_proto",
"//src/carnot/planner/tetragon/ir:logical_pl_cc_proto",
"//src/carnot/planner/objects:cc_library",
"//src/common/uuid:cc_library",
],
Expand Down
28 changes: 28 additions & 0 deletions src/carnot/planner/probes/probes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ Status MutationsIR::ToProto(plannerpb::CompileMutationsResponse* pb) {
*(pb->add_mutations()->mutable_file_source()) = file_source;
}

for (const auto& tetragon_to_delete : TetragonsToDelete()) {
pb->add_mutations()->mutable_delete_tetragon()->set_glob_pattern(tetragon_to_delete);
}

for (const auto& tetragon : tetragon_deployments_) {
*(pb->add_mutations()->mutable_tetragon()) = tetragon;
}

return Status::OK();
}

Expand All @@ -329,6 +337,26 @@ void MutationsIR::CreateFileSourceDeployment(const std::string& glob_pattern,
file_source_deployments_.push_back(file_source);
}

std::vector<tetragon::ir::TetragonDeployment> MutationsIR::TetragonDeployments() {
std::vector<tetragon::ir::TetragonDeployment> tetragon_deployments;
for (size_t i = 0; i < tetragon_deployments_.size(); i++) {
tetragon_deployments.push_back(tetragon_deployments_[i]);
}
return tetragon_deployments;
}

void MutationsIR::CreateTetragonDeployment(const std::string& glob_pattern,
const std::string& table_name, int64_t ttl_ns) {
tetragon::ir::TetragonDeployment tetragon;
tetragon.set_name(glob_pattern);
tetragon.set_glob_pattern(glob_pattern);
tetragon.set_table_name(table_name);
auto one_sec = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(1));
tetragon.mutable_ttl()->set_seconds(ttl_ns / one_sec.count());
tetragon.mutable_ttl()->set_nanos(ttl_ns % one_sec.count());
tetragon_deployments_.push_back(tetragon);
}

} // namespace compiler
} // namespace planner
} // namespace carnot
Expand Down
39 changes: 38 additions & 1 deletion src/carnot/planner/probes/probes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "src/carnot/planner/dynamic_tracing/ir/logicalpb/logical.pb.h"
#include "src/carnot/planner/file_source/ir/logical.pb.h"
#include "src/carnot/planner/tetragon/ir/logical.pb.h"
#include "src/carnot/planner/objects/funcobject.h"
#include "src/carnot/planner/plannerpb/service.pb.h"
#include "src/carnot/planner/probes/label_selector_target.h"
Expand Down Expand Up @@ -181,6 +182,20 @@ class FileSourceDeployment {
int64_t ttl_ns_;
};

class TetragonDeployment {
public:
TetragonDeployment(const std::string& glob_pattern, const std::string& table_name,
int64_t ttl_ns)
: glob_pattern_(glob_pattern), table_name_(table_name), ttl_ns_(ttl_ns) {}

Status ToProto(tetragon::ir::TetragonDeployment pb) const;

private:
std::string glob_pattern_;
std::string table_name_;
int64_t ttl_ns_;
};

class TracepointDeployment {
public:
TracepointDeployment(const std::string& trace_name, int64_t ttl_ns)
Expand Down Expand Up @@ -244,6 +259,12 @@ class MutationsIR {
int64_t ttl_ns);

void CreateDeleteFileSource(const std::string& glob_pattern);

void CreateTetragonDeployment(const std::string& glob_pattern, const std::string& table_name,
int64_t ttl_ns);

void CreateDeleteTetragon(const std::string& glob_pattern);

/**
* @brief Create a TraceProgram for the MutationsIR w/ the specified UPID.
*
Expand Down Expand Up @@ -363,7 +384,20 @@ class MutationsIR {

const std::vector<std::string>& FileSourcesToDelete() { return file_sources_to_delete_; }

private:
std::vector<tetragon::ir::TetragonDeployment> TetragonDeployments();

/**
* @brief Deletes the tetragon log passed in.
*
* @param tetragon_to_delete
*/
void DeleteTetragon(const std::string& tetragon_to_delete) {
tetragons_to_delete_.push_back(tetragon_to_delete);
}

const std::vector<std::string>& TetragonsToDelete() { return tetragons_to_delete_; }

private:
// All the new tracepoints added as part of this mutation. DeploymentSpecs are protobufs because
// we only modify these upon inserting the new tracepoint, while the Tracepoint definition is
// still modified aftered adding the tracepoint.
Expand All @@ -383,6 +417,9 @@ class MutationsIR {

std::vector<file_source::ir::FileSourceDeployment> file_source_deployments_;
std::vector<std::string> file_sources_to_delete_;

std::vector<tetragon::ir::TetragonDeployment> tetragon_deployments_;
std::vector<std::string> tetragons_to_delete_;
};

} // namespace compiler
Expand Down
6 changes: 6 additions & 0 deletions src/carnot/planner/probes/tracepoint_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "src/carnot/planner/dynamic_tracing/ir/logicalpb/logical.pb.h"
#include "src/carnot/planner/file_source/ir/logical.pb.h"
#include "src/carnot/planner/tetragon/ir/logical.pb.h"

namespace px {
namespace carnot {
Expand Down Expand Up @@ -83,6 +84,11 @@ StatusOr<file_source::ir::FileSourceDeployment> CompileFileSource(std::string_vi
return pb.mutations()[0].file_source();
}

StatusOr<tetragon::ir::TetragonDeployment> CompileTetragon(std::string_view query) {
PX_ASSIGN_OR_RETURN(auto pb, CompileMutations(query));
return pb.mutations()[0].tetragon();
}

} // namespace compiler
} // namespace planner
} // namespace carnot
Expand Down
6 changes: 6 additions & 0 deletions src/carnot/planner/probes/tracepoint_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ StatusOr<carnot::planner::dynamic_tracing::ir::logical::TracepointDeployment> Co
*/
StatusOr<file_source::ir::FileSourceDeployment> CompileFileSource(std::string_view query);

/**
* Take a tetragon log specification in PXL format, and compiles it to a logical tetragon log
* deployment.
*/
StatusOr<tetragon::ir::TetragonDeployment> CompileTetragon(std::string_view query);

} // namespace compiler
} // namespace planner
} // namespace carnot
Expand Down
52 changes: 52 additions & 0 deletions src/carnot/planner/tetragon/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:pl_build_system.bzl", "pl_cc_binary", "pl_cc_library", "pl_cc_test")

package(default_visibility = [
"//src/carnot:__subpackages__",
"//src/experimental/standalone_pem:__subpackages__", # TODO(ddelnano): Is this needed?
])

pl_cc_library(
name = "cc_library",
srcs = glob(
[
"*.cc",
"*.h",
],
exclude = [
"**/*_test.cc",
"**/*_test_utils.h",
],
),
hdrs = ["tetragon.h"],
deps = [
"//src/carnot/planner/objects:cc_library",
"//src/carnot/planner/probes:cc_library",
"//src/common/uuid:cc_library", # TODO(ddelnano): This may not be needed
],
)

pl_cc_test(
name = "tetragon_test",
srcs = ["tetragon_test.cc"],
deps = [
":cc_library",
"//src/carnot/planner:test_utils",
"//src/carnot/planner/compiler:cc_library",
],
)
41 changes: 41 additions & 0 deletions src/carnot/planner/tetragon/ir/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:proto_compile.bzl", "pl_cc_proto_library", "pl_go_proto_library", "pl_proto_library")

package(default_visibility = ["//src:__subpackages__"])

pl_proto_library(
name = "logical_pl_proto",
srcs = ["logical.proto"],
deps = [
"@gogo_grpc_proto//gogoproto:gogo_pl_proto",
],
)

pl_cc_proto_library(
name = "logical_pl_cc_proto",
proto = ":logical_pl_proto",
deps = [
"@gogo_grpc_proto//gogoproto:gogo_pl_cc_proto",
],
)

pl_go_proto_library(
name = "logical_pl_go_proto",
importpath = "px.dev/pixie/src/carnot/planner/tetragon/ir",
proto = ":logical_pl_proto",
)
Loading