-
Notifications
You must be signed in to change notification settings - Fork 137
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
googleca: close certificate authority client when done #930
googleca: close certificate authority client when done #930
Conversation
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
cde8a63
to
9346a16
Compare
Codecov Report
@@ Coverage Diff @@
## main #930 +/- ##
==========================================
- Coverage 53.83% 53.69% -0.14%
==========================================
Files 37 37
Lines 2320 2326 +6
==========================================
Hits 1249 1249
- Misses 980 986 +6
Partials 91 91
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
9346a16
to
a830a39
Compare
Can we implement |
@haydentherapper @priyawadhwa I changed the implementation to follow the same approach we followed with |
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 is looking good, just a couple more comments!
@@ -188,19 +188,24 @@ func main() { | |||
|
|||
client, err := privateca.NewCertificateAuthorityClient(context.Background()) | |||
if err != nil { | |||
client.Close() | |||
log.Fatal(err) | |||
} | |||
parsedCerts, err := fetchCACertificate(context.Background(), *gcpCaParent, *kmsKey, *tinkKeysetPath, *tinkKmsKey, client) |
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.
I think we can probably just put the defer client.Close()
call here after the error check once and then remove all the other calls to client.Close()
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.
IIRC the problem is that log.Fatal ends execution immediately so the deferral doesn't happen. I think the linter complains about the lack of closure in that case. I ran into this with closing files in other tests
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, this is due to the nature of log.Fatal. It won't run the defer.
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
8f46374
to
179acd2
Compare
Signed-off-by: Hector Fernandez hector@chainguard.dev
Summary
We realized that
NewCertAuthorityService
was creating a certificate authority client but the returned client was not closed when it was done being used. This is needed to clean up its underlying connections. I added a new interface function so any third party (consumer) could close the connection when they are done.Release Note
Close certificate authority client when done.
Documentation