Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those const are used only locally no need for CAPs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually using these in consoleplugin_objects.go so I need to expose them.

Would you prefer to move these to constants.go ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry my mistake that should be fine then
/lgtm

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
}
Loading