-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Pass warnings through on non-error responses #599
Conversation
52a4612
to
7eda99c
Compare
On a related note, I've been trying to integrate this warnings behavior as a client and I have to say the behavior/interface is infuriating to use. According to the upstream prom docs the warnings are meant to be non-fatal. If the response has a warning and no error we currently return an
Since this client is returning a non-nil thing that is a warning (and implements
Assuming upstream plans on keeping this behavior (warnings are non-fatal) IMO we should change the signature to pass warning separate from error. As it stands you basically have to rewrite everything once and change passthrough funcs and future coding habits. If we were to change the return to Thoughts? |
@jacksontj yep looks like this implementation make the use of error quite bad so yeah lets try with your original suggestion. |
Ok, I'll try and get a pr together some time this week.
…On Tue, Jun 11, 2019, 6:26 AM Krasi Georgiev ***@***.***> wrote:
@jacksontj <https://github.com/jacksontj> yep looks like this
implementation make the use of error quite bad so yeah lets try with your
original suggestion.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#599?email_source=notifications&email_token=AAMLPHMVKJHTUYDTN2J7BN3PZ6RXNA5CNFSM4HWD4M7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXNDMJA#issuecomment-500839972>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMLPHNCIA6XTRNEPHCAJETPZ6RXNANCNFSM4HWD4M7A>
.
|
@krasi-georgiev here is the change, for now I only wired up warnings to query/queryRange -- as they are the only ones that pass that information back. If these get added to others in the future it would be easy to add -- but I don't think thats planned. |
api/prometheus/v1/api_test.go
Outdated
res, err := test.do() | ||
res, warnings, err := test.do() | ||
|
||
if (test.inWarnings == nil) != (warnings == 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.
I am a bit confused by this. The queryTests
don't have the inWarnings
set anywhere so this will always be true test.inWarnings == 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.
@krasi-georgiev true, I've added a couple cases that do so.
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.
but than you should also check the content right? testutil.Equals(t,test.inWarnings,warnings)
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.
and don't forget the full stop for the comments to follow the golang standards. I know it is annoying until you get used to 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.
Updated again :)
98584bc
to
e384c03
Compare
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
Thanks! |
// Query performs a query for the given time. | ||
Query(ctx context.Context, query string, ts time.Time) (model.Value, api.Error) | ||
Query(ctx context.Context, query string, ts time.Time) (model.Value, api.Warnings, 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 breaks a lot of downstream users of this library who have been relying on go get without a lock file
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.
Unfortunately this was expected, upstream prometheus added these warnings and due to the semantics of those warnings we end up basically requiring this (more discussion in #562).
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.
Personally I'm finding this Warnings
thing a major pain to integrate as it complicates things quite a bit more (and it doesn't really help IMO that its not really a "warning" from prometheus).
Legit, we are not using go ver mgmt, on us in my mind
…On Thu, Jun 13, 2019, 11:54 PM Thomas Jackson ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In api/prometheus/v1/api.go
<#599 (comment)>
:
> // Query performs a query for the given time.
- Query(ctx context.Context, query string, ts time.Time) (model.Value, api.Error)
+ Query(ctx context.Context, query string, ts time.Time) (model.Value, api.Warnings, error)
Unfortunately this was expected, upstream prometheus added these warnings
and due to the semantics of those warnings we end up basically requiring
this (more discussion in #562
<#562>).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#599?email_source=notifications&email_token=AAKTQCB2GOBKOZQHOBVXDHDP2MXBLA5CNFSM4HWD4M7KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB3RGOLA#discussion_r293667153>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKTQCEES7M6MHKBUOA36PDP2MXBLANCNFSM4HWD4M7A>
.
|
Signed-off-by: Thomas Jackson jacksontj.89@gmail.com
Without this we have 2 problems:
(1) we cannot differentiate an error from a warning from the API response body (as the
Err()
method is returning self always(2) we can inadvertently layer these errors together when using
NewErrorAPI
This PR addresses both.