Skip to content

Commit

Permalink
fix: improve code
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 6197b13 commit 72a5031
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 181 deletions.
2 changes: 2 additions & 0 deletions comp/api/api/apiimpl/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func (s *serverSecure) TaggerStreamEntities(req *pb.StreamTagsRequest, srv pb.Ag
return s.taggerServer.TaggerStreamEntities(req, srv)
}

// TaggerGenerateContainerIDFromOriginInfo generates a container ID from the Origin Info.
// This function takes an Origin Info but only uses the ExternalData part of it, this is done for backward compatibility.
func (s *serverSecure) TaggerGenerateContainerIDFromOriginInfo(ctx context.Context, req *pb.GenerateContainerIDFromOriginInfoRequest) (*pb.GenerateContainerIDFromOriginInfoResponse, error) {
return s.taggerServer.TaggerGenerateContainerIDFromOriginInfo(ctx, req)
}
Expand Down
8 changes: 5 additions & 3 deletions comp/core/tagger/impl-remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,11 @@ 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{
ExternalDataInit: originInfo.ExternalData.Init,
ExternalDataContainerName: originInfo.ExternalData.ContainerName,
ExternalDataPodUID: originInfo.ExternalData.PodUID,
ExternalData: &pb.GenerateContainerIDFromOriginInfoRequest_ExternalData{
Init: originInfo.ExternalData.Init,
ContainerName: originInfo.ExternalData.ContainerName,
PodUID: originInfo.ExternalData.PodUID,
},
})
if err != nil {
_ = t.log.Errorf("unable to generate container ID from origin info, will retry: %s", err)
Expand Down
7 changes: 4 additions & 3 deletions comp/core/tagger/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ func (s *Server) TaggerFetchEntity(_ context.Context, in *pb.FetchEntityRequest)
}

// TaggerGenerateContainerIDFromOriginInfo request the generation of a container ID from external data from the Tagger.
// This function takes an Origin Info but only uses the ExternalData part of it, this is done for backward compatibility.
func (s *Server) TaggerGenerateContainerIDFromOriginInfo(_ context.Context, in *pb.GenerateContainerIDFromOriginInfoRequest) (*pb.GenerateContainerIDFromOriginInfoResponse, error) {
generatedContainerID, err := s.taggerComponent.GenerateContainerIDFromOriginInfo(origindetection.OriginInfo{
ExternalData: origindetection.ExternalData{
Init: in.ExternalDataInit,
ContainerName: in.ExternalDataContainerName,
PodUID: in.ExternalDataPodUID,
Init: in.ExternalData.Init,
ContainerName: in.ExternalData.ContainerName,
PodUID: in.ExternalData.PodUID,
},
})
if err != nil {
Expand Down
23 changes: 15 additions & 8 deletions pkg/proto/datadog/model/v1/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,21 @@ message Entity {
}

message GenerateContainerIDFromOriginInfoRequest {
// Local Data
string localDataContainerIDFromSocket = 1;
string localDataPodUID = 2;
string localDataContainerID = 3;
// External Data
bool externalDataInit = 4;
string externalDataContainerName = 5;
string externalDataPodUID = 6;
message LocalData {
string containerIDFromSocket = 1;
string containerID = 2;
string Inode = 3;
string podUID = 4;
}

message ExternalData {
bool init = 1;
string containerName = 2;
string podUID = 3;
}

LocalData localData = 1;
ExternalData externalData = 2;
}

message GenerateContainerIDFromOriginInfoResponse {
Expand Down
Loading

0 comments on commit 72a5031

Please sign in to comment.