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

Report a watch error instead of eating it when we can't decode #73937

Open
wants to merge 1 commit into
base: master
from

Conversation

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 11, 2019

Clients are required to handle watch events of type ERROR, so instead
of eating the decoding error we should pass it on to the client. Use
NewGenericServerError with isUnexpectedResponse to indicate that we
didn't get the bytes from the server we were expecting. For watch, the
415 error code is roughly correct and we will return an error to the
client that makes debugging a failure in either server watch or client
machinery much easier.

We do not alter the behavior when it appears the response is an EOF
or other disconnection.

/kind bug

This was discovered while writing an e2e test to verify #62175

NONE
@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Feb 11, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@smarterclayton

This comment has been minimized.

Copy link
Contributor Author

smarterclayton commented Feb 12, 2019

I may change this to an internal error instead of a 418, to be consistent with when we fail to renegotiate.

@logicalhan
Copy link
Contributor

logicalhan left a comment

/lgtm

t.Fatalf("unexpected close")
}
if evt.Type != Error {
t.Fatalf("unexpected type: %#v", evt)

This comment has been minimized.

@logicalhan

logicalhan Feb 12, 2019

Contributor

nitpick: I like Errorf here, since it would allow us to continue to the next assertion. This doesn't feel like a fatal assertion to me.

This comment has been minimized.

@smarterclayton

smarterclayton Feb 12, 2019

Author Contributor

If the type doesn't match, the object isn't really relevant. We usually exit early in unit tests, like we do for normal method calls.

In this case though we can simply test both conditions in the same if, which I think accomplishes your objective.

This comment has been minimized.

@logicalhan

logicalhan Feb 12, 2019

Contributor

Yeah, I think that sounds reasonable. Thanks for considering it.

Show resolved Hide resolved staging/src/k8s.io/apimachinery/pkg/watch/streamwatcher_test.go

@k8s-ci-robot k8s-ci-robot added the lgtm label Feb 12, 2019

@smarterclayton

This comment has been minimized.

Copy link
Contributor Author

smarterclayton commented Feb 12, 2019

/retest

@smarterclayton

This comment has been minimized.

Copy link
Contributor Author

smarterclayton commented Feb 12, 2019

/hold

Report a watch error instead of eating it when we can't decode
Clients are required to handle watch events of type ERROR, so instead
of eating the decoding error we should pass it on to the client. Use
NewGenericServerError with isUnexpectedResponse to indicate that we
didn't get the bytes from the server we were expecting. For watch, the
415 error code is roughly correct and we will return an error to the
client that makes debugging a failure in either server watch or client
machinery much easier.

We do not alter the behavior when it appears the response is an EOF
or other disconnection.

@smarterclayton smarterclayton force-pushed the smarterclayton:report_errors branch from bd94058 to cc64c98 Feb 12, 2019

@k8s-ci-robot k8s-ci-robot removed the lgtm label Feb 12, 2019

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Feb 12, 2019

New changes are detected. LGTM label has been removed.

@smarterclayton

This comment has been minimized.

Copy link
Contributor Author

smarterclayton commented Feb 12, 2019

/retest

1 similar comment
@smarterclayton

This comment has been minimized.

Copy link
Contributor Author

smarterclayton commented Feb 12, 2019

/retest

@smarterclayton

This comment has been minimized.

Copy link
Contributor Author

smarterclayton commented Feb 12, 2019

Updated to return a 500 and cleaned up test, PTAL

@yliaog

This comment has been minimized.

Copy link
Contributor

yliaog commented Feb 14, 2019

/cc

@k8s-ci-robot k8s-ci-robot requested a review from yliaog Feb 14, 2019

@logicalhan

This comment has been minimized.

Copy link
Contributor

logicalhan commented Feb 14, 2019

/cc @mbohlool

@k8s-ci-robot k8s-ci-robot requested a review from mbohlool Feb 14, 2019

@dims

This comment has been minimized.

Copy link
Member

dims commented Feb 18, 2019

/assign @deads2k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment