Skip to content

Commit

Permalink
NETOBSERV-1298: Add netobserv operator changes to support dup list (#501
Browse files Browse the repository at this point in the history
)

* NETOBSERV-1298: Add netobserv operator changes to support dup list

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>

* add columns definitions to new list fields

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>

* deduper mode frontend config

---------

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
Co-authored-by: Julien Pinsonneau <jpinsonn@redhat.com>
  • Loading branch information
msherif1234 and jpinsonneau authored Jan 18, 2024
1 parent b0ead75 commit 34965b4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
6 changes: 6 additions & 0 deletions controllers/consoleplugin/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ type FilterConfig struct {
Placeholder string `yaml:"placeholder,omitempty" json:"placeholder,omitempty"`
}

type Deduper struct {
Mark bool `yaml:"mark" json:"mark"`
Merge bool `yaml:"merge" json:"merge"`
}

type FrontendConfig struct {
RecordTypes []string `yaml:"recordTypes" json:"recordTypes"`
Columns []ColumnConfig `yaml:"columns" json:"columns"`
Sampling int `yaml:"sampling" json:"sampling"`
Features []string `yaml:"features" json:"features"`
Deduper Deduper `yaml:"deduper" json:"deduper"`

PortNaming flowslatest.ConsolePluginPortConfig `yaml:"portNaming,omitempty" json:"portNaming,omitempty"`
Filters []FilterConfig `yaml:"filters,omitempty" json:"filters,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions controllers/consoleplugin/config/static-frontend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ columns:
filter: interface
default: false
width: 10
- id: FlowDirInts
name: Interfaces and Directions
tooltip: Pairs of network interface and direction of the Flow observed at the Node observation point.
field: FlowDirection
default: false
width: 15
- id: Bytes
name: Bytes
tooltip: The total aggregated number of bytes.
Expand Down
19 changes: 19 additions & 0 deletions controllers/consoleplugin/consoleplugin_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
flowslatest "github.com/netobserv/network-observability-operator/apis/flowcollector/v1beta2"
config "github.com/netobserv/network-observability-operator/controllers/consoleplugin/config"
"github.com/netobserv/network-observability-operator/controllers/constants"
"github.com/netobserv/network-observability-operator/controllers/ebpf"
"github.com/netobserv/network-observability-operator/pkg/helper"
"github.com/netobserv/network-observability-operator/pkg/volumes"
)
Expand Down Expand Up @@ -344,6 +345,7 @@ func (b *builder) setLokiConfig(lconf *config.LokiConfig) {
}

func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) {
var dedupJustMark, dedupMerge bool
if helper.UseEBPF(b.desired) {
if helper.IsPktDropEnabled(&b.desired.Agent.EBPF) {
fconf.Features = append(fconf.Features, "pktDrop")
Expand All @@ -356,12 +358,29 @@ func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) {
if helper.IsFlowRTTEnabled(&b.desired.Agent.EBPF) {
fconf.Features = append(fconf.Features, "flowRTT")
}

if v, ok := b.desired.Agent.EBPF.Debug.Env[ebpf.EnvDedupeJustMark]; ok {
dedupJustMark, _ = strconv.ParseBool(v)
} else {
dedupJustMark, _ = strconv.ParseBool(ebpf.DedupeJustMarkDefault)
}

if v, ok := b.desired.Agent.EBPF.Debug.Env[ebpf.EnvDedupeMerge]; ok {
dedupMerge, _ = strconv.ParseBool(v)
} else {
dedupMerge, _ = strconv.ParseBool(ebpf.DedupeMergeDefault)

}
}
fconf.RecordTypes = helper.GetRecordTypes(&b.desired.Processor)
fconf.PortNaming = b.desired.ConsolePlugin.PortNaming
fconf.QuickFilters = b.desired.ConsolePlugin.QuickFilters
fconf.AlertNamespaces = []string{b.namespace}
fconf.Sampling = helper.GetSampling(b.desired)
fconf.Deduper = config.Deduper{
Mark: dedupJustMark,
Merge: dedupMerge,
}
}

//go:embed config/static-frontend-config.yaml
Expand Down
19 changes: 14 additions & 5 deletions controllers/ebpf/agent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ const (
envLogLevel = "LOG_LEVEL"
envDedupe = "DEDUPER"
dedupeDefault = "firstCome"
envDedupeJustMark = "DEDUPER_JUST_MARK"
dedupeJustMarkDefault = "true"
envGoMemLimit = "GOMEMLIMIT"
envEnablePktDrop = "ENABLE_PKT_DROPS"
envEnableDNSTracking = "ENABLE_DNS_TRACKING"
Expand All @@ -71,6 +69,13 @@ const (
bpfNetNSMountPath = "/var/run/netns"
)

const (
EnvDedupeJustMark = "DEDUPER_JUST_MARK"
EnvDedupeMerge = "DEDUPER_MERGE"
DedupeJustMarkDefault = "true"
DedupeMergeDefault = "false"
)

type reconcileAction int

const (
Expand Down Expand Up @@ -460,21 +465,24 @@ func (c *AgentController) setEnvConfig(coll *flowslatest.FlowCollector) []corev1
}

dedup := dedupeDefault
dedupJustMark := dedupeJustMarkDefault
dedupJustMark := DedupeJustMarkDefault
dedupMerge := DedupeMergeDefault
// we need to sort env map to keep idempotency,
// as equal maps could be iterated in different order
for _, pair := range helper.KeySorted(coll.Spec.Agent.EBPF.Debug.Env) {
k, v := pair[0], pair[1]
if k == envDedupe {
dedup = v
} else if k == envDedupeJustMark {
} else if k == EnvDedupeJustMark {
dedupJustMark = v
} else if k == EnvDedupeMerge {
dedupMerge = v
} else {
config = append(config, corev1.EnvVar{Name: k, Value: v})
}
}
config = append(config, corev1.EnvVar{Name: envDedupe, Value: dedup})
config = append(config, corev1.EnvVar{Name: envDedupeJustMark, Value: dedupJustMark})
config = append(config, corev1.EnvVar{Name: EnvDedupeJustMark, Value: dedupJustMark})
config = append(config, corev1.EnvVar{
Name: envAgentIP,
ValueFrom: &corev1.EnvVarSource{
Expand All @@ -485,6 +493,7 @@ func (c *AgentController) setEnvConfig(coll *flowslatest.FlowCollector) []corev1
},
},
)
config = append(config, corev1.EnvVar{Name: EnvDedupeMerge, Value: dedupMerge})

return config
}

0 comments on commit 34965b4

Please sign in to comment.