Skip to content

Commit adfc8be

Browse files
committed
[review-fix 1] Preserve baseline RC provenance
- Apply winning filter metadata before mode selection so baseline-admitted paths retain their RC ID, source, and tags without changing standard scheduling. - Add coverage for an RC include overriding a local exclusion while preserving the baseline profile. Source: review feedback Validation: bazel test --nocache_test_results //comp/networkpath/npcollector/impl:impl_test
1 parent b225e69 commit adfc8be

2 files changed

Lines changed: 35 additions & 11 deletions

File tree

comp/networkpath/npcollector/impl/baseline_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
model "github.com/DataDog/agent-payload/v5/process"
1717
"github.com/DataDog/datadog-agent/comp/networkpath/npcollector/impl/common"
18+
"github.com/DataDog/datadog-agent/comp/networkpath/npcollector/impl/connfilter"
1819
npmodel "github.com/DataDog/datadog-agent/comp/networkpath/npcollector/model"
1920
"github.com/DataDog/datadog-agent/pkg/networkpath/payload"
2021
"github.com/DataDog/datadog-agent/pkg/trace/teststatsd"
@@ -149,6 +150,34 @@ func TestBaselineKeepsStrongestObservationPerPath(t *testing.T) {
149150
assert.Equal(t, []string{"10.0.0.1", "10.0.0.2", "10.0.0.3"}, scheduledBaselineHosts(t, collector))
150151
}
151152

153+
func TestBaselinePreservesWinningRCProvenance(t *testing.T) {
154+
_, collector := newTestNpCollector(t, map[string]any{
155+
"network_path.connections_monitoring.baseline_tests_enabled": true,
156+
"network_path.collector.monitor_ip_without_domain": true,
157+
}, &teststatsd.Client{}, nil)
158+
filter, errs := connfilter.NewConnFilter([]connfilter.Config{
159+
{Type: connfilter.FilterTypeExclude, MatchIP: "10.0.0.1"},
160+
{
161+
Type: connfilter.FilterTypeInclude,
162+
MatchIP: "10.0.0.1",
163+
TestConfigID: "dynamic-a",
164+
Tags: []string{"team:payments"},
165+
},
166+
}, "", false)
167+
require.Empty(t, errs)
168+
collector.filter = filter
169+
170+
collector.ScheduleNetworkPathTests(slices.Values([]npmodel.NetworkPathConnection{
171+
baselineConn("10.0.0.1", 1),
172+
}))
173+
174+
pathtest := <-collector.pathtestInputChan
175+
assert.Equal(t, payload.DynamicTestProfileBaseline, pathtest.DynamicTestProfile)
176+
assert.Equal(t, "dynamic-a", pathtest.TestConfigID)
177+
assert.Equal(t, payload.TestConfigSourceRemote, pathtest.TestConfigSource)
178+
assert.Equal(t, []string{"team:payments"}, pathtest.Tags)
179+
}
180+
152181
func TestBaselineEmptySnapshotsSelectNothing(t *testing.T) {
153182
_, collector := newTestNpCollector(t, map[string]any{
154183
"network_path.connections_monitoring.baseline_tests_enabled": true,

comp/networkpath/npcollector/impl/npcollector.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,17 @@ func (s *npCollectorImpl) scheduleNetworkPathTests(origin payload.PathOrigin, co
329329
continue
330330
}
331331
pathtest := s.makePathtest(conn, origin)
332+
pathtest.TestConfigID = evaluation.testConfigID
333+
pathtest.Tags = evaluation.tags
334+
if evaluation.testConfigID != "" {
335+
pathtest.TestConfigSource = payload.TestConfigSourceRemote
336+
}
332337
if baselineMode {
333338
selectedBaselineCandidates = addBaselinePath(selectedBaselineCandidates, pathtest, conn.Signals)
334339
continue
335340
}
336341

337-
if err := s.scheduleStandardNetworkPathTest(pathtest, evaluation); err != nil {
342+
if err := s.scheduleOne(&pathtest); err != nil {
338343
s.logger.Errorf("Error scheduling pathtests: %s", err)
339344
}
340345
}
@@ -344,16 +349,6 @@ func (s *npCollectorImpl) scheduleNetworkPathTests(origin payload.PathOrigin, co
344349
_ = s.statsdClient.Count(common.NetworkPathCollectorMetricPrefix+"schedule.conns_received", int64(connCount), []string{}, 1)
345350
_ = s.statsdClient.Gauge(common.NetworkPathCollectorMetricPrefix+"schedule.duration", s.TimeNowFn().Sub(startTime).Seconds(), nil, 1)
346351
}
347-
348-
func (s *npCollectorImpl) scheduleStandardNetworkPathTest(pathtest common.Pathtest, evaluation pathEvaluation) error {
349-
pathtest.TestConfigID = evaluation.testConfigID
350-
pathtest.Tags = evaluation.tags
351-
if evaluation.testConfigID != "" {
352-
pathtest.TestConfigSource = payload.TestConfigSourceRemote
353-
}
354-
return s.scheduleOne(&pathtest)
355-
}
356-
357352
func (s *npCollectorImpl) scheduleBaselinePaths(selected []baselineCandidate) {
358353
for i := range selected {
359354
if err := s.scheduleOne(&selected[i].path); err != nil {

0 commit comments

Comments
 (0)