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

Propagate SecurityHandshakeObserver without channel attribute #1129

Merged

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Aug 19, 2020

Motivation:

Usage of Channel's attributes increase a shared state of the Channel.
SecurityHandshakeObserver can be propagated without using it.

Modifications:

  • When SslHandshakeCompletionEvent arrives, look up for
    ConnectionObserverHandler to access previously initialized
    SecurityHandshakeObserver;
  • Add SecurityHandshakeObserverTest to verify that
    SecurityHandshakeObserver is working with different configurations:
    HTTP/1.1, HTTP/2, ALPN, secure proxy tunnel;
  • Improve TestServiceStreaming to echo content-type header;

Result:

Less state on the Channel instance.

if (waitForSslHandshake) {
if (observer != null) {
// Notify ConnectionObserverHandler that we are ready to receive SecurityHandshakeObserver instance
ctx.pipeline().fireUserEventTriggered(WaitingForHandshakeCompletionEvent.INSTANCE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

A negative of sending an event is that there is no acknowledgment of receipt which makes debugging harder.
An alternative is to follow what we do for DeferSslHandler => lookup the handler and register interest for receiving the observer. The negative is more public API (internal so arguably low) but gives a more determinsitic behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion! Everything is pkg-private without public exposure 🎉

Motivation:

Usage of Channel's attributes increase a shared state of the `Channel`.
`SecurityHandshakeObserver` can be propagated without using it.

Modifications:

- Introduce `WaitingForHandshakeCompletionEvent` that is used to notify
`ConnectionObserverHandler` that the last handler is initialized and
ready to receive `SecurityHandshakeObserver` instance;
- Propagate `SecurityHandshakeObserver` as user event through the pipeline;
- Add `SecurityHandshakeObserverTest` to verify that
`SecurityHandshakeObserver` is working with different configurations:
HTTP/1.1, HTTP/2, ALPN, secure proxy tunnel;
- Improve `TestServiceStreaming` to echo content-type header;

Result:

Less state on the `Channel` instance.
if (securityObserver != null) {
securityObserver.handshakeComplete(session);
if (observer != null) {
observer.handshakeComplete(session);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Log at warn if shouldReport is true?

Copy link
Member Author

Choose a reason for hiding this comment

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

The warn log is easy to miss. This is not expected to be caught by users, we should provide a guarantee that it never happens. I'm thinking about an assertion, but as we discussed offline we will avoid using null values. Therefore, shouldReport will go away in a follow-up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok what I meant was that if we expect the observer to be present but it is not; is there something we need to do to bubble it up to the user?

Yes good to guarantee but bugs will make it hard to debug. Perhaps a good item to think about when using NOOP observers.

@idelpivnitskiy
Copy link
Member Author

@servicetalk-bot test this please

@idelpivnitskiy idelpivnitskiy merged commit d4a869a into apple:transport-observability Aug 21, 2020
@idelpivnitskiy idelpivnitskiy deleted the handshake-handle branch August 21, 2020 04:03
idelpivnitskiy added a commit that referenced this pull request Aug 26, 2020
Motivation:

Usage of Channel's attributes increase a shared state of the `Channel`.
`SecurityHandshakeObserver` can be propagated without using it.

Modifications:

- When `SslHandshakeCompletionEvent` arrives, look up for
`ConnectionObserverHandler` to access previously initialized
`SecurityHandshakeObserver`;
- Add `SecurityHandshakeObserverTest` to verify that
`SecurityHandshakeObserver` is working with different configurations:
HTTP/1.1, HTTP/2, ALPN, secure proxy tunnel;
- Improve `TestServiceStreaming` to echo content-type header;

Result:

Less state on the `Channel` instance.
idelpivnitskiy added a commit that referenced this pull request Aug 26, 2020
Motivation:

Usage of Channel's attributes increase a shared state of the `Channel`.
`SecurityHandshakeObserver` can be propagated without using it.

Modifications:

- When `SslHandshakeCompletionEvent` arrives, look up for
`ConnectionObserverHandler` to access previously initialized
`SecurityHandshakeObserver`;
- Add `SecurityHandshakeObserverTest` to verify that
`SecurityHandshakeObserver` is working with different configurations:
HTTP/1.1, HTTP/2, ALPN, secure proxy tunnel;
- Improve `TestServiceStreaming` to echo content-type header;

Result:

Less state on the `Channel` instance.
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.

None yet

2 participants