Skip to content

Commit 621ff37

Browse files
authored
NETOBSERV-2126: cleanup unused code wrt Duplicate (#1261)
1 parent 2385f04 commit 621ff37

File tree

12 files changed

+6
-127
lines changed

12 files changed

+6
-127
lines changed

apis/flowmetrics/v1alpha1/flowmetric_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ type FlowMetricSpec struct {
7878
// +optional
7979
ValueField string `json:"valueField,omitempty"`
8080

81-
// `filters` is a list of fields and values used to restrict which flows are taken into account. Oftentimes, these filters must
82-
// be used to eliminate duplicates: `Duplicate != "true"` and `FlowDirection = "0"`.
81+
// `filters` is a list of fields and values used to restrict which flows are taken into account.
8382
// Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/observability/network_observability/json-flows-format-reference.html.
8483
// +optional
8584
Filters []MetricFilter `json:"filters"`

bundle/manifests/flows.netobserv.io_flowmetrics.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ spec:
167167
type: string
168168
filters:
169169
description: |-
170-
`filters` is a list of fields and values used to restrict which flows are taken into account. Oftentimes, these filters must
171-
be used to eliminate duplicates: `Duplicate != "true"` and `FlowDirection = "0"`.
170+
`filters` is a list of fields and values used to restrict which flows are taken into account.
172171
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/observability/network_observability/json-flows-format-reference.html.
173172
items:
174173
properties:

config/crd/bases/flows.netobserv.io_flowmetrics.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ spec:
157157
type: string
158158
filters:
159159
description: |-
160-
`filters` is a list of fields and values used to restrict which flows are taken into account. Oftentimes, these filters must
161-
be used to eliminate duplicates: `Duplicate != "true"` and `FlowDirection = "0"`.
160+
`filters` is a list of fields and values used to restrict which flows are taken into account.
162161
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/observability/network_observability/json-flows-format-reference.html.
163162
items:
164163
properties:

controllers/consoleplugin/config/config.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ type FieldConfig struct {
108108
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
109109
}
110110

111-
type Deduper struct {
112-
Mark bool `yaml:"mark" json:"mark"`
113-
Merge bool `yaml:"merge" json:"merge"`
114-
}
115-
116111
type FrontendConfig struct {
117112
RecordTypes []api.ConnTrackOutputRecordTypeEnum `yaml:"recordTypes" json:"recordTypes"`
118113
PortNaming flowslatest.ConsolePluginPortConfig `yaml:"portNaming,omitempty" json:"portNaming,omitempty"`
@@ -123,7 +118,6 @@ type FrontendConfig struct {
123118
AlertNamespaces []string `yaml:"alertNamespaces,omitempty" json:"alertNamespaces,omitempty"`
124119
Sampling int `yaml:"sampling" json:"sampling"`
125120
Features []string `yaml:"features" json:"features"`
126-
Deduper Deduper `yaml:"deduper" json:"deduper"`
127121
Fields []FieldConfig `yaml:"fields" json:"fields"`
128122
}
129123

controllers/consoleplugin/config/static-frontend-config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,9 +1336,6 @@ fields:
13361336
- name: IcmpCode
13371337
type: number
13381338
description: ICMP code
1339-
- name: Duplicate
1340-
type: boolean
1341-
description: Indicates if this flow was also captured from another interface on the same host
13421339
- name: FlowDirection
13431340
type: number
13441341
description: |

controllers/consoleplugin/consoleplugin_objects.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
flowslatest "github.com/netobserv/network-observability-operator/apis/flowcollector/v1beta2"
2525
cfg "github.com/netobserv/network-observability-operator/controllers/consoleplugin/config"
2626
"github.com/netobserv/network-observability-operator/controllers/constants"
27-
"github.com/netobserv/network-observability-operator/controllers/ebpf"
2827
"github.com/netobserv/network-observability-operator/controllers/reconcilers"
2928
"github.com/netobserv/network-observability-operator/pkg/helper"
3029
"github.com/netobserv/network-observability-operator/pkg/helper/loki"
@@ -432,15 +431,6 @@ func (b *builder) getPromConfig(ctx context.Context) cfg.PrometheusConfig {
432431
}
433432

434433
func (b *builder) setFrontendConfig(fconf *cfg.FrontendConfig) error {
435-
var err error
436-
dedupJustMark, err := strconv.ParseBool(ebpf.DedupeJustMarkDefault)
437-
if err != nil {
438-
return err
439-
}
440-
dedupMerge, err := strconv.ParseBool(ebpf.DedupeMergeDefault)
441-
if err != nil {
442-
return err
443-
}
444434
if helper.IsPktDropEnabled(&b.desired.Agent.EBPF) {
445435
fconf.Features = append(fconf.Features, "pktDrop")
446436
}
@@ -469,30 +459,11 @@ func (b *builder) setFrontendConfig(fconf *cfg.FrontendConfig) error {
469459
fconf.Features = append(fconf.Features, "ipsec")
470460
}
471461

472-
if b.desired.Agent.EBPF.Advanced != nil {
473-
if v, ok := b.desired.Agent.EBPF.Advanced.Env[ebpf.EnvDedupeJustMark]; ok {
474-
dedupJustMark, err = strconv.ParseBool(v)
475-
if err != nil {
476-
return err
477-
}
478-
}
479-
480-
if v, ok := b.desired.Agent.EBPF.Advanced.Env[ebpf.EnvDedupeMerge]; ok {
481-
dedupMerge, err = strconv.ParseBool(v)
482-
if err != nil {
483-
return err
484-
}
485-
}
486-
}
487462
fconf.RecordTypes = helper.GetRecordTypes(&b.desired.Processor)
488463
fconf.PortNaming = b.desired.ConsolePlugin.PortNaming
489464
fconf.QuickFilters = b.desired.ConsolePlugin.QuickFilters
490465
fconf.AlertNamespaces = []string{b.info.Namespace}
491466
fconf.Sampling = helper.GetSampling(b.desired)
492-
fconf.Deduper = cfg.Deduper{
493-
Mark: dedupJustMark,
494-
Merge: dedupMerge,
495-
}
496467
if helper.IsMultiClusterEnabled(&b.desired.Processor) {
497468
fconf.Features = append(fconf.Features, "multiCluster")
498469
}

controllers/consoleplugin/consoleplugin_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -338,59 +338,6 @@ func TestConfigMapContent(t *testing.T) {
338338
assert.NotEmpty(config.Frontend.Filters)
339339
assert.NotEmpty(config.Frontend.Scopes)
340340
assert.Equal(config.Frontend.Sampling, 1)
341-
assert.Equal(config.Frontend.Deduper.Mark, false)
342-
assert.Equal(config.Frontend.Deduper.Merge, true)
343-
}
344-
345-
func TestConfigMapError(t *testing.T) {
346-
assert := assert.New(t)
347-
348-
agentSpec := flowslatest.FlowCollectorAgent{
349-
Type: "eBPF",
350-
EBPF: flowslatest.FlowCollectorEBPF{
351-
Sampling: ptr.To(int32(1)),
352-
Advanced: &flowslatest.AdvancedAgentConfig{
353-
Env: map[string]string{
354-
"DEDUPER_JUST_MARK": "invalid",
355-
},
356-
},
357-
},
358-
}
359-
lokiSpec := flowslatest.FlowCollectorLoki{}
360-
loki := helper.NewLokiConfig(&lokiSpec, "any")
361-
362-
// spec with invalid flag
363-
spec := flowslatest.FlowCollectorSpec{
364-
Agent: agentSpec,
365-
ConsolePlugin: getPluginConfig(),
366-
Loki: lokiSpec,
367-
}
368-
builder := getBuilder(&spec, &loki)
369-
cm, _, err := builder.configMap(context.Background())
370-
assert.Nil(cm)
371-
assert.NotNil(err)
372-
373-
// update to valid flags
374-
agentSpec.EBPF.Advanced.Env = map[string]string{
375-
"DEDUPER_JUST_MARK": "false",
376-
"DEDUPER_MERGE": "true",
377-
}
378-
spec = flowslatest.FlowCollectorSpec{
379-
Agent: agentSpec,
380-
ConsolePlugin: getPluginConfig(),
381-
Loki: lokiSpec,
382-
}
383-
builder = getBuilder(&spec, &loki)
384-
cm, _, err = builder.configMap(context.Background())
385-
assert.NotNil(cm)
386-
assert.Nil(err)
387-
388-
// parse output config and check expected values
389-
var config config.PluginConfig
390-
err = yaml.Unmarshal([]byte(cm.Data["config.yaml"]), &config)
391-
assert.Nil(err)
392-
assert.Equal(config.Frontend.Deduper.Mark, false)
393-
assert.Equal(config.Frontend.Deduper.Merge, true)
394341
}
395342

396343
func TestServiceUpdateCheck(t *testing.T) {

controllers/ebpf/agent_controller.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ const (
5252
envKafkaSASLIDPath = "KAFKA_SASL_CLIENT_ID_PATH"
5353
envKafkaSASLSecretPath = "KAFKA_SASL_CLIENT_SECRET_PATH"
5454
envLogLevel = "LOG_LEVEL"
55-
envDedupe = "DEDUPER"
56-
dedupeDefault = "firstCome"
5755
envGoMemLimit = "GOMEMLIMIT"
5856
envEnablePktDrop = "ENABLE_PKT_DROPS"
5957
envEnableDNSTracking = "ENABLE_DNS_TRACKING"
@@ -94,11 +92,7 @@ const (
9492
)
9593

9694
const (
97-
EnvDedupeJustMark = "DEDUPER_JUST_MARK"
98-
EnvDedupeMerge = "DEDUPER_MERGE"
9995
envDNSTrackingPort = "DNS_TRACKING_PORT"
100-
DedupeJustMarkDefault = "false"
101-
DedupeMergeDefault = "true"
10296
defaultDNSTrackingPort = "53"
10397
bpfmanMapsVolumeName = "bpfman-maps"
10498
bpfManBpfFSPath = "/run/netobserv/maps"
@@ -752,9 +746,6 @@ func (c *AgentController) setEnvConfig(coll *flowslatest.FlowCollector) []corev1
752746
})
753747
}
754748

755-
dedup := dedupeDefault
756-
dedupJustMark := DedupeJustMarkDefault
757-
dedupMerge := DedupeMergeDefault
758749
dnsTrackingPort := defaultDNSTrackingPort
759750
networkEventsGroupID := defaultNetworkEventsGroupID
760751
// we need to sort env map to keep idempotency,
@@ -763,12 +754,6 @@ func (c *AgentController) setEnvConfig(coll *flowslatest.FlowCollector) []corev1
763754
for _, pair := range helper.KeySorted(advancedConfig.Env) {
764755
k, v := pair[0], pair[1]
765756
switch k {
766-
case envDedupe:
767-
dedup = v
768-
case EnvDedupeJustMark:
769-
dedupJustMark = v
770-
case EnvDedupeMerge:
771-
dedupMerge = v
772757
case envDNSTrackingPort:
773758
dnsTrackingPort = v
774759
case envNetworkEventsGroupID:
@@ -778,8 +763,6 @@ func (c *AgentController) setEnvConfig(coll *flowslatest.FlowCollector) []corev1
778763
}
779764
}
780765

781-
config = append(config, corev1.EnvVar{Name: envDedupe, Value: dedup})
782-
config = append(config, corev1.EnvVar{Name: EnvDedupeJustMark, Value: dedupJustMark})
783766
config = append(config, corev1.EnvVar{Name: envDNSTrackingPort, Value: dnsTrackingPort})
784767
config = append(config, corev1.EnvVar{Name: envNetworkEventsGroupID, Value: networkEventsGroupID})
785768
config = append(config, corev1.EnvVar{
@@ -792,7 +775,6 @@ func (c *AgentController) setEnvConfig(coll *flowslatest.FlowCollector) []corev1
792775
},
793776
},
794777
)
795-
config = append(config, corev1.EnvVar{Name: EnvDedupeMerge, Value: dedupMerge})
796778

797779
return config
798780
}

controllers/flowcollector_controller_certificates_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,7 @@ func flowCollectorCertificatesSpecs() {
145145
DeploymentModel: flowslatest.DeploymentModelKafka,
146146
Agent: flowslatest.FlowCollectorAgent{
147147
Type: "eBPF",
148-
EBPF: flowslatest.FlowCollectorEBPF{
149-
Advanced: &flowslatest.AdvancedAgentConfig{
150-
Env: map[string]string{
151-
"DEDUPER_JUST_MARK": "true",
152-
},
153-
},
154-
},
148+
EBPF: flowslatest.FlowCollectorEBPF{},
155149
},
156150
Loki: flowslatest.FlowCollectorLoki{
157151
Enable: ptr.To(true),

docs/FlowMetric.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ When set to `Egress`, it is equivalent to adding the regular expression filter o
146146
<td><b><a href="#flowmetricspecfiltersindex">filters</a></b></td>
147147
<td>[]object</td>
148148
<td>
149-
`filters` is a list of fields and values used to restrict which flows are taken into account. Oftentimes, these filters must
150-
be used to eliminate duplicates: `Duplicate != "true"` and `FlowDirection = "0"`.
149+
`filters` is a list of fields and values used to restrict which flows are taken into account.
151150
Refer to the documentation for the list of available fields: https://docs.openshift.com/container-platform/latest/observability/network_observability/json-flows-format-reference.html.<br/>
152151
</td>
153152
<td>false</td>

0 commit comments

Comments
 (0)