-
Notifications
You must be signed in to change notification settings - Fork 6
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
Lock IAMClient requests when connection lost #186
Lock IAMClient requests when connection lost #186
Conversation
Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Only grpc calls required to be locked, streams are wrapped by the corresponding clients Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
773ba70
to
9214832
Compare
"google.golang.org/grpc" | ||
) | ||
|
||
/*********************************************************************************************************************** |
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.
Are these empty sections (consts,types) needed?
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.
no, removed.
iamclient/iamcertprovider.go
Outdated
* Public | ||
**********************************************************************************************************************/ | ||
|
||
// New creates new certificate provider instance. |
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.
// New creates new certificate provider instance. | |
// NewCertProvider creates new certificate provider instance. |
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.
fixed
@@ -34,7 +33,6 @@ import ( | |||
// CertProvider certificate provider interface. | |||
type CertProvider interface { | |||
GetCertificate(certType string, issuer []byte, serial string) (certURL, keyURL string, err error) | |||
SubscribeCertChanged(certType string) (<-chan *iamanager.CertInfo, error) |
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.
Why it is removed? Not required?
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.
yes, Interface used by Create(M)TLSCredentials, they dont require Subscribe method
@@ -35,6 +35,7 @@ type GRPCConn struct { | |||
sync.Mutex | |||
|
|||
grpcConn *grpc.ClientConn | |||
started bool |
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.
Fix commit message
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.
done
} | ||
client.publicConnection.Set(publicConn) | ||
|
||
defer func() { |
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.
Usually, no need to put good path into defer for readability reason.
defer func() { | |
defer func() { | |
if err != nil { | |
publicConn.Close() | |
} | |
} | |
... | |
client.publicConnection.Start() |
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.
client.publicConnection.Start should be done in the end of the function execution to ensure connection succeded. Otherwise we unlock pending requests earlier & they can fail.
Current function beside error check has also
(client.isProtectedConnEnabled) logic, which means we should duplicate
client.publicConnection.Start() in
if (!client.isProtectedConnEnabled) {
}
and in the end of the function.
In order to avoid that I decided to add both cases to defer() function.
if err != nil { | ||
return aoserrors.Wrap(err) | ||
} | ||
|
||
client.protectedConnection.Set(protectedConn) | ||
|
||
defer func() { |
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.
ditto
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.
for unification maded the same way as for the public connection
Updating grpc connection shouldn't unlock requests. Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
9214832
to
26bfefe
Compare
|
No description provided.