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

Use refactored confgen for metrics #142

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

jotak
Copy link
Member

@jotak jotak commented Jul 27, 2022

Requires: netobserv/flowlogs-pipeline#267

Opened as draft until the above is merged

cc @KalmanMeth there's a couple of little changes on top of what you added :

  • Interface with confgen is reduced to only what is needed here: calling "ParseDefinition" and "GenerateTruncatedConfig". So we don't need anymore the intermediate temporary files
  • Propagate errors to caller

@openshift-ci
Copy link

openshift-ci bot commented Jul 27, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@jotak jotak force-pushed the use-refactored-confgen branch from 8a15c87 to b0e5bb4 Compare July 29, 2022 09:15
@jotak jotak requested review from jpinsonneau and ronensc July 29, 2022 09:15
@jotak jotak marked this pull request as ready for review July 29, 2022 09:15
@jotak jotak force-pushed the use-refactored-confgen branch from b0e5bb4 to d97d013 Compare July 29, 2022 09:16
func TestMergeMetricsConfigurationNoIgnore(t *testing.T) {
assert := assert.New(t)

flp := getFLPConfig()
FlpMetricsConfigDir = "test_metrics_definitions"
FlpMetricsConfig = TestFlpMetricsConfig

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea here was to use a well-known (unchanging) set of metrics for testing, and not the current version in metrics_definitions, which might change from time-to-time. If we use the regular metrics_definitions, they whenever we make changes to metrics_definitions we may also have to update the test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, but on the other hand, there's also some value in testing the actual embedded metrics (making sure it's correctly formed, etc.). Could be a bit more maintenance , but it also increases coverage

@openshift-ci openshift-ci bot added the lgtm label Jul 31, 2022
@KalmanMeth KalmanMeth assigned jotak and unassigned KalmanMeth Jul 31, 2022
@jotak jotak force-pushed the use-refactored-confgen branch from d97d013 to 0243e3f Compare August 1, 2022 10:12
@openshift-ci openshift-ci bot removed the lgtm label Aug 1, 2022
@jotak jotak force-pushed the use-refactored-confgen branch from 0243e3f to 3805c93 Compare August 2, 2022 13:28
- Simplified interface with confgen: just call "ParseDefinition" and
  "GenerateTruncatedConfig"
- Propagate errors to caller
@jotak jotak force-pushed the use-refactored-confgen branch from 3805c93 to 1168cec Compare August 3, 2022 07:40
srcPath := FlpMetricsConfigDir + "/" + fileName
destPath := tmpMetricsDefinitionsDir + "/" + fileName
input, err := FlpMetricsConfig.ReadFile(srcPath)
srcPath := metricsConfigDir + "/" + fileName
Copy link
Contributor

Choose a reason for hiding this comment

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

Could filepath.Join() be used to build srcPath?
https://pkg.go.dev/path/filepath#Join

Comment on lines 432 to 433
config := map[string]interface{}{
"log-level": b.desired.LogLevel,
Copy link
Contributor

Choose a reason for hiding this comment

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

config.ConfigFileStruct can be used instead of map[string]interface{}

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm there are some weird things happening here: ConfigFileStruct doesn't have health. Seems like the output of confgen isn't exactly the input of flp ?

Copy link
Member Author

Choose a reason for hiding this comment

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

also LogLevel exists in ConfigFileStruct but it seems unused (see config.ParseConfig => it doesn't fill log-level).
I guess some more cleanup should be done on FLP

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code of FLP's main, it seems to me that FLP accepts the health port only from the command line arguments.
https://github.com/netobserv/flowlogs-pipeline/blob/d7656a24bb2417bfd2fec25f75fb1ee077c1b86e/cmd/flowlogs-pipeline/main.go
If I'm correct, I think it's a bug in FLP that it doesn't allow the health port to be set from the config file.

Copy link
Member Author

@jotak jotak Aug 3, 2022

Choose a reason for hiding this comment

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

I think it works, as it uses viper which accepts a config file as a substitute to command line args.
But viper does use any of the declared model that we have, so that's why it is a little bit confusing IMO

@jotak
Copy link
Member Author

jotak commented Aug 3, 2022

/approve
@ronensc I'm doing a second PR to try fixing some flaky tests, I'll use the filepath.Join as part of it

@openshift-ci
Copy link

openshift-ci bot commented Aug 3, 2022

[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 Aug 3, 2022
@openshift-ci openshift-ci bot merged commit f1b1989 into netobserv:main Aug 3, 2022
@jotak jotak deleted the use-refactored-confgen branch December 7, 2022 04:01
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.

4 participants