-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: validate benchmark type #583
Conversation
This pull request does not have a backport label. Could you fix it @olegsu? 🙏
|
1dc08a6
to
4fa50cf
Compare
Cloudbeat CI 🤖Allure Report: http://csp-allure-reports.s3.amazonaws.com/allure_reports/cloudbeat/prs/583/index.html |
d98fccb
to
aa9af3a
Compare
aa9af3a
to
2ab04f5
Compare
2ba924e
to
f9a9517
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
scripts/common.sh
Outdated
# exec_pod $POD "elastic-agent restart" # https://github.com/elastic/cloudbeat/pull/458#issuecomment-1308837098 | ||
# done | ||
for P in $(get_agents); do | ||
exec_pod $POD "elastic-agent restart" # https://github.com/elastic/cloudbeat/pull/458#issuecomment-1308837098 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the comment.
Also, I just noticed we are missing POD=$(echo $P | cut -d '/' -f 2)
.
Can you verify that it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, will verify
AWSConfig aws.ConfigAWS `config:",inline"` | ||
RuntimeCfg *RuntimeConfig `config:"runtime_cfg"` | ||
Fetchers []*config.C `config:"fetchers"` | ||
KubeConfig string `config:"kube_config"` | ||
Period time.Duration `config:"period"` | ||
Processors processors.PluginConfig `config:"processors"` | ||
BundlePath string `config:"bundle_path"` | ||
Benchmark string `config:"config.v1.benchmark"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change requires a matching change to the integration, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
launcher/launcher.go
Outdated
@@ -239,6 +242,9 @@ func (l *launcher) reconfigureWait(timeout time.Duration) (*config.C, error) { | |||
err := l.validator.Validate(update) | |||
if err != nil { | |||
l.log.Errorf("Config update validation failed: %v", err) | |||
if errors.Is(err, cloudbeat_config.ErrBenchmarkNotSupported) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The launcher was designed in a way it is agnostic to cloudbeat or any Beater
implementation.
In that case, we can extend the Validator
to support a special kind of error that will send that degraded message.
The only difference will be that the Validator
accepts config.C
instead of our struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, we can update the validator behavior to return a boolean whether the configuration is valid or not.
So the validator will also receive the management.Manager
to update the status.
I am not sure it's better as we still have a coupling between the launcher and the validator.
16fcd2b
to
9daf134
Compare
errors/errors.go
Outdated
// can help to end user to operate cloudbeat | ||
// for example when a cloudbeat configuration is invalid, this error will include | ||
// more information about what is missing/expected and maybe links to external sources as well | ||
type CloudbeatError struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked it, since I still don't want the launcher to be aware of cloudbeat I would just rename it.
Maybe BeaterDegradeError
/ BeaterUnhealthyError
or some other name that indicates what is about to happen once this error is returned.
Also, it should reside near the launcher IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good naming, will change the name.
Also, it should reside near the launcher IMO.
This might be an issue with imports
9daf134
to
9f2c7b1
Compare
9f2c7b1
to
1ebe7b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last touch
@@ -239,6 +242,10 @@ func (l *launcher) reconfigureWait(timeout time.Duration) (*config.C, error) { | |||
err := l.validator.Validate(update) | |||
if err != nil { | |||
l.log.Errorf("Config update validation failed: %v", err) | |||
heatlhErr := &cb_errors.BeaterUnhealthyError{} | |||
if errors.As(err, heatlhErr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test this new functionality, it can be a part of TestLauncherValidator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, note that you are checking the error that returned from the Validator
but BeaterUnhealthyError
error is actually returned from config.New
and wrapped in the validator and probably won't get detected here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test this new functionality, it can be a part of
TestLauncherValidator
I dont think we have an easy way to mock the Manager.UpdateStatus
tbh.
Also, note that you are checking the error that returned from the
Validator
butBeaterUnhealthyError
error is actually returned fromconfig.New
and wrapped in the validator and probably won't get detected here.
The test for the errors pkg checking exactly this. First, create the BeaterUnhealthyError
and then wrap it, later test that using errors.As
it will get the original error.
From golang https://pkg.go.dev/errors#As
As finds the first error in err's chain that matches target, and if one is found, sets target to that error value and returns true. Otherwise, it returns false.
errors/errors.go
Outdated
msg string | ||
} | ||
|
||
func New(msg string) BeaterUnhealthyError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, rename the function to indicate the error type, maybe errors.NewBeaterUnhealthy(...)
?
fc5eda9
to
db6084f
Compare
This pull request is now in conflicts. Could you fix it? 🙏
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olegsu LGTM. scripts/common.sh approved.
90b3186
to
36d98fb
Compare
36d98fb
to
db6084f
Compare
This pull request is now in conflicts. Could you fix it? 🙏
|
What does this PR do?
This will use the new
config.v1
structure to validate that the cloudbeat knows how to run the selected benchmark.In case the benchmark is not supported it may fail fast or ignore and update the status.
This PR only uses
config.v1.benchmark
to not deal with the new structure that integrations pr adding ( cc @kfirpeled)Related Issues
Related #239
Related elastic/integrations#4752
Checklist