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

Remove runtime config logic #597

Merged
merged 9 commits into from
Dec 27, 2022

Conversation

jeniawhite
Copy link
Contributor

@jeniawhite jeniawhite commented Dec 21, 2022

What does this PR do?
Removes the runtime config logic

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary README/documentation (if appropriate)
  • TODO: Need to bump the policy version prior to merging this PR

@mergify
Copy link

mergify bot commented Dec 21, 2022

This pull request does not have a backport label. Could you fix it @jeniawhite? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit
    NOTE: backport-skip has been added to this pull request.

@jeniawhite jeniawhite marked this pull request as draft December 21, 2022 16:44
@github-actions
Copy link

@jeniawhite jeniawhite marked this pull request as ready for review December 22, 2022 09:25
Copy link
Collaborator

@oren-zohar oren-zohar left a comment

Choose a reason for hiding this comment

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

looking at the new config.v1 format, it seems like we moved the credentials to there also, yet we still read our credentials from the flat version. Not sure if we should also address this change here, to fully migrate to the new format wdyt? nvm out of scope

Also, did you test this E2E? @jeniawhite

Comment on lines +33 to +35
// TODO: Should we check something?
// Benchmark is being checked inside config.New
_, err := config.New(cfg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like the validation inside config should be here

if c.Benchmark != "" {
if !isSupportedBenchmark(c.Benchmark) {
	return c, ErrBenchmarkNotSupported
	}
}

Copy link
Contributor Author

@jeniawhite jeniawhite Dec 25, 2022

Choose a reason for hiding this comment

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

I've considered moving the validation to the validator but that would require us to move logic from the config package to the beater package.
Which requires recoding parts of the cloudbeat like newCloudbeat signatures and etc...
Reconsidering the existing solution I did not see any value in the validator, because we use the same validation for non-fleet managed configs and reconfigurations.
This is why I've consolidated the validity checks in the config constructor and removed the validator.

Would be great to get your input on that @amirbenun.

@jeniawhite
Copy link
Contributor Author

@oren-zohar
Yeah, I've run the E2E test once again after removing the validator and consolidating logic inside the config and I can see the same amount of findings as the 8.7 SNAPSHOT without my changes.
Screen Shot 2022-12-25 at 18 48 00

Copy link
Contributor

@amirbenun amirbenun left a comment

Choose a reason for hiding this comment

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

IMO, we should keep decoupling cloudbeat and the launcher.
For that PR, it means that the validator should remain as an abstraction layer for beater specific use cases. Even if the validator only calls another validation function for the config.

@mergify
Copy link

mergify bot commented Dec 27, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b evgb-RemoveRuntimeConfig upstream/evgb-RemoveRuntimeConfig
git merge upstream/main
git push upstream evgb-RemoveRuntimeConfig

@jeniawhite
Copy link
Contributor Author

@amirbenun Rolled back to the commit that leaves the validator.
I Ran an E2E test again to verify that I get everything:
Screen Shot 2022-12-27 at 16 54 40

@jeniawhite jeniawhite requested a review from amirbenun December 27, 2022 14:59
Copy link
Contributor

@amirbenun amirbenun left a comment

Choose a reason for hiding this comment

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

LGTM

Result: fetcherResult,
ActivatedRules: o.activatedRules,
Result: fetcherResult,
Benchmark: o.benchmark,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am missing some context here, did we change all the rules in a way they will run only when their benchmark is on?

@@ -17,7 +17,7 @@

package version

const policyVersion = "v1.2.3"
const policyVersion = "v1.2.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that's your matching change for the rules?

@jeniawhite jeniawhite merged commit 7e36649 into elastic:main Dec 27, 2022
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.

3 participants