Skip to content

Conversation

zuercher
Copy link
Member

Modifies the Thrift router to allow protocols to upgrade on initial
data from the downstream connection and upgrade an upstream connection
before transmitting a request. As part of this work, Transport and
Protocol objects are reused across downstream connections and for
an upstream's request and response.

Risk Level: low, upgrade path unused
Testing: unit tests
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Stephan Zuercher stephan@turbinelabs.io

Modifies the Thrift router to allow protocols to upgrade on initial
data from the downstream connection and upgrade an upstream connection
before transmitting a request. As part of this work, Transport and
Protocol objects are reused across downstream connections and for
an upstream's request and response.

*Risk Level*: low, upgrade path unused
*Testing*: unit tests
*Docs Changes*: n/a
*Release Notes*: n/a

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
@zuercher
Copy link
Member Author

@brirams @rgs1 fyi

}

/**
* Check whether a given upstream connection can be upgraded and generates an upgrade request
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] Checks for consistency with the other method comments

@@ -19,8 +19,8 @@ class ProtocolConverter : public virtual DecoderEventHandler {
ProtocolConverter() {}
virtual ~ProtocolConverter() {}

void initProtocolConverter(ProtocolPtr&& proto, Buffer::Instance& buffer) {
proto_ = std::move(proto);
void initProtocolConverter(Protocol* proto, Buffer::Instance& buffer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The change to a raw pointer here is dangerous.

@@ -350,8 +353,8 @@ ProtocolState DecoderStateMachine::run(Buffer::Instance& buffer) {
return state_;
}

Decoder::Decoder(TransportPtr&& transport, ProtocolPtr&& protocol, DecoderCallbacks& callbacks)
: transport_(std::move(transport)), protocol_(std::move(protocol)), callbacks_(callbacks) {}
Decoder::Decoder(Transport& transport, Protocol& protocol, DecoderCallbacks& callbacks)
Copy link
Contributor

Choose a reason for hiding this comment

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

With this change from TransportPtr&& transport to Transport& transport, what guarantees that the referenced transport will remain valid for the full life of the Decoder object?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's up to the constructor of the Decoder to make sure this is the case. ConnectionManager creates a TransportPtr, ProtocolPtr, and DecoderPtr when it's constructed. The TransportPtr and ProtocolPtr and never replaced so their lifecycle is the duration of the downstream connection.

Each Router has a TransportPtr and ProtocolPtr. A DecoderPtr is held indirectly via ThriftObjectPtr if protocol upgrade occurs for the upstream. Once upgrade is complete that ThriftObjectPtr and DecoderPtr are destroyed. If the request is terminated early the ThriftObjectPtr and DecoderPtr are destroyed before the TransportPtr or ProtocolPtr.

Finally the ConnectionManager::ActiveRpc holds a ResponseDecoder that has references to the Router's TransportPtr and ProtocolPtr. The destruction order there is ResponseDecoder before DecoderFilter so that's ok as well.

brirams
brirams previously approved these changes Aug 29, 2018
Copy link
Contributor

@brirams brirams left a comment

Choose a reason for hiding this comment

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

Take my approval with a grain of salt because I'm still ramping up but looks reasonable.

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
brian-pane
brian-pane previously approved these changes Aug 31, 2018
(prefer forward reference resolved in the same file to one resolved by a separate file)

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
@zuercher
Copy link
Member Author

zuercher commented Sep 5, 2018

@brian-pane can I get you refresh your review? (5fc9e3a is the only change from before).

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Your "we wish Github supported our permissions model" approval, sir!

@zuercher zuercher merged commit 763f2a7 into envoyproxy:master Sep 5, 2018
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.

4 participants