Skip to content

Commit

Permalink
Remove timeouts in ACME logging middleware
Browse files Browse the repository at this point in the history
Logging middleware probably isn't the place for this in any case, but
more broadly there's little need to add additional timeouts here since
we have a context timeout configured during issuance and ACME timeouts
configured at the level of the HTTP client we use.

This is the second part of implementing the timeouts proposal from
#5214

Signed-off-by: Ashley Davis <ashley.davis@jetstack.io>
  • Loading branch information
SgtCoDFish committed Jun 20, 2022
1 parent 0607b6c commit 03aff7e
Showing 1 changed file with 2 additions and 47 deletions.
49 changes: 2 additions & 47 deletions pkg/acme/client/middleware/logger.go
Expand Up @@ -18,7 +18,6 @@ package middleware

import (
"context"
"time"

"github.com/go-logr/logr"
"golang.org/x/crypto/acme"
Expand All @@ -27,10 +26,6 @@ import (
logf "github.com/cert-manager/cert-manager/pkg/logs"
)

const (
timeout = time.Second * 10
)

func NewLogger(baseCl client.Interface) client.Interface {
return &Logger{
baseCl: baseCl,
Expand All @@ -49,135 +44,95 @@ var _ client.Interface = &Logger{}
func (l *Logger) AuthorizeOrder(ctx context.Context, id []acme.AuthzID, opt ...acme.OrderOption) (*acme.Order, error) {
l.log.V(logf.TraceLevel).Info("Calling AuthorizeOrder")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.AuthorizeOrder(ctx, id, opt...)
}

func (l *Logger) GetOrder(ctx context.Context, url string) (*acme.Order, error) {
l.log.V(logf.TraceLevel).Info("Calling GetOrder")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.GetOrder(ctx, url)
}

func (l *Logger) FetchCert(ctx context.Context, url string, bundle bool) ([][]byte, error) {
l.log.V(logf.TraceLevel).Info("Calling FetchCert")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.FetchCert(ctx, url, bundle)
}

func (l *Logger) ListCertAlternates(ctx context.Context, url string) ([]string, error) {
l.log.V(logf.TraceLevel).Info("Calling ListCertAlternates")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.ListCertAlternates(ctx, url)
}

func (l *Logger) WaitOrder(ctx context.Context, url string) (*acme.Order, error) {
l.log.V(logf.TraceLevel).Info("Calling WaitOrder")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.WaitOrder(ctx, url)
}

func (l *Logger) CreateOrderCert(ctx context.Context, finalizeURL string, csr []byte, bundle bool) (der [][]byte, certURL string, err error) {
l.log.V(logf.TraceLevel).Info("Calling CreateOrderCert")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.CreateOrderCert(ctx, finalizeURL, csr, bundle)
}

func (l *Logger) Accept(ctx context.Context, chal *acme.Challenge) (*acme.Challenge, error) {
l.log.V(logf.TraceLevel).Info("Calling Accept")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.Accept(ctx, chal)
}

func (l *Logger) GetChallenge(ctx context.Context, url string) (*acme.Challenge, error) {
l.log.V(logf.TraceLevel).Info("Calling GetChallenge")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.GetChallenge(ctx, url)
}

func (l *Logger) GetAuthorization(ctx context.Context, url string) (*acme.Authorization, error) {
l.log.V(logf.TraceLevel).Info("Calling GetAuthorization")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.GetAuthorization(ctx, url)
}

func (l *Logger) WaitAuthorization(ctx context.Context, url string) (*acme.Authorization, error) {
l.log.V(logf.TraceLevel).Info("Calling WaitAuthorization")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.WaitAuthorization(ctx, url)
}

func (l *Logger) Register(ctx context.Context, a *acme.Account, prompt func(tosURL string) bool) (*acme.Account, error) {
l.log.V(logf.TraceLevel).Info("Calling Register")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.Register(ctx, a, prompt)
}

func (l *Logger) GetReg(ctx context.Context, url string) (*acme.Account, error) {
l.log.V(logf.TraceLevel).Info("Calling GetReg")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.GetReg(ctx, url)
}

func (l *Logger) HTTP01ChallengeResponse(token string) (string, error) {
l.log.V(logf.TraceLevel).Info("Calling HTTP01ChallengeResponse")

return l.baseCl.HTTP01ChallengeResponse(token)
}

func (l *Logger) DNS01ChallengeRecord(token string) (string, error) {
l.log.V(logf.TraceLevel).Info("Calling DNS01ChallengeRecord")

return l.baseCl.DNS01ChallengeRecord(token)
}

func (l *Logger) Discover(ctx context.Context) (acme.Directory, error) {
l.log.V(logf.TraceLevel).Info("Calling Discover")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.Discover(ctx)
}

func (l *Logger) UpdateReg(ctx context.Context, a *acme.Account) (*acme.Account, error) {
l.log.V(logf.TraceLevel).Info("Calling UpdateReg")

ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

return l.baseCl.UpdateReg(ctx, a)
}

0 comments on commit 03aff7e

Please sign in to comment.