Skip to content

Commit

Permalink
Fix operator for FLP breaking changes (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
jotak authored Mar 8, 2023
1 parent d337f77 commit 503646d
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 57 deletions.
25 changes: 14 additions & 11 deletions controllers/flowlogspipeline/flp_common_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,10 @@ func (b *builder) addTransformStages(stage *config.PipelineBuilderStage) error {

// prometheus stage (encode) configuration
promEncode := api.PromEncode{
Port: int(b.desired.Processor.Metrics.Server.Port),
Prefix: "netobserv_",
Metrics: promMetrics,
}

if b.desired.Processor.Metrics.Server.TLS.Type != flowslatest.ServerTLSDisabled {
promEncode.TLS = &api.PromTLSConf{
CertPath: helper.GetSingleCertPath(b.promTLS, promCerts),
KeyPath: helper.GetSingleKeyPath(b.promTLS, promCerts),
}
}

enrichedStage.EncodePrometheus("prometheus", promEncode)
b.addCustomExportStages(&enrichedStage)

Expand Down Expand Up @@ -520,14 +512,25 @@ func getKafkaTLS(tls *flowslatest.ClientTLS) *api.ClientTLS {
// returns a configmap with a digest of its configuration contents, which will be used to
// detect any configuration change
func (b *builder) configMap(stages []config.Stage, parameters []config.StageParam) (*corev1.ConfigMap, string, error) {
metricsSettings := config.MetricsSettings{
Port: int(b.desired.Processor.Metrics.Server.Port),
Prefix: "netobserv_",
NoPanic: true,
}
if b.desired.Processor.Metrics.Server.TLS.Type != flowslatest.ServerTLSDisabled {
metricsSettings.TLS = &api.PromTLSConf{
CertPath: helper.GetSingleCertPath(b.promTLS, promCerts),
KeyPath: helper.GetSingleKeyPath(b.promTLS, promCerts),
}
}
config := map[string]interface{}{
"log-level": b.desired.Processor.LogLevel,
"health": map[string]interface{}{
"port": b.desired.Processor.HealthPort,
},
"pipeline": stages,
"parameters": parameters,
"metrics-settings": config.MetricsSettings{Prefix: "netobserv_", NoPanic: true},
"pipeline": stages,
"parameters": parameters,
"metricsSettings": metricsSettings,
}
if b.desired.Processor.ProfilePort > 0 {
config["profile"] = map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion controllers/flowlogspipeline/flp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func TestConfigMapShouldDeserializeAsJSON(t *testing.T) {
assert.EqualValues([]string{"SrcK8S_Namespace", "SrcK8S_OwnerName", "DstK8S_Namespace", "DstK8S_OwnerName", "FlowDirection", "_RecordType"}, lokiCfg.Labels)
assert.Equal(`{app="netobserv-flowcollector"}`, fmt.Sprintf("%v", lokiCfg.StaticLabels))

assert.Equal(cfg.Processor.Metrics.Server.Port, int32(params[5].Encode.Prom.Port))
assert.Equal(cfg.Processor.Metrics.Server.Port, int32(decoded.MetricsSettings.Port))
}

func TestAutoScalerUpdateCheck(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/mitchellh/mapstructure v1.4.3
github.com/netobserv/flowlogs-pipeline v0.1.8
github.com/netobserv/flowlogs-pipeline v0.1.9-0.20230308074144-04f8a14d4ccf
github.com/onsi/ginkgo/v2 v2.1.3
github.com/onsi/gomega v1.19.0
github.com/openshift/api v0.0.0-20220112145620-704957ce4980
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/netobserv/flowlogs-pipeline v0.1.8 h1:1ovL1alrpYhpoAmm1WDZ5OUF2SmsAYShM851bteDBsQ=
github.com/netobserv/flowlogs-pipeline v0.1.8/go.mod h1:c5wzfwfWT3PBqZBKuHfoaWulHuiJfEmVNTZlaPqIWrs=
github.com/netobserv/flowlogs-pipeline v0.1.9-0.20230308074144-04f8a14d4ccf h1:eOb6az0JNGxdCMRVw8BBcMQo/b1u9a+aASZlzvifRHI=
github.com/netobserv/flowlogs-pipeline v0.1.9-0.20230308074144-04f8a14d4ccf/go.mod h1:eCNls81KUt1dBiEVcB6gOKsCVjXRAcXcscWKTZsSu1k=
github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500 h1:RmnoJe/ci5q+QdM7upFdxiU+D8F3L3qTd5wXCwwHefw=
github.com/netobserv/prometheus-common v0.31.2-0.20220720134304-43e74fd22881 h1:hx5bi6xBovRjmwUoVJBzhJ3EDo4K4ZUsqqKrJuQ2vMI=
github.com/netobserv/prometheus-common v0.31.2-0.20220720134304-43e74fd22881/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 503646d

Please sign in to comment.