Skip to content

Commit

Permalink
[Backport 7.61.x] [CWS] do not start/stop manually the remote tagger …
Browse files Browse the repository at this point in the history
…in the resolver (#31609)

Co-authored-by: paulcacheux <[email protected]>
  • Loading branch information
agent-platform-auto-pr[bot] and paulcacheux authored Nov 29, 2024
1 parent b7b4749 commit 45688b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
25 changes: 2 additions & 23 deletions pkg/security/resolvers/tags/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/DataDog/datadog-agent/comp/core/tagger/types"
"github.com/DataDog/datadog-agent/pkg/security/seclog"
"github.com/DataDog/datadog-agent/pkg/security/utils"
"github.com/DataDog/datadog-agent/pkg/util/log"
)

// Event defines the tags event type
Expand All @@ -25,8 +24,6 @@ const (

// Tagger defines a Tagger for the Tags Resolver
type Tagger interface {
Start(ctx context.Context) error
Stop() error
Tag(entity types.EntityID, cardinality types.TagCardinality) ([]string, error)
GlobalTags(cardinality types.TagCardinality) ([]string, error)
}
Expand Down Expand Up @@ -73,31 +70,13 @@ func (t *DefaultResolver) GetValue(id string, tag string) string {
}

// Start the resolver
func (t *DefaultResolver) Start(ctx context.Context) error {
if t.tagger == nil {
return nil
}

go func() {
if err := t.tagger.Start(ctx); err != nil {
log.Errorf("failed to init tagger: %s", err)
}
}()

go func() {
<-ctx.Done()
_ = t.tagger.Stop()
}()

func (t *DefaultResolver) Start(_ context.Context) error {
return nil
}

// Stop the resolver
func (t *DefaultResolver) Stop() error {
if t.tagger == nil {
return nil
}
return t.tagger.Stop()
return nil
}

// NewDefaultResolver returns a new default tags resolver
Expand Down
31 changes: 0 additions & 31 deletions pkg/security/tests/fake_tags_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package tests

import (
"context"
"fmt"
"sync"

Expand All @@ -26,16 +25,6 @@ type FakeTagger struct {
containerIDs []string
}

// Start the tagger
func (fr *FakeTagger) Start(_ context.Context) error {
return nil
}

// Stop the tagger
func (fr *FakeTagger) Stop() error {
return nil
}

// Tag returns the tags for the given id
func (fr *FakeTagger) Tag(entity types.EntityID, _ types.TagCardinality) ([]string, error) {
containerID := entity.GetID()
Expand Down Expand Up @@ -68,16 +57,6 @@ func NewFakeTaggerDifferentImageNames() tags.Tagger {
// FakeMonoTagger represents a fake mono tagger
type FakeMonoTagger struct{}

// Start the tagger
func (fmr *FakeMonoTagger) Start(_ context.Context) error {
return nil
}

// Stop the tagger
func (fmr *FakeMonoTagger) Stop() error {
return nil
}

// Tag returns the tags for the given id
func (fmr *FakeMonoTagger) Tag(entity types.EntityID, _ types.TagCardinality) ([]string, error) {
return []string{"container_id:" + entity.GetID(), "image_name:fake_ubuntu", "image_tag:latest"}, nil
Expand All @@ -103,16 +82,6 @@ type FakeManualTagger struct {
nextSelectors []*cgroupModel.WorkloadSelector
}

// Start the tagger
func (fmr *FakeManualTagger) Start(_ context.Context) error {
return nil
}

// Stop the tagger
func (fmr *FakeManualTagger) Stop() error {
return nil
}

// SpecifyNextSelector specifies the next image name and tag to be resolved
func (fmr *FakeManualTagger) SpecifyNextSelector(selector *cgroupModel.WorkloadSelector) {
fmr.Lock()
Expand Down

0 comments on commit 45688b8

Please sign in to comment.