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

Change hsConn to a map #50

Merged
merged 1 commit into from
Jul 15, 2020
Merged

Conversation

Ryanfsdf
Copy link
Collaborator

@Ryanfsdf Ryanfsdf commented Jul 8, 2020

Previously, hsConn was a single value. If an application specifies 2 different handshaker service addresses, this would result in strange behavior where the first handshaker address that gets called into Dial would always be used. By using a map, we allow a handshaker connection per handshaker service address.


This change is Reviewable

Copy link
Owner

@matthewstevenson88 matthewstevenson88 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR Ryan! I left a couple of comments.

Reviewable status: 0 of 2 files reviewed, 4 unresolved discussions (waiting on @davisgu, @matthewstevenson88, and @Ryanfsdf)


security/s2a/internal/handshaker/service/service.go, line 29 at r1 (raw file):

var (
	// hsConnMap represents a mapping from an S2A handshaker service address
	// to a corresponding S2A handshaker service connection.

nit: "corresponding connection to an S2A handshaker service instance."


security/s2a/internal/handshaker/service/service.go, line 31 at r1 (raw file):

	// to a corresponding S2A handshaker service connection.
	hsConnMap = make(map[string]*grpc.ClientConn)
	// mu guards hsDialer.

This precedes this PR, but doesn't mu also guard hsConnMap?

If that's correct, should we move mu to the top of the list of variables and change its comment?


security/s2a/internal/handshaker/service/service_test.go, line 30 at r1 (raw file):

	// The address is irrelevant in this test.
	testAddress  = "some_address"
	testAddress2 = "some_address2"

nit: Please add an underscore between address and 2.

(Also, I know this already existed in the code, but could you change some to test?)


security/s2a/internal/handshaker/service/service_test.go, line 80 at r1 (raw file):

		t.Fatalf("hsConnmap[%v] = %v, want %v", testAddress2, got, want)
	}
	if got, want := conn2 == conn3, false; got != want {

It might be simpler to write if got, want := conn2, conn3; got == want { ... }?

@Ryanfsdf Ryanfsdf force-pushed the create-hs-map branch 2 times, most recently from 5af9704 to 9a4126e Compare July 8, 2020 20:05
Copy link
Collaborator Author

@Ryanfsdf Ryanfsdf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @davisgu and @matthewstevenson88)


security/s2a/internal/handshaker/service/service.go, line 31 at r1 (raw file):

Previously, matthewstevenson88 wrote…

This precedes this PR, but doesn't mu also guard hsConnMap?

If that's correct, should we move mu to the top of the list of variables and change its comment?

Done.


security/s2a/internal/handshaker/service/service_test.go, line 80 at r1 (raw file):

Previously, matthewstevenson88 wrote…

It might be simpler to write if got, want := conn2, conn3; got == want { ... }?

I don't think that would be correct, since want would be equal to conn3 and that would be implying that we want conn3. But we don't want conn3, we want conn2 to be equal to conn3.

Copy link
Collaborator Author

@Ryanfsdf Ryanfsdf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @davisgu and @matthewstevenson88)


security/s2a/internal/handshaker/service/service_test.go, line 80 at r1 (raw file):

Previously, Ryanfsdf (Ryan Kim) wrote…

I don't think that would be correct, since want would be equal to conn3 and that would be implying that we want conn3. But we don't want conn3, we want conn2 to be equal to conn3.

we want conn2 not to be equal to conn3*

Copy link
Owner

@matthewstevenson88 matthewstevenson88 left a comment

Choose a reason for hiding this comment

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

Approved, with 2 small nits. Please get approval from @cesarghali for Go readability.

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @davisgu and @Ryanfsdf)


security/s2a/internal/handshaker/service/service_test.go, line 28 at r2 (raw file):

const (
	// The address is irrelevant in this test.

nit: Can we remove this comment? Now that we have a map, the address is relevant (in that they are distinct addresses).


security/s2a/internal/handshaker/service/service_test.go, line 44 at r2 (raw file):

	}()

	// First call to Dial, it should create a connection for the given address.

nit: s/for/to the server running at

Copy link
Collaborator

@cesarghali cesarghali left a comment

Choose a reason for hiding this comment

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

This seems to be a bug in ALTS code as well, do you mind sending a PR to fix that?

Reviewed 1 of 2 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @davisgu and @Ryanfsdf)


security/s2a/internal/handshaker/service/service_test.go, line 28 at r3 (raw file):

const (
	testAddress  = "test_address"

testAddress1 = "test_address_1"

Copy link
Collaborator Author

@Ryanfsdf Ryanfsdf left a comment

Choose a reason for hiding this comment

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

Sure, will do!

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @cesarghali and @davisgu)


security/s2a/internal/handshaker/service/service_test.go, line 28 at r3 (raw file):

Previously, cesarghali (Cesar Ghali) wrote…

testAddress1 = "test_address_1"

Done.

@Ryanfsdf Ryanfsdf merged commit 2d2faf9 into matthewstevenson88:master Jul 15, 2020
Ryanfsdf added a commit that referenced this pull request Jul 15, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants