-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Fix panic in etcd validate secure endpoints #13810 #13824
Conversation
Can you add a test? |
Codecov Report
@@ Coverage Diff @@
## main #13824 +/- ##
==========================================
- Coverage 72.72% 72.39% -0.33%
==========================================
Files 467 467
Lines 38280 38282 +2
==========================================
- Hits 27839 27716 -123
- Misses 8662 8766 +104
- Partials 1779 1800 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Yes, I will add a test today. |
Test for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, confirmed that Dial is deprecated and not used by NewTransport
client/pkg/transport/tls_test.go
Outdated
t.Error("validate secure endpoints should fail") | ||
} | ||
|
||
secureEps := []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you sequentially test different cases, fist insecure later secure, also you don't have you considered using subtests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will using subtests.
client/pkg/transport/tls_test.go
Outdated
"http://" + srv.Listener.Addr().String(), | ||
"invalid remote address", | ||
} | ||
if _, err := ValidateSecureEndpoints(*tlsInfo, insecureEps); err == nil || !strings.Contains(err.Error(), "is insecure") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test case with insecure endpoint that passes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test for ValidateSecureEndpoints()
updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The only minor concern is the unit test. subtest is better, but since there is only two cases, and they share the same http server, so I am OK.
client/pkg/transport/tls_test.go
Outdated
if !test.expectedErr && err != nil { | ||
t.Errorf("unexpected error: %v", err) | ||
} | ||
if err == nil && !test.expectedErr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if is not needed, you can still check endpoints. in case mixEndPoints
you specified both expectedEndpoints and expectErr true, which is misleading as this if will result in endpoints not being verified.
client/pkg/transport/tls_test.go
Outdated
t.Errorf("unexpected error: %v", err) | ||
} | ||
if err == nil && !test.expectedErr { | ||
if len(secureEps) != len(test.expectedEndpoints) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeepEqual should already test if length matches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I removed secureEps
's length check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Running workflow. Thanks @eval-exec
@serathius I rebased branch ( |
`ValidateSecureEndpoints()` should call `t.DialContext()` instead of `t.Dial()`, because `t.Dial` is `nil`
Co-authored-by: Marek Siarkowicz <[email protected]>
Co-authored-by: Marek Siarkowicz <[email protected]>
Backport: etcd-io#13824 Signed-off-by: Wei Fu <[email protected]>
This pr fix #13810
etcd/client/pkg/transport/transport.go
Lines 33 to 43 in 1b208aa
In
etcd/client/pkg/transport/tls.go
:ValidateSecureEndpoints()
should callt.DialContext()
instead oft.Dial()
, becauset.Dial
isnil