From 739686ba88699d8a4a377087619b719f0bbf1487 Mon Sep 17 00:00:00 2001 From: Garrett Squire Date: Thu, 30 Apr 2020 11:56:43 -0700 Subject: [PATCH] Bug Fixes (#4798) Patches: Make sure all log tailing types call Cleanup Make sure the http.Response body is closed in all cases Make sure that the challenge token is always deleted --- cmd/log-validator/main.go | 2 +- test/integration/common_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/log-validator/main.go b/cmd/log-validator/main.go index 252c59b5e..34c0399d4 100644 --- a/cmd/log-validator/main.go +++ b/cmd/log-validator/main.go @@ -142,7 +142,6 @@ func main() { Logger: tailLogger{logger}, }) cmd.FailOnError(err, "failed to tail file") - defer t.Cleanup() go func() { for line := range t.Lines { @@ -172,6 +171,7 @@ func main() { // "reopen" code path for files that are removed and then recreated. // These errors are harmless so we ignore them to allow clean shutdown. _ = t.Stop() + t.Cleanup() } }) } diff --git a/test/integration/common_test.go b/test/integration/common_test.go index 587e20f6d..024f47d7b 100644 --- a/test/integration/common_test.go +++ b/test/integration/common_test.go @@ -81,10 +81,11 @@ func delHTTP01Response(token string) error { if err != nil { return fmt.Errorf("deleting http-01 response: %s", err) } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { return fmt.Errorf("deleting http-01 response: status %d", resp.StatusCode) } - resp.Body.Close() return nil } @@ -126,11 +127,12 @@ func authAndIssue(c *client, csrKey *ecdsa.PrivateKey, domains []string) (*issua if err != nil { return nil, fmt.Errorf("adding HTTP-01 response: %s", err) } - defer delHTTP01Response(chal.Token) chal, err = c.Client.UpdateChallenge(c.Account, chal) if err != nil { + delHTTP01Response(chal.Token) return nil, fmt.Errorf("updating challenge: %s", err) } + delHTTP01Response(chal.Token) } csr, err := makeCSR(csrKey, domains)