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

Doc: regenerate API refs (FlowCollector + Flow Format) #550

Merged
merged 8 commits into from
Feb 5, 2024

Conversation

jotak
Copy link
Member

@jotak jotak commented Jan 30, 2024

Flow format is now generated from a fields.yaml file stored here, instead of the console plugin's type definition previously used, as it became more likely to be outdated

A check is added to make sure any field referenced in the frontend config is also defined in fields.yaml

@jotak
Copy link
Member Author

jotak commented Jan 30, 2024

FYI @skrthomas
(let's wait a bit that the dev team reviews it, but that should set the ground for 1.5 API doc)
Also, you'll see that I completely changed the layout of the Flow Format spec: this is because I don't use anymore the previous tooling and now we're more free for designing the way we want. So I've moved away from the previous flat text format, to use a table instead. Pls let me know how it plays with the doc integration...

@jotak
Copy link
Member Author

jotak commented Jan 30, 2024

docs/fields.yaml Outdated
@@ -0,0 +1,129 @@
# Fields definition, used to generate documentation
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add this to the static-frontend-config ?

I would like to get rid of ipfix.ts file from console plugin repo in the end.
We can also rely on these definitions to check if field is a label and add types since the query engine check for numbers.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can surely move that to the config, ok, but it will stay unused in code for the time being, right? at least for this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

well then I can also change my flow-format-validation script into a go test

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, that's a long run refactor 😉


The "Filter ID" column shows which related name to use when defining Quick Filters (see `spec.consolePlugin.quickFilters` in the `FlowCollector` specification).

The "Loki label" column is useful when querying Loki directly: label fields need to be selected using link:https://grafana.com/docs/loki/latest/logql/log_queries/#log-stream-selector[stream selectors].
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need to write this too:

If you are reading this specification as a reference for the Kafka export feature, you must treat all Labels and Fields as regular fields and ignore any distinctions between them that are specific to Loki.

Copy link
Member Author

Choose a reason for hiding this comment

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

No I removed that because now it's not organized by Fields and Labels anymore - it's directly written for Kafka exporter users

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks Joel. I re-copied your latest IBMSG tweaks to my PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

re-copied and pushed latest to my PR.

Comment on lines 487 to 488
// Flaky assertion here, quite annoying, some weirdness with `envtest` maybe?
// Anyway it doesn't bring much value. Disabling it for the time being
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is not tied to the parallelization of the tests. Currently, we are not setting any parameter wich means tests from different packages can run concurently.

	-parallel n
	    Allow parallel execution of test functions that call t.Parallel, and
	    fuzz targets that call t.Parallel when running the seed corpus.
	    The value of this flag is the maximum number of tests to run
	    simultaneously.
	    While fuzzing, the value of this flag is the maximum number of
	    subprocesses that may call the fuzz function simultaneously, regardless of
	    whether T.Parallel is called.
	    By default, -parallel is set to the value of GOMAXPROCS.
	    Setting -parallel to values higher than GOMAXPROCS may cause degraded
	    performance due to CPU contention, especially when fuzzing.
	    Note that -parallel only applies within a single test binary.
	    The 'go test' command may run tests for different packages
	    in parallel as well, according to the setting of the -p flag
	    (see 'go help build').

Adding -p 1 to the go test command ensure each tests to be run separately but highly increase the testing time.
We could also try to use the t.Parallel call in each test checking for Cleanup
Lastly, we can also force different FlowCollector instance name. It's hacky but may work here.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI this PR moved FLP and Monitoring controller tests outside of controllers package so we parallelize creation / deletion of FlowCollector between the 3 packages.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, after many tests, I didn't find issues with parallelism (although I don't guarantee that there aren't any). My guess is that it's ok with parallelism because each controller set up its own envtest environment so they run in isolation. And tbh if this isn't the case, I'm quite surprised to not see many more failures at random places, whereas here this is always the same single test that is failing.
Anyway my understanding of this test failure is finally that this is a timing issue, the CR taking sometimes more time to be actually deleted than the test timeout. So I have this PR for a fix: #557 (and I'll remove my change here)

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted the change here, cf the mentioned PR above

Comment on lines +947 to +954
- name: PktDropLatestState
type: string
description: TCP state on last dropped packet
filter: pkt_drop_state # couldn't guess from config
- name: PktDropLatestDropCause
type: string
description: Latest drop cause
filter: pkt_drop_cause # couldn't guess from config
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- name: PktDropLatestState
type: string
description: TCP state on last dropped packet
filter: pkt_drop_state # couldn't guess from config
- name: PktDropLatestDropCause
type: string
description: Latest drop cause
filter: pkt_drop_cause # couldn't guess from config
- name: PktDropLatestState
type: string
description: TCP state on last dropped packet
- name: PktDropLatestDropCause
type: string
description: Latest drop cause

We keep filter definition in the columns right ?

Comment on lines +65 to +71
type FieldConfig struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"`
Description string `yaml:"description" json:"description"`
LokiLabel bool `yaml:"lokiLabel,omitempty" json:"lokiLabel,omitempty"`
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
type FieldConfig struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"`
Description string `yaml:"description" json:"description"`
LokiLabel bool `yaml:"lokiLabel,omitempty" json:"lokiLabel,omitempty"`
Filter string `yaml:"filter,omitempty" json:"filter,omitempty"`
}
type FieldConfig struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"`
Description string `yaml:"description" json:"description"`
LokiLabel bool `yaml:"lokiLabel,omitempty" json:"lokiLabel,omitempty"`
}

I don't think we should define filters in the field configuration. Filters are already defined in their own section and tied to columns when needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

they aren't defined from there, it's only a reference. In fact, for almost all the fields I didn't need that reference as I could retrieve them from the columns. But there are two exceptions: for drop state and drop cause. These ones don't have the filter defined in column, I guess they must be some kind of special cases in the front implementation? Because of them, as I want to document the existence of these filters, I had to add an explicit reference.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can rename the field filterRef to clarify

Copy link
Contributor

Choose a reason for hiding this comment

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

There are multiple exceptions indeed such as:

  • TimeFlowStartMs / TimeFlowEndMs
  • PktDropLatestState / PktDropLatestDropCause
  • Duplicate

So either we refactor these in the plugin to rely on filters or we force these filter ids from the field config as you initially planned.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see filters for TimeFlowStartMs / TimeFlowEndMs or Duplicate, while they exist for PktDrop stuff (in the filters yaml)

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps a refactoring will be necessary moving forward, but for this PR I didn't intend to do any code change, just extracting whatever data I can for the doc

Copy link

openshift-ci bot commented Feb 2, 2024

@jotak: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-operator 66920aa link false /test e2e-operator

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5d91297) 57.87% compared to head (c6b6db9) 57.89%.

❗ Current head c6b6db9 differs from pull request most recent head 8f04d2b. Consider uploading reports for the commit 8f04d2b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #550      +/-   ##
==========================================
+ Coverage   57.87%   57.89%   +0.02%     
==========================================
  Files          73       73              
  Lines        9543     9543              
==========================================
+ Hits         5523     5525       +2     
  Misses       3684     3684              
+ Partials      336      334       -2     
Flag Coverage Δ
unittests 57.89% <ø> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jotak and others added 8 commits February 5, 2024 09:29
Flow format is now generated from a fields.yaml file stored here,
instead of the console plugin's type definition previously used, as it
became more likely to be outdated

A check is added to make sure any field referenced in the frontend
config is also defined in fields.yaml
Removed hack/flows-format-validation.sh, replaced with a go test
Add type information
- for instance => for example
- may => might

Also use head directive ":_mod-docs-content-type: REFERENCE"
Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>
Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>
@jotak
Copy link
Member Author

jotak commented Feb 5, 2024

@jpinsonneau PR updated (doc regenerated after your updates, reverted flaky test change)

Copy link
Contributor

@jpinsonneau jpinsonneau left a comment

Choose a reason for hiding this comment

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

Looks good for the doc, thanks @jotak !

@openshift-ci openshift-ci bot added the lgtm label Feb 5, 2024
@jotak
Copy link
Member Author

jotak commented Feb 5, 2024

thanks
/approve

Copy link

openshift-ci bot commented Feb 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jotak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Feb 5, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 34fd0ae into netobserv:main Feb 5, 2024
9 of 10 checks passed
jotak added a commit to jotak/network-observability-operator that referenced this pull request Feb 5, 2024
* Doc: regenerate API refs (FlowCollector + Flow Format)

Flow format is now generated from a fields.yaml file stored here,
instead of the console plugin's type definition previously used, as it
became more likely to be outdated

A check is added to make sure any field referenced in the frontend
config is also defined in fields.yaml

* fix validation script

* Merge fields.yaml in static-frontend-config.yaml

Removed hack/flows-format-validation.sh, replaced with a go test
Add type information

* Minor tweaks for IBM style guide

- for instance => for example
- may => might

Also use head directive ":_mod-docs-content-type: REFERENCE"

* Update controllers/consoleplugin/config/static-frontend-config.yaml

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>

* Update hack/asciidoc-flows-gen.sh

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>

* Revert changes on flaky test

* regen doc

---------

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>
jotak added a commit to jotak/network-observability-operator that referenced this pull request Feb 8, 2024
* Doc: regenerate API refs (FlowCollector + Flow Format)

Flow format is now generated from a fields.yaml file stored here,
instead of the console plugin's type definition previously used, as it
became more likely to be outdated

A check is added to make sure any field referenced in the frontend
config is also defined in fields.yaml

* fix validation script

* Merge fields.yaml in static-frontend-config.yaml

Removed hack/flows-format-validation.sh, replaced with a go test
Add type information

* Minor tweaks for IBM style guide

- for instance => for example
- may => might

Also use head directive ":_mod-docs-content-type: REFERENCE"

* Update controllers/consoleplugin/config/static-frontend-config.yaml

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>

* Update hack/asciidoc-flows-gen.sh

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>

* Revert changes on flaky test

* regen doc

---------

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>
openshift-merge-bot bot pushed a commit that referenced this pull request Feb 8, 2024
* Doc: regenerate API refs (FlowCollector + Flow Format)

Flow format is now generated from a fields.yaml file stored here,
instead of the console plugin's type definition previously used, as it
became more likely to be outdated

A check is added to make sure any field referenced in the frontend
config is also defined in fields.yaml

* fix validation script

* Merge fields.yaml in static-frontend-config.yaml

Removed hack/flows-format-validation.sh, replaced with a go test
Add type information

* Minor tweaks for IBM style guide

- for instance => for example
- may => might

Also use head directive ":_mod-docs-content-type: REFERENCE"

* Update controllers/consoleplugin/config/static-frontend-config.yaml



* Update hack/asciidoc-flows-gen.sh



* Revert changes on flaky test

* regen doc

---------

Co-authored-by: Julien Pinsonneau <91894519+jpinsonneau@users.noreply.github.com>
@jotak jotak deleted the regen-doc branch February 8, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants