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
k6runner: handle errors reported by http runners #694
Conversation
ce6fae7
to
c12ccda
Compare
465dd58
to
37f228f
Compare
37f228f
to
e3403fb
Compare
internal/k6runner/k6runner.go
Outdated
@@ -111,7 +112,8 @@ func (r Script) Run(ctx context.Context, registry *prometheus.Registry, logger l | |||
return false, err | |||
} | |||
|
|||
return !resultCollector.failure, nil | |||
success := result.Error == "" && result.ErrorCode == "" | |||
return success, nil |
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.
Not sure if at this point we should create an error
with result.Error
and return 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.
It makes sense to do I think
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.
Delved a bit more on what this error is used for, and it seems like it is just log.Warn
ed?
synthetic-monitoring-agent/internal/prober/scripted/scripted.go
Lines 57 to 65 in e3403fb
func (p Prober) Probe(ctx context.Context, target string, registry *prometheus.Registry, logger logger.Logger) bool { | |
success, err := p.script.Run(ctx, registry, logger, p.logger) | |
if err != nil { | |
p.logger.Warn().Err(err).Msg("running probe") | |
return false | |
} | |
return success | |
} |
If this is the case we might want to return an error when the code is something that is not-on-us.
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.
Refined (slang for "made more complicated") the error handling logic in the latest commit, LMK what you think :)
f7bc8f5
to
0681324
Compare
Previously, k6 runners used to communicate errors by returning a non-200 status code, and not returning the logs of the execution. mq proxy, in addition to returning non-200 status codes, also includes an error code and description for errors that occur while running the script.
With the introduction of https://github.com/grafana/sm-k6-runner/pull/153, we now report as errors exceptions being thrown on the script, such as trying to access undefined variables, or invocations of
fail()
. In this scenario, users likely expect to see the check reported as a failure, but also to see the logs and metrics produced by it.This PR changes the error-handling logic, so that the response is always parsed for status code that (should) include it, and the success of the check is calculated by checking if there response contains an error.