Skip to content

Commit 058e777

Browse files
authored
logs: remove health platform references from Logs Agent (#46818)
### What does this PR do? Removes the Logs Agent’s integration with the Health Platform that was used to report Docker file tailing permission issues. Concretely, this PR: - Drops the `healthplatform` dependency wiring from the logs agent component. - Simplifies the container launcher and tailer factory constructors by removing the `healthPlatform` parameter. - Removes the Docker file permission error detection and reporting code path (including the issue reporting helper functions). - Updates mocks and unit tests to reflect the removal. ### Motivation The Logs Agent should no longer mention or depend on the Health Platform for reporting issues in this flow as it is now a built-in check of the platform ### Describe how you validated your changes - Ran unit tests for the logs agent / container launcher / tailer factory packages (including updated tests in `pkg/logs/launchers/container/...`). - Ensured the agent compiles with the updated constructor signatures and fx wiring changes. ### Additional Notes Co-authored-by: louis.coquerelle <louis.coquerelle@datadoghq.com>
1 parent e4a4e2d commit 058e777

File tree

9 files changed

+14
-88
lines changed

9 files changed

+14
-88
lines changed

comp/logs/agent/agentimpl/agent.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
statusComponent "github.com/DataDog/datadog-agent/comp/core/status"
2727
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
2828
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
29-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
3029
"github.com/DataDog/datadog-agent/comp/logs/agent"
3130
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
3231
flareController "github.com/DataDog/datadog-agent/comp/logs/agent/flare"
@@ -86,7 +85,6 @@ type dependencies struct {
8685
SchedulerProviders []schedulers.Scheduler `group:"log-agent-scheduler"`
8786
Tagger tagger.Component
8887
Compression logscompression.Component
89-
HealthPlatform option.Option[healthplatform.Component]
9088
}
9189

9290
type provides struct {
@@ -124,7 +122,6 @@ type logAgent struct {
124122
schedulerProviders []schedulers.Scheduler
125123
integrationsLogs integrations.Component
126124
compression logscompression.Component
127-
healthPlatform option.Option[healthplatform.Component]
128125

129126
// make sure this is done only once, when we're ready
130127
prepareSchedulers sync.Once
@@ -165,7 +162,6 @@ func newLogsAgent(deps dependencies) provides {
165162
integrationsLogs: integrationsLogs,
166163
tagger: deps.Tagger,
167164
compression: deps.Compression,
168-
healthPlatform: deps.HealthPlatform,
169165
}
170166
deps.Lc.Append(fx.Hook{
171167
OnStart: logsAgent.start,

comp/logs/agent/agentimpl/agent_core_init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (a *logAgent) addLauncherInstances(lnchrs *launchers.Launchers, wmeta optio
162162
lnchrs.AddLauncher(listener.NewLauncher(a.config.GetInt("logs_config.frame_size")))
163163
lnchrs.AddLauncher(journald.NewLauncher(a.flarecontroller, a.tagger))
164164
lnchrs.AddLauncher(windowsevent.NewLauncher())
165-
lnchrs.AddLauncher(container.NewLauncher(a.sources, wmeta, a.tagger, a.healthPlatform))
165+
lnchrs.AddLauncher(container.NewLauncher(a.sources, wmeta, a.tagger))
166166
lnchrs.AddLauncher(integrationLauncher.NewLauncher(
167167
afero.NewOsFs(),
168168
a.sources, integrationsLogs))

comp/logs/agent/agentimpl/agent_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import (
3030
taggerfxmock "github.com/DataDog/datadog-agent/comp/core/tagger/fx-mock"
3131
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
3232
workloadmetafxmock "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx-mock"
33-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
34-
healthplatformmock "github.com/DataDog/datadog-agent/comp/healthplatform/mock"
3533
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
3634
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
3735
auditorfx "github.com/DataDog/datadog-agent/comp/logs/auditor/fx"
@@ -55,7 +53,6 @@ import (
5553
logsStatus "github.com/DataDog/datadog-agent/pkg/logs/status"
5654
"github.com/DataDog/datadog-agent/pkg/logs/tailers"
5755
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
58-
"github.com/DataDog/datadog-agent/pkg/util/option"
5956
"github.com/DataDog/datadog-agent/pkg/util/testutil"
6057
)
6158

@@ -513,9 +510,6 @@ func (suite *AgentTestSuite) createDeps() dependencies {
513510
}),
514511
auditorfx.Module(),
515512
fx.Provide(kubehealthmock.NewProvides),
516-
fx.Provide(func() option.Option[healthplatform.Component] {
517-
return option.New[healthplatform.Component](healthplatformmock.Mock(suite.T()))
518-
}),
519513
))
520514
}
521515

comp/logs/agent/agentimpl/mock.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"go.uber.org/fx"
1515

16-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
1716
"github.com/DataDog/datadog-agent/comp/logs/agent"
1817
"github.com/DataDog/datadog-agent/pkg/logs/diagnostic"
1918
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
@@ -27,8 +26,7 @@ import (
2726
func MockModule() fxutil.Module {
2827
return fxutil.Component(
2928
fx.Provide(newMock),
30-
fx.Provide(func(m agent.Mock) agent.Component { return m }),
31-
fx.Supply(option.None[healthplatform.Component]()))
29+
fx.Provide(func(m agent.Mock) agent.Component { return m }))
3230
}
3331

3432
type mockLogsAgent struct {

pkg/logs/launchers/container/launcher.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1515
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
16-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
1716
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1817
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
1918
"github.com/DataDog/datadog-agent/pkg/logs/launchers/container/tailerfactory"
@@ -61,18 +60,15 @@ type Launcher struct {
6160
wmeta option.Option[workloadmeta.Component]
6261

6362
tagger tagger.Component
64-
65-
healthPlatform option.Option[healthplatform.Component]
6663
}
6764

6865
// NewLauncher returns a new launcher
69-
func NewLauncher(sources *sourcesPkg.LogSources, wmeta option.Option[workloadmeta.Component], tagger tagger.Component, healthPlatform option.Option[healthplatform.Component]) *Launcher {
66+
func NewLauncher(sources *sourcesPkg.LogSources, wmeta option.Option[workloadmeta.Component], tagger tagger.Component) *Launcher {
7067
launcher := &Launcher{
71-
sources: sources,
72-
tailers: make(map[*sourcesPkg.LogSource]tailerfactory.Tailer),
73-
wmeta: wmeta,
74-
tagger: tagger,
75-
healthPlatform: healthPlatform,
68+
sources: sources,
69+
tailers: make(map[*sourcesPkg.LogSource]tailerfactory.Tailer),
70+
wmeta: wmeta,
71+
tagger: tagger,
7672
}
7773
return launcher
7874
}
@@ -84,7 +80,7 @@ func (l *Launcher) Start(sourceProvider launchers.SourceProvider, pipelineProvid
8480
l.cancel = cancel
8581
l.stopped = make(chan struct{})
8682

87-
l.tailerFactory = tailerfactory.New(l.sources, pipelineProvider, registry, l.wmeta, l.tagger, l.healthPlatform)
83+
l.tailerFactory = tailerfactory.New(l.sources, pipelineProvider, registry, l.wmeta, l.tagger)
8884
go l.run(ctx, sourceProvider)
8985
}
9086

pkg/logs/launchers/container/launcher_no_kubelet_and_docker.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ package container
1111
import (
1212
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1313
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
14-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
1514
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1615
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
1716
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
@@ -26,7 +25,7 @@ import (
2625
type Launcher struct{}
2726

2827
// NewLauncher returns a new launcher
29-
func NewLauncher(_ *sourcesPkg.LogSources, _ option.Option[workloadmeta.Component], _ tagger.Component, _ option.Option[healthplatform.Component]) *Launcher {
28+
func NewLauncher(_ *sourcesPkg.LogSources, _ option.Option[workloadmeta.Component], _ tagger.Component) *Launcher {
3029
return &Launcher{}
3130
}
3231

pkg/logs/launchers/container/launcher_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
taggerfxmock "github.com/DataDog/datadog-agent/comp/core/tagger/fx-mock"
1919
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
20-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
2120
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
2221
auditorMock "github.com/DataDog/datadog-agent/comp/logs/auditor/mock"
2322
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
@@ -41,7 +40,7 @@ func (tf *testFactory) MakeTailer(source *sources.LogSource) (tailerfactory.Tail
4140
func TestStartStop(t *testing.T) {
4241
fakeTagger := taggerfxmock.SetupFakeTagger(t)
4342

44-
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger, option.None[healthplatform.Component]())
43+
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger)
4544

4645
sp := launchers.NewMockSourceProvider()
4746
pl := pipeline.NewMockProvider()
@@ -61,7 +60,7 @@ func TestStartStop(t *testing.T) {
6160
func TestAddsRemovesSource(t *testing.T) {
6261
fakeTagger := taggerfxmock.SetupFakeTagger(t)
6362

64-
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger, option.None[healthplatform.Component]())
63+
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger)
6564
l.tailerFactory = &testFactory{
6665
makeTailer: func(source *sources.LogSource) (tailerfactory.Tailer, error) {
6766
return &tailerfactory.TestTailer{Name: source.Name}, nil
@@ -92,7 +91,7 @@ func TestAddsRemovesSource(t *testing.T) {
9291
func TestCannotMakeTailer(t *testing.T) {
9392
fakeTagger := taggerfxmock.SetupFakeTagger(t)
9493

95-
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger, option.None[healthplatform.Component]())
94+
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger)
9695
l.tailerFactory = &testFactory{
9796
makeTailer: func(_ *sources.LogSource) (tailerfactory.Tailer, error) {
9897
return nil, errors.New("uhoh")
@@ -115,7 +114,7 @@ func TestCannotMakeTailer(t *testing.T) {
115114
func TestCannotStartTailer(t *testing.T) {
116115
fakeTagger := taggerfxmock.SetupFakeTagger(t)
117116

118-
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger, option.None[healthplatform.Component]())
117+
l := NewLauncher(nil, option.None[workloadmeta.Component](), fakeTagger)
119118
l.tailerFactory = &testFactory{
120119
makeTailer: func(source *sources.LogSource) (tailerfactory.Tailer, error) {
121120
return &tailerfactory.TestTailer{Name: source.Name, StartError: true}, nil

pkg/logs/launchers/container/tailerfactory/factory.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ package tailerfactory
1212
import (
1313
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1414
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
15-
healthplatform "github.com/DataDog/datadog-agent/comp/healthplatform/def"
1615
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1716
"github.com/DataDog/datadog-agent/pkg/logs/internal/util/containersorpods"
1817
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
@@ -63,15 +62,12 @@ type factory struct {
6362
dockerUtilGetter dockerUtilGetter
6463

6564
tagger tagger.Component
66-
67-
// healthPlatform is the health platform component for reporting issues
68-
healthPlatform option.Option[healthplatform.Component]
6965
}
7066

7167
var _ Factory = (*factory)(nil)
7268

7369
// New creates a new Factory.
74-
func New(sources *sources.LogSources, pipelineProvider pipeline.Provider, registry auditor.Registry, workloadmetaStore option.Option[workloadmeta.Component], tagger tagger.Component, healthPlatform option.Option[healthplatform.Component]) Factory {
70+
func New(sources *sources.LogSources, pipelineProvider pipeline.Provider, registry auditor.Registry, workloadmetaStore option.Option[workloadmeta.Component], tagger tagger.Component) Factory {
7571
return &factory{
7672
sources: sources,
7773
pipelineProvider: pipelineProvider,
@@ -80,7 +76,6 @@ func New(sources *sources.LogSources, pipelineProvider pipeline.Provider, regist
8076
cop: containersorpods.NewChooser(),
8177
dockerUtilGetter: &dockerUtilGetterImpl{},
8278
tagger: tagger,
83-
healthPlatform: healthPlatform,
8479
}
8580
}
8681

pkg/logs/launchers/container/tailerfactory/file.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ import (
1616
"context"
1717
"errors"
1818
"fmt"
19-
"io/fs"
2019
"os"
2120
"path/filepath"
2221
"runtime"
23-
"syscall"
24-
25-
"github.com/DataDog/agent-payload/v5/healthplatform"
2622

2723
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
2824
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
@@ -127,19 +123,6 @@ func (tf *factory) makeDockerFileSource(source *sources.LogSource) (*sources.Log
127123
// try to fall back to reading from a socket.
128124
f, err := opener.OpenLogFile(path)
129125
if err != nil {
130-
// Check if this is a permission error and report to health platform
131-
if isPermissionError(err) {
132-
// Extract the base docker directory from the path
133-
dockerDir := dockerLogsBasePathNix
134-
if overridePath := pkgconfigsetup.Datadog().GetString("logs_config.docker_path_override"); len(overridePath) > 0 {
135-
dockerDir = overridePath
136-
} else if runtime.GOOS == "windows" {
137-
dockerDir = dockerLogsBasePathWin
138-
}
139-
140-
// Report the issue to health platform
141-
tf.reportDockerPermissionIssue(dockerDir)
142-
}
143126
// (this error already has the form 'open <path>: ..' so needs no further embellishment)
144127
return nil, err
145128
}
@@ -339,37 +322,3 @@ func findK8sLogPath(pod *workloadmeta.KubernetesPod, containerName string) strin
339322
log.Debugf("Using the latest kubernetes logs path for container %s", containerName)
340323
return filepath.Join(podLogsBasePath, getPodDirectorySince1_14(pod), containerName, anyLogFile)
341324
}
342-
343-
// isPermissionError checks if an error is permission-related using proper error type checking
344-
func isPermissionError(err error) bool {
345-
return errors.Is(err, fs.ErrPermission) ||
346-
errors.Is(err, syscall.EACCES) ||
347-
errors.Is(err, syscall.EPERM)
348-
}
349-
350-
// reportDockerPermissionIssue reports a Docker file tailing permission issue to the health platform
351-
func (tf *factory) reportDockerPermissionIssue(dockerDir string) {
352-
hp, exists := tf.healthPlatform.Get()
353-
if !exists {
354-
return
355-
}
356-
357-
// Report the issue with minimal context - health platform registry provides all metadata and remediation
358-
err := hp.ReportIssue(
359-
"logs-docker-file-permissions",
360-
"Docker File Tailing Permissions",
361-
&healthplatform.IssueReport{
362-
IssueId: "docker-file-tailing-disabled",
363-
Context: map[string]string{
364-
"dockerDir": dockerDir,
365-
"os": runtime.GOOS,
366-
},
367-
},
368-
)
369-
370-
if err != nil {
371-
log.Warnf("Failed to report Docker permission issue to health platform: %v", err)
372-
} else {
373-
log.Infof("Reported Docker file tailing permission issue to health platform")
374-
}
375-
}

0 commit comments

Comments
 (0)