Skip to content

Commit

Permalink
NETOBSERV-1092 Move CRD fields to advanced (netobserv#467)
Browse files Browse the repository at this point in the history
* move fields to debug

read defaults from CRD

fix merge

Feedback on Debug crd sections

- As suggested by Julien, rename Debug to Advanced
- Merge back loki fields into Loki section

* Add tests + some fixes

- Add webhook tests on Advanced sections
- Fix loki.advanced not being overwritten from anotations on conversion
- StaticLabel isn't a pointer to map anymore, as maps are already
  nillable
- fix alm sample with renamed fields
- generalize CRD setup for all suite_tests

* Fix loki v1beta1 settings ignored and console port setting broken

- Some loki settings, when provided by a v1beta1 CR, were ignored, such as
  batchWait/Size
- Found a minor day-0 bug in console: when the port setting is changed,
  console plugin was unreachable because the pod didn't use that port
(only service did). It seems nobody ever changed that setting >_<

* fix rebase

---------

Co-authored-by: Joel Takvorian <jtakvori@redhat.com>
  • Loading branch information
jpinsonneau and jotak authored Jan 22, 2024
1 parent da4bdd3 commit bf1562e
Show file tree
Hide file tree
Showing 37 changed files with 2,302 additions and 1,284 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ COPY main.go main.go
COPY apis/ apis/
COPY controllers/ controllers/
COPY pkg/ pkg/
COPY config/ config/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags "-X 'main.buildVersion=$BUILD_VERSION' -X 'main.buildDate=`date +%Y-%m-%d\ %H:%M`'" -mod vendor -a -o manager main.go
Expand Down
2 changes: 1 addition & 1 deletion apis/flowcollector/v1alpha1/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ type FlowCollectorEBPF struct {
// excludeInterfaces contains the interface names that will be excluded from flow tracing.
// If an entry is enclosed by slashes (such as `/br-/`), it will match as regular expression,
// otherwise it will be matched as a case-sensitive string.
//+kubebuilder:default=lo;
//+kubebuilder:default:=lo;
ExcludeInterfaces []string `json:"excludeInterfaces,omitempty"`

//+kubebuilder:validation:Enum=trace;debug;info;warn;error;fatal;panic
Expand Down
72 changes: 64 additions & 8 deletions apis/flowcollector/v1alpha1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {

// Processor
dst.Spec.Processor.LogTypes = restored.Spec.Processor.LogTypes
if restored.Spec.Processor.ConversationHeartbeatInterval != nil {
dst.Spec.Processor.ConversationHeartbeatInterval = restored.Spec.Processor.ConversationHeartbeatInterval
if restored.Spec.Processor.Advanced.ConversationHeartbeatInterval != nil {
dst.Spec.Processor.Advanced.ConversationHeartbeatInterval = restored.Spec.Processor.Advanced.ConversationHeartbeatInterval
}
if restored.Spec.Processor.ConversationEndTimeout != nil {
dst.Spec.Processor.ConversationEndTimeout = restored.Spec.Processor.ConversationEndTimeout
if restored.Spec.Processor.Advanced.ConversationEndTimeout != nil {
dst.Spec.Processor.Advanced.ConversationEndTimeout = restored.Spec.Processor.Advanced.ConversationEndTimeout
}
if restored.Spec.Processor.ConversationTerminatingTimeout != nil {
dst.Spec.Processor.ConversationTerminatingTimeout = restored.Spec.Processor.ConversationTerminatingTimeout
if restored.Spec.Processor.Advanced.ConversationTerminatingTimeout != nil {
dst.Spec.Processor.Advanced.ConversationTerminatingTimeout = restored.Spec.Processor.Advanced.ConversationTerminatingTimeout
}
if restored.Spec.Processor.Metrics.DisableAlerts != nil {
dst.Spec.Processor.Metrics.DisableAlerts = restored.Spec.Processor.Metrics.DisableAlerts
Expand Down Expand Up @@ -168,14 +168,14 @@ func Convert_v1alpha1_FlowCollectorLoki_To_v1beta2_FlowCollectorLoki(in *FlowCol
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta1 not in v1alpha1
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_FlowCollectorConsolePlugin_To_v1alpha1_FlowCollectorConsolePlugin(in *v1beta2.FlowCollectorConsolePlugin, out *FlowCollectorConsolePlugin, s apiconversion.Scope) error {
return autoConvert_v1beta2_FlowCollectorConsolePlugin_To_v1alpha1_FlowCollectorConsolePlugin(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta1 not in v1alpha1
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_FlowCollectorEBPF_To_v1alpha1_FlowCollectorEBPF(in *v1beta2.FlowCollectorEBPF, out *FlowCollectorEBPF, s apiconversion.Scope) error {
return autoConvert_v1beta2_FlowCollectorEBPF_To_v1alpha1_FlowCollectorEBPF(in, out, s)
Expand Down Expand Up @@ -336,3 +336,59 @@ func Convert_v1alpha1_FLPMetrics_To_v1beta2_FLPMetrics(in *FLPMetrics, out *v1be
out.IncludeList = metrics.GetAsIncludeList(in.IgnoreTags, nil)
return autoConvert_v1alpha1_FLPMetrics_To_v1beta2_FLPMetrics(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_FlowCollectorConsolePlugin_To_v1beta2_FlowCollectorConsolePlugin(in *FlowCollectorConsolePlugin, out *v1beta2.FlowCollectorConsolePlugin, s apiconversion.Scope) error {
return autoConvert_v1alpha1_FlowCollectorConsolePlugin_To_v1beta2_FlowCollectorConsolePlugin(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_FlowCollectorFLP_To_v1beta2_FlowCollectorFLP(in *FlowCollectorFLP, out *v1beta2.FlowCollectorFLP, s apiconversion.Scope) error {
return autoConvert_v1alpha1_FlowCollectorFLP_To_v1beta2_FlowCollectorFLP(in, out, s)
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_DebugConfig_To_v1beta2_AdvancedAgentConfig(in *DebugConfig, out *v1beta2.AdvancedAgentConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_AdvancedAgentConfig_To_v1alpha1_DebugConfig(in *v1beta2.AdvancedAgentConfig, out *DebugConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_DebugConfig_To_v1beta2_AdvancedProcessorConfig(in *DebugConfig, out *v1beta2.AdvancedProcessorConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1beta2_AdvancedProcessorConfig_To_v1alpha1_DebugConfig(in *v1beta2.AdvancedProcessorConfig, out *DebugConfig, s apiconversion.Scope) error {
out.Env = in.Env
return nil
}

// This function need to be manually created because conversion-gen not able to create it intentionally because
// we have new defined fields in v1beta2 not in v1alpha1
// nolint:golint,stylecheck,revive
func Convert_v1alpha1_FlowCollectorEBPF_To_v1beta2_FlowCollectorEBPF(in *FlowCollectorEBPF, out *v1beta2.FlowCollectorEBPF, s apiconversion.Scope) error {
out.Advanced = &v1beta2.AdvancedAgentConfig{
Env: in.Debug.Env,
}
return autoConvert_v1alpha1_FlowCollectorEBPF_To_v1beta2_FlowCollectorEBPF(in, out, s)
}
Loading

0 comments on commit bf1562e

Please sign in to comment.