Skip to content

Conversation

@mariomac
Copy link

@mariomac mariomac commented Mar 3, 2022

It integrates the following components from the old Goflow-Kube repository:

  • Kube metadata enricher and Informers. There is already a Kube Enricher with its own informers but the output transformation was not the same as the Goflow-Kube payload. In later PRs we can work on merging both and/or adapting the dependant services to the new format.
  • End-to-End pipeline test directly taken from Goflow-Kube to verify the compatiblity of the output messages.
  • Some changes done to the API to improve testability of the code.

Port int `yaml:"port" doc:"the port number to listen on"`
HostName string `yaml:"hostName" doc:"the hostname to listen on"`
Port int `yaml:"port" doc:"the port number to listen on"`
BatchMaxLen int `yaml:"batchMaxLen" doc:"the number of accumulated flows before being forwarded for processing"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

@eranra @mariomac Do we also want to be able to specify a timeout value after which to send whatever we have?

Copy link
Author

Choose a reason for hiding this comment

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

Good point. We can do this or we can try what was discussed in a previous PR: to forward flows one by one via channels. In that case, we don't need neither BatchMaxLen nor BatchTimeout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mariomac I like the one-by-one + channels approach ... getting more performance by "multi-thread/core" is what we need.

Comment on lines 89 to 91
type KubeEnrich struct {
KubeConfigPath string `json:"kubeConfigPath"`
IPFields map[string]string `json:"ipFields"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this perhaps go into the api directory and get included in the api.md?

@codecov-commenter
Copy link

Codecov Report

Merging #120 (a8ec50c) into main (e0d95f2) will increase coverage by 3.69%.
The diff coverage is 58.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
+ Coverage   54.63%   58.32%   +3.69%     
==========================================
  Files          47       52       +5     
  Lines        2709     3141     +432     
==========================================
+ Hits         1480     1832     +352     
- Misses       1129     1184      +55     
- Partials      100      125      +25     
Flag Coverage Δ
unittests 58.32% <58.59%> (+3.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/config/config.go 50.00% <ø> (ø)
pkg/pipeline/transform/kubernetes/kubernetes.go 14.37% <0.00%> (-0.18%) ⬇️
pkg/pipeline/transform/transform.go 100.00% <ø> (ø)
pkg/pipeline/transform/netobserv/meta.go 33.62% <33.62%> (ø)
pkg/pipeline/pipeline.go 91.89% <40.00%> (-8.11%) ⬇️
pkg/test/utils.go 65.51% <40.00%> (-13.44%) ⬇️
pkg/pipeline/transform/netobserv/enrich.go 53.40% <53.40%> (ø)
pkg/pipeline/pipeline_builder.go 53.84% <55.55%> (+0.21%) ⬆️
pkg/test/ipfix.go 69.86% <69.86%> (ø)
pkg/pipeline/ingest/ingest_collector.go 80.50% <80.00%> (+80.50%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0d95f2...a8ec50c. Read the comment docs.

@@ -0,0 +1,201 @@
package pipeline
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mariomac if this is "specific" for some "use-case" or "scenario" ... maybe the right thing is to open a folder called scenarios and put the test file inside this folder. We might have more "use-cases" tests in the future. Also, can you think of some other name for "netobs" it is not informative? Maybe something like a redhat-ocp scenario or something like that. We need to think on this repo as being an upstream repo.

Copy link
Author

@mariomac mariomac Mar 7, 2022

Choose a reason for hiding this comment

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

This was located here because tests we often rely on private APIs. But you are right when you say that this is only a scenario-addressed test.

I think that, for the moment, I will remove this test, as it relies on other components that are already tested.

In a future, I think it would be nice to enable integration tests that do not rely on any private API:

  1. Enabling tests that are run via docker-compose, as it is actually being done.
  2. Changing the components' constructors to not be constructed directly from a configuration file but allowing dependency injection.


// Values taken from https://www.iana.org/assignments/ipfix/ipfix.xhtml
var (
sourceIPv4Address = entities.NewInfoElement("sourceIPv4Address", 8, entities.Ipv4Address, 0, 4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This "feels" like end-to-end test ... and very specific to IPFIX ... do we need this ... what component is being tested here ???

Copy link
Author

Choose a reason for hiding this comment

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

This is used to test the Ingest Collector (ingest_collector_test.go), as it remained untested.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mariomac ok ... this looks good to me ... the only comment small comment I have is that maybe it makes sense to put this file, and maybe also the Loki mock file under some "internal" folder underneath "test" and not directly in test.


// The IPFIX client might send information before the Ingester is actually listening,
// so we might need to repeat the submission
test.Eventually(t, timeout, func(t require.TestingT) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really do not like "inconsistent" tests ... can we make this test more robust and drop the Eventually concept ... the entire Eventually concept feels like hiding from creating a consistent and deterministic test.

Copy link
Author

Choose a reason for hiding this comment

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

In this case, the "Eventually" is not hiding an inconsistent test but addressing a synchronization issue. Goflow2 is initializing in an internal, background goroutine, and there is no way that we can know when it has started to accept flows (as UDP connections are uni-directional).

There are two ways to address this:

  1. Adding a Timeout of e.g. 1-2 seconds, but that would cause that this test is slow.
  2. Keep sending flows until we observe that they are being forwarded.

In the next commit, I have rewritten the test to be more explicit that we follow case 2, without giving the impression of flakyness.

Copy link
Collaborator

@eranra eranra left a comment

Choose a reason for hiding this comment

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

@mariomac thanks ... this looks very good to me

@mariomac mariomac merged commit e7919b2 into netobserv:main Mar 8, 2022
@mariomac mariomac deleted the netobserv-flows branch March 8, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants