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

alts: add ALTS config and integration test #4559

Merged
merged 31 commits into from
Oct 29, 2018
Merged

Conversation

JimmyCYJ
Copy link
Member

Description:
Last one for #3429, introduce ALTS config and add integration test.

Risk Level: Low (extension)
Testing: manual test, integration test, CI
Docs Changes: Done
Release Notes:
Fixes #3429.

Signed-off-by: JimmyCYJ jimmychen.0102@gmail.com

lizan and others added 8 commits September 19, 2018 11:56
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
HandshakerFactory factory =
[handshaker_service](Event::Dispatcher& dispatcher,
const Network::Address::InstanceConstSharedPtr&,
const Network::Address::InstanceConstSharedPtr&) -> TsiHandshakerPtr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a check that |local_address| passed-in should be initialized?

Copy link
Member Author

Choose a reason for hiding this comment

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

Per offline discussion with @lizan checking nullptr is enough here.

std::to_string(fake_handshaker_server_port_));
}

void AltsIntegrationTest::initialize() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it Envoy code style that member definition has to be outside of class declaration?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved all definitions into declarations, just like other integration test files.

};
testRouterRequestAndResponseWithBody(1024, 512, false, &creator);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how possible it is with grpc fake handshake service, but it'll be great if you can add a handshake failure test and peer validation failure test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added tests to cover peer validation failure at both sides. Handshake failure case is not easy to add, which might involve changes to fake handshake server.

Copy link
Member

Choose a reason for hiding this comment

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

One thing you might be able to do is point handshaker_service to non-exist handshaker server, that will fail handshake.

Copy link
Member Author

@JimmyCYJ JimmyCYJ Oct 15, 2018

Choose a reason for hiding this comment

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

I have added one test which sets a wrong address to client's config, so that client fails to do handshake. For the server side, it is weird that Envoy always connects to the fake handshaker server even I set an arbitrary string as handshaker server's address. I am still debugging it.

Copy link
Member Author

@JimmyCYJ JimmyCYJ Oct 22, 2018

Choose a reason for hiding this comment

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

After discussing with @jiangtaoli2016 and @yihuazhang, we figure out why Envoy can still talk to fake handshaker server even the handshaker url is " ". This is because in integration test, client and Envoy are sharing one gRPC binary. When client starts talking to fake handshaker server, init_shared_resources() is called and kSharedResource->channel is created. Later when Envoy talks to fake handshaker server, it reuses the kSharedResource->channel and continues handshake process.

In real application use, two handshake clients (e.g. two Envoys) are depending on separate gRPC library, so this issue will not happen.

I have removed TEST_P(AltsIntegrationTestServerWrongHandshaker, ConnectToWrongHandshakerAddress), as TEST_P(AltsIntegrationTestClientWrongHandshaker, ConnectToWrongHandshakerAddress) is sufficient to cover the error case.

@stale
Copy link

stale bot commented Oct 8, 2018

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Oct 8, 2018
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
@htuch
Copy link
Member

htuch commented Oct 9, 2018

@JimmyCYJ can you ping when this is ready for review? Thanks.

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Oct 9, 2018
@JimmyCYJ
Copy link
Member Author

JimmyCYJ commented Oct 9, 2018

can you ping when this is ready for review? Thanks.

Sure, I am working on it this week.

Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
@lizan
Copy link
Member

lizan commented Oct 10, 2018

can you merge master? coverage fails due to that.

Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
# TODO(lizan): Use release once new version released.
sha256 = "dcd972e32e39e41f6248c7f8252676de2993d93289da842b72e271d0a89ed150",
strip_prefix = "grpc-1.16.0-pre1",
urls = ["https://github.com/grpc/grpc/archive/v1.16.0-pre1.tar.gz"],
Copy link
Member Author

Choose a reason for hiding this comment

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

grpc-1.16.0 is going to be released on 10/22/2018

Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
@htuch
Copy link
Member

htuch commented Oct 23, 2018

@JimmyCYJ is this ready for review yet?

@JimmyCYJ
Copy link
Member Author

JimmyCYJ commented Oct 23, 2018

is this ready for review yet?

@htuch Yes, this is ready for review. gRPC 1.16.0 will be released this week. I will update gRPC dependency when 1.16.0 is released.

Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
@JimmyCYJ
Copy link
Member Author

gRPC version is updated.

@JimmyCYJ JimmyCYJ changed the title [WIP] alts: add ALTS config and integration test alts: add ALTS config and integration test Oct 24, 2018
@JimmyCYJ
Copy link
Member Author

@htuch This is ready for review. Please take a look. Thanks.

// https://cloud.google.com/security/encryption-in-transit/application-layer-transport-security/
message Alts {
// The location of a handshaker service, this is usually 169.254.169.254:8080
// on GCE
Copy link
Member

Choose a reason for hiding this comment

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

Nit: end sentences with .

MessageUtil::downcastAndValidate<const envoy::config::transport_socket::alts::v2alpha::Alts&>(
message);

std::string handshaker_service = config.handshaker_service();
Copy link
Member

Choose a reason for hiding this comment

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

Nit: constify the rest of these.

}

HandshakerFactory factory =
[handshaker_service](Event::Dispatcher& dispatcher,
Copy link
Member

Choose a reason for hiding this comment

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

Can we refactor this and the upstream case to something that has most of the common logic?

->mutable_listeners(0)
->mutable_filter_chains(0)
->mutable_transport_socket();
std::string yaml = R"EOF(
Copy link
Member

Choose a reason for hiding this comment

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

Nit: const


void initialize() override {
config_helper_.addConfigModifier([this](envoy::config::bootstrap::v2::Bootstrap& bootstrap) {
auto transport_socket = bootstrap.mutable_static_resources()
Copy link
Member

Choose a reason for hiding this comment

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

Nit: auto transport_socket*

handshaker_service: ")EOF" +
fakeHandshakerServerAddress(server_connect_handshaker_) + "\"";
if (!server_peer_identity_.empty()) {
yaml.replace(yaml.find("[]"), std::string::size_type(2), server_peer_identity_);
Copy link
Member

Choose a reason for hiding this comment

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

See next comment..

handshaker_service: ")EOF" +
fakeHandshakerServerAddress(client_connect_handshaker_) + "\"";
if (!client_peer_identity_.empty()) {
client_yaml.replace(client_yaml.find("[]"), std::string::size_type(2), client_peer_identity_);
Copy link
Member

Choose a reason for hiding this comment

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

I think it'd be just cleaner to explicitly work with the protobuf typed object than this kind of sed-like replacement.. or at least use fmt::format..

@@ -54,6 +46,20 @@ Network::PostIoAction TsiSocket::doHandshake() {
void TsiSocket::doHandshakeNext() {
ENVOY_CONN_LOG(debug, "TSI: doHandshake next: received: {}", callbacks_->connection(),
raw_read_buffer_.length());

if (!handshaker_) {
handshaker_ = handshaker_factory_(callbacks_->connection().dispatcher(),
Copy link
Member

Choose a reason for hiding this comment

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

Missing coverage.

Copy link
Member

Choose a reason for hiding this comment

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

@JimmyCYJ LGTM, but were you planning on adding coverage here?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm this shouldn't be missing coverage if integration test ran in coverage CI...

Copy link
Member

Choose a reason for hiding this comment

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

@JimmyCYJ for the coverage missing in L54, I think you can easily add it in tsi_socket unit test.

Copy link
Member Author

Choose a reason for hiding this comment

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

@htuch @lizan Sorry for the slow PR update. Yes, I was planning to add unit test into tsi_socket_test.cc but don't get a chance to do so. I will add test soon and ping you to review. Thanks for asking.

Copy link
Member Author

Choose a reason for hiding this comment

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

@htuch Please take a look. Thanks.

Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Signed-off-by: JimmyCYJ <jimmychen.0102@gmail.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@htuch htuch merged commit f9edb52 into envoyproxy:master Oct 29, 2018
@JimmyCYJ JimmyCYJ deleted the alts_config branch October 29, 2018 04:06
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