Skip to content
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

connection: add tests #1

Merged
merged 2 commits into from
Feb 4, 2019
Merged

Conversation

pohly
Copy link

@pohly pohly commented Jan 22, 2019

This verifies that both unix:/// and absolute paths work and that the
timing behavior is as expected (wait for server, react promptly once
it appears).

@pohly
Copy link
Author

pohly commented Jan 22, 2019

There's one more test that might be useful: ensuring that gRPC does not attempt to reconnect after loosing the connection. I'll have a look at that now.

assert.InEpsilon(t, time.Second, endTime.Sub(startTime), 1, "connection loss should be detected quickly")
}

// No reconnection either.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what this test tries to do. If server is gone, gRPC should return codes.Unavailable quickly. That's correct. But it will try to reconnect if you re-start the server. So No reconnection either comment is quite confusing.

@pohly
Copy link
Author

pohly commented Jan 22, 2019 via email

@jsafrane
Copy link
Owner

We need to be very careful here. Is Unavailable returned in any case other than driver restart? We should not restart provisioner unless it's absolutely necessary, because it may leak volumes in case user deleted corresponding PVC.

Digging into code, there are few places when Unavailable is returned for not closed connection.

// 429 Too Many Requests - UNAVAILABLE.
http.StatusTooManyRequests: codes.Unavailable,

// 429 Too Many Requests - UNAVAILABLE.
http.StatusTooManyRequests: codes.Unavailable,
// 502 Bad Gateway - UNAVAILABLE.
http.StatusBadGateway: codes.Unavailable,
// 503 Service Unavailable - UNAVAILABLE.
http.StatusServiceUnavailable: codes.Unavailable,
// 504 Gateway timeout - UNAVAILABLE.
http.StatusGatewayTimeout: codes.Unavailable,

// errStreamDrain indicates that the stream is rejected because the
// connection is draining. This could be caused by goaway or balancer
// removing the address.
errStreamDrain = status.Error(codes.Unavailable, "the connection is draining")
// errStreamDone is returned from write at the client side to indiacte application
// layer of an error.
errStreamDone = errors.New("the stream is done")
// StatusGoAway indicates that the server sent a GOAWAY that included this
// stream's ID in unprocessed RPCs.
statusGoAway = status.New(codes.Unavailable, "the stream is rejected because server is draining the connection")

pohly added 2 commits January 31, 2019 14:27
Some but not all CSI sidecar apps may want to cache information
retrieved from a CSI driver. Those (and only) those apps needs a way
to detect that the cached information became invalid due to a CSI
driver restart and then react to that. The Connect function supports
notifying the app via an optional callback which then can:
- kill the app via os.Exit
- invalidate the cached information and continue by reconnecting
- prevent reconnecting and exit the application when gRPC method
  calls fail with status.Unavailable

The default behavior is as before, i.e. the connection is getting
restablished.
This verifies that both unix:/// and absolute paths work and that the
timing behavior is as expected (wait for server, react promptly once
it appears).
@pohly
Copy link
Author

pohly commented Jan 31, 2019

@jsafrane I've implemented the approach with an explicit "connection lost" callback in this PR. Shall we merge that into your branch and from there into the upstream repo or shall I create a new PR?

@jsafrane jsafrane merged commit 23d286e into jsafrane:connection Feb 4, 2019
jsafrane pushed a commit that referenced this pull request Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants