Skip to content

x/crypto/acme: send req with external context to RetryBackoff function #30183

@rekby

Description

@rekby

What did you do?

client = &acme.Client{
			Key:          config.PrivateKey,
			DirectoryURL: *ServerApiURL,
			RetryBackoff: func(n int, r *http.Request, res *http.Response) time.Duration {
				ctx := r.Context()
				retryLogger := zc.L(ctx) // get logger from context https://github.com/rekby/zapcontext
				if retryLogger == nil {
					retryLogger = logger.With(zap.String("request_context", "no-logger"))
				}
                                retryLogger.Info("Test")
                       }
}
                 

Send request to Lets encrypt with retrieval error.
_, err = client.Accept(ctx, httpchallenge)

What did you expect to see?

logs with my logger from ctx, and without request_context" = "no-logger"

What did you see instead?

logs with "request_context" = "no-logger" and without my logger from context ctx.

I suggest to send req with external context to function. Now it receive clear context (but http call do with external context).
My patch for self: https://github.com/rekby/crypto/commit/9874cac870c3253304772cee7f13a87c56040e88

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions