Skip to content

Commit

Permalink
fix: rework proto fields
Browse files Browse the repository at this point in the history
Signed-off-by: Wassim DHIF <wassim.dhif@datadoghq.com>
  • Loading branch information
wdhif committed Dec 16, 2024
1 parent 28280e3 commit bfe71de
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 142 deletions.
6 changes: 3 additions & 3 deletions comp/core/tagger/impl-remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ func (t *remoteTagger) GenerateContainerIDFromOriginInfo(originInfo origindetect
// Call the gRPC method to get the container ID from the origin info
containerIDResponse, err := t.client.TaggerGenerateContainerIDFromOriginInfo(t.queryCtx, &pb.GenerateContainerIDFromOriginInfoRequest{
ExternalData: &pb.GenerateContainerIDFromOriginInfoRequest_ExternalData{
Init: originInfo.ExternalData.Init,
ContainerName: originInfo.ExternalData.ContainerName,
PodUID: originInfo.ExternalData.PodUID,
Init: &originInfo.ExternalData.Init,
ContainerName: &originInfo.ExternalData.ContainerName,
PodUID: &originInfo.ExternalData.PodUID,
},
})
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions comp/core/tagger/origindetection/origindetection.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ const (

// OriginInfo contains the Origin Detection information.
type OriginInfo struct {
LocalData LocalData // Local Data is the local data list.
LocalData LocalData // LocalData is the local data list.
ExternalData ExternalData // ExternalData is the external data list.
Cardinality string // Cardinality is the cardinality of the resolved origin.
ProductOrigin ProductOrigin // ProductOrigin is the product that sent the origin information.
}

// LocalData that is generated by the client and sent to the Agent.
type LocalData struct {
ContainerIDFromSocket string
ContainerID string
Inode string
PodUID string
ProcessID uint32 // ProcessID of the container process on the host.
ContainerID string // ContainerID sent from the client.
Inode uint64 // Inode is the Cgroup inode of the container.
PodUID string // PodUID of the pod sent from the client.
}

// ExternalData generated by the Admission Controller and sent to the Agent.
type ExternalData struct {
Init bool
ContainerName string
PodUID string
Init bool // Init is true if the container is an init container.
ContainerName string // ContainerName is the name of the container as seen by the Admission Controller.
PodUID string // PodUID is the UID of the pod as seen by the Admission Controller.
}

// GenerateContainerIDFromExternalData generates a container ID from the external data.
Expand Down
6 changes: 3 additions & 3 deletions comp/core/tagger/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ func (s *Server) TaggerFetchEntity(_ context.Context, in *pb.FetchEntityRequest)
func (s *Server) TaggerGenerateContainerIDFromOriginInfo(_ context.Context, in *pb.GenerateContainerIDFromOriginInfoRequest) (*pb.GenerateContainerIDFromOriginInfoResponse, error) {
generatedContainerID, err := s.taggerComponent.GenerateContainerIDFromOriginInfo(origindetection.OriginInfo{
ExternalData: origindetection.ExternalData{
Init: in.ExternalData.Init,
ContainerName: in.ExternalData.ContainerName,
PodUID: in.ExternalData.PodUID,
Init: *in.ExternalData.Init,
ContainerName: *in.ExternalData.ContainerName,
PodUID: *in.ExternalData.PodUID,
},
})
if err != nil {
Expand Down
20 changes: 11 additions & 9 deletions pkg/proto/datadog/model/v1/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,23 @@ message Entity {
}

message GenerateContainerIDFromOriginInfoRequest {
// Nested message for the local data
message LocalData {
string containerIDFromSocket = 1;
string containerID = 2;
uint64 Inode = 3;
string podUID = 4;
optional uint32 processID = 1; // Process ID of the container process on the host.
optional string containerID = 2; // Container ID send from the client.
optional uint64 inode = 3; // Cgroup inode of the container.
optional string podUID = 4; // Pod UID send from the client.
}

// Nested message for the external data
message ExternalData {
bool init = 1;
string containerName = 2;
string podUID = 3;
optional bool init = 1; // Init is true if the container is an init container.
optional string containerName = 2; // Container name in the Kubernetes Pod spec.
optional string podUID = 3; // Pod UID in the Kubernetes Pod spec.
}

LocalData localData = 1;
ExternalData externalData = 2;
optional LocalData localData = 1; // Local data for the container, generated by the client.
optional ExternalData externalData = 2; // External data for the container, generated by the Admission Controller.
}

message GenerateContainerIDFromOriginInfoResponse {
Expand Down
Loading

0 comments on commit bfe71de

Please sign in to comment.