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-627: merge Agent and FLP #502

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions apis/flowcollector/v1beta1/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,7 @@ type FlowCollectorFLP struct {
//+kubebuilder:validation:Minimum=1025
//+kubebuilder:validation:Maximum=65535
//+kubebuilder:default:=2055
// Port of the flow collector (host port).
// By convention, some values are forbidden. It must be greater than 1024 and different from
// 4500, 4789 and 6081.
// [Deprecated (*)] Port of the flow collector (host port). It is not used anymore and will be removed in a future version.
Port int32 `json:"port,omitempty"`

//+kubebuilder:validation:Minimum=1
Expand Down
4 changes: 1 addition & 3 deletions apis/flowcollector/v1beta2/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,7 @@ type AdvancedProcessorConfig struct {
//+kubebuilder:validation:Maximum=65535
//+kubebuilder:default:=2055
//+optional
// Port of the flow collector (host port).
// By convention, some values are forbidden. It must be greater than 1024 and different from
// 4500, 4789 and 6081.
// [Deprecated (*)] Port of the flow collector (host port). It is not used anymore and will be removed in a future version.
Port *int32 `json:"port,omitempty"`

//+kubebuilder:validation:Minimum=1
Expand Down
12 changes: 6 additions & 6 deletions bundle/manifests/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2674,9 +2674,9 @@ spec:
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention,
some values are forbidden. It must be greater than 1024 and
different from 4500, 4789 and 6081.
description: '[Deprecated (*)] Port of the flow collector (host
port). It is not used anymore and will be removed in a future
version.'
format: int32
maximum: 65535
minimum: 1025
Expand Down Expand Up @@ -4968,9 +4968,9 @@ spec:
type: integer
port:
default: 2055
description: Port of the flow collector (host port). By convention,
some values are forbidden. It must be greater than 1024
and different from 4500, 4789 and 6081.
description: '[Deprecated (*)] Port of the flow collector
(host port). It is not used anymore and will be removed
in a future version.'
format: int32
maximum: 65535
minimum: 1025
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,14 +1041,6 @@ spec:
- list
- update
- watch
- apiGroups:
- security.openshift.io
resourceNames:
- hostnetwork
resources:
- securitycontextconstraints
verbs:
- use
- apiGroups:
- authentication.k8s.io
resources:
Expand Down
12 changes: 6 additions & 6 deletions config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2661,9 +2661,9 @@ spec:
type: boolean
port:
default: 2055
description: Port of the flow collector (host port). By convention,
some values are forbidden. It must be greater than 1024 and
different from 4500, 4789 and 6081.
description: '[Deprecated (*)] Port of the flow collector (host
port). It is not used anymore and will be removed in a future
version.'
format: int32
maximum: 65535
minimum: 1025
Expand Down Expand Up @@ -4955,9 +4955,9 @@ spec:
type: integer
port:
default: 2055
description: Port of the flow collector (host port). By convention,
some values are forbidden. It must be greater than 1024
and different from 4500, 4789 and 6081.
description: '[Deprecated (*)] Port of the flow collector
(host port). It is not used anymore and will be removed
in a future version.'
format: int32
maximum: 65535
minimum: 1025
Expand Down
8 changes: 0 additions & 8 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,3 @@ rules:
- list
- update
- watch
- apiGroups:
- security.openshift.io
resourceNames:
- hostnetwork
resources:
- securitycontextconstraints
verbs:
- use
31 changes: 3 additions & 28 deletions controllers/consoleplugin/consoleplugin_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

osv1alpha1 "github.com/openshift/api/console/v1alpha1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
appsv1 "k8s.io/api/apps/v1"
ascv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
Expand All @@ -20,7 +20,6 @@ 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/loki"
"github.com/netobserv/network-observability-operator/pkg/volumes"
Expand Down Expand Up @@ -350,15 +349,6 @@ func (b *builder) setLokiConfig(lconf *config.LokiConfig) {
}

func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) error {
var err error
dedupJustMark, err := strconv.ParseBool(ebpf.DedupeJustMarkDefault)
if err != nil {
return err
}
dedupMerge, err := strconv.ParseBool(ebpf.DedupeMergeDefault)
if err != nil {
return err
}
if helper.IsPktDropEnabled(&b.desired.Agent.EBPF) {
fconf.Features = append(fconf.Features, "pktDrop")
}
Expand All @@ -371,29 +361,14 @@ func (b *builder) setFrontendConfig(fconf *config.FrontendConfig) error {
fconf.Features = append(fconf.Features, "flowRTT")
}

if b.desired.Agent.EBPF.Advanced != nil {
if v, ok := b.desired.Agent.EBPF.Advanced.Env[ebpf.EnvDedupeJustMark]; ok {
dedupJustMark, err = strconv.ParseBool(v)
if err != nil {
return err
}
}

if v, ok := b.desired.Agent.EBPF.Advanced.Env[ebpf.EnvDedupeMerge]; ok {
dedupMerge, err = strconv.ParseBool(v)
if err != nil {
return err
}
}
}
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,
Mark: helper.UseDedupJustMark(b.desired),
Merge: helper.UseDedupMerge(b.desired),
}
if helper.IsMultiClusterEnabled(&b.desired.Processor) {
fconf.Features = append(fconf.Features, "multiCluster")
Expand Down
51 changes: 0 additions & 51 deletions controllers/consoleplugin/consoleplugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,57 +330,6 @@ func TestConfigMapContent(t *testing.T) {
assert.Equal(config.Frontend.Deduper.Merge, false)
}

func TestConfigMapError(t *testing.T) {
assert := assert.New(t)

agentSpec := flowslatest.FlowCollectorAgent{
Type: "eBPF",
EBPF: flowslatest.FlowCollectorEBPF{
Sampling: ptr.To(int32(1)),
Advanced: &flowslatest.AdvancedAgentConfig{
Env: map[string]string{
"DEDUPER_JUST_MARK": "invalid",
},
},
},
}
lokiSpec := flowslatest.FlowCollectorLoki{}
loki := helper.NewLokiConfig(&lokiSpec, "any")

// spec with invalid flag
spec := flowslatest.FlowCollectorSpec{
Agent: agentSpec,
ConsolePlugin: getPluginConfig(),
Loki: lokiSpec,
}
builder := newBuilder(testNamespace, testImage, &spec, &loki)
cm, _, err := builder.configMap()
assert.Nil(cm)
assert.NotNil(err)

// update to valid flags
agentSpec.EBPF.Advanced.Env = map[string]string{
"DEDUPER_JUST_MARK": "false",
"DEDUPER_MERGE": "true",
}
spec = flowslatest.FlowCollectorSpec{
Agent: agentSpec,
ConsolePlugin: getPluginConfig(),
Loki: lokiSpec,
}
builder = newBuilder(testNamespace, testImage, &spec, &loki)
cm, _, err = builder.configMap()
assert.NotNil(cm)
assert.Nil(err)

// parse output config and check expected values
var config config.PluginConfig
err = yaml.Unmarshal([]byte(cm.Data["config.yaml"]), &config)
assert.Nil(err)
assert.Equal(config.Frontend.Deduper.Mark, false)
assert.Equal(config.Frontend.Deduper.Merge, true)
}

func TestServiceUpdateCheck(t *testing.T) {
assert := assert.New(t)
old := getServiceSpecs()
Expand Down
Loading
Loading