-
Notifications
You must be signed in to change notification settings - Fork 351
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
OPA: Fail fast on discovery or bundle download errors #3120
base: master
Are you sure you want to change the base?
Conversation
73bdf5a
to
583fc58
Compare
c838d65
to
0b106c2
Compare
0f696aa
to
6f69e3c
Compare
Addressing the race condition in the upstream as a part of this reported issue. |
d32f5f3
to
45183e6
Compare
4a1d25e
to
0fe55f1
Compare
failed chan error, | ||
prefix string, | ||
) { | ||
if status.Code == "bundle_error" { |
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 still feels like we are only handling a subset of errors, is this really reliable? My understanding was that the Code only gives information about what went wrong and that length(status.Errors) essentially gives yoj if anything goes wrong…
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.
That indeed is more intuitive, but had below concerns.
When looking at the OPA implementation below, status.Errors
it is set only in 1 occasion out of the 3. But the other 2 occasions set status.Errors
to nil even though it is setting an error. Based on the existing implementation status.Code is most reliable as I see.
I also understand if the bundle_error
constant is ever modified then we are in trouble. But then again, just relying on code to be non-empty is also not good if the code got ever set in an non-errornous scenario.
Status Error code segment, /plugins/bundle/status.go#L64-L97
const (
errCode = "bundle_error"
)
func (s *Status) SetError(err error) {
var (
astErrors ast.Errors
httpError download.HTTPError
)
switch {
case err == nil:
s.Code = ""
s.HTTPCode = ""
s.Message = ""
s.Errors = nil
case errors.As(err, &astErrors):
s.Code = errCode
s.HTTPCode = ""
s.Message = types.MsgCompileModuleError
s.Errors = make([]error, len(astErrors))
for i := range astErrors {
s.Errors[i] = astErrors[i]
}
case errors.As(err, &httpError):
s.Code = errCode
s.HTTPCode = json.Number(strconv.Itoa(httpError.StatusCode))
s.Message = err.Error()
s.Errors = nil
default:
s.Code = errCode
s.HTTPCode = ""
s.Message = err.Error()
s.Errors = 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.
Sounds like we want to reach out to styra to make a proper error handling possible.
I also wonder about the typing here. Status.HTTPCode being a string and httpError not being an error, what the hack is this code?
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.
Will raise this in the OPA community and get back.
PS: open-policy-agent/opa#6983 raised with minimum changes that will help us here. Will take it forward based on review.
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.
Went ahead with the bundle_error
constant as a change there will be communicated in OPA release notes.
Moving to draft as using OPA 0.67.0, which is yet to be taken by Skipper dependency upgrades. |
OPA 0.67.1 is merged now. |
f2b5ca6
to
47d31f2
Compare
Signed-off-by: Magnus Jungsbluth <[email protected]>
6849365
to
07ebb8c
Compare
…errors. Signed-off-by: Pushpalanka Jayawardhana <[email protected]>
07ebb8c
to
ed756e6
Compare
Signed-off-by: Pushpalanka Jayawardhana <[email protected]>
1bfa347
to
e67d998
Compare
…ering Signed-off-by: Pushpalanka Jayawardhana <[email protected]>
e67d998
to
0b857aa
Compare
Signed-off-by: Pushpalanka Jayawardhana <[email protected]>
Signed-off-by: Pushpalanka Jayawardhana <[email protected]>
Requesting a review as the PR goes green without the 2 ToDo's to be addressed to unregister the listeners. |
As part of #3119, this PR changes the behaviour on starting up OPA instances inside the OPA based Skipper filters.
Currently even in the face of download errors of bundles, the default timeout of 30s is applied.
By using listeners both for bundle download and discovery bundle download, we can detect a failure early despite the respective plugins still waiting for the bundles to become available.
Still a draft because tests are missing, there are some cleanups in the code that need to be done.
Pending: Unregister discovery and bundle plugin listeners.