Skip to content
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

Common tracing and retry/backoff support for go-gather #1993

Conversation

zregvart
Copy link
Member

More details in the commit messages. Adds a set of common variables used to configure the HTTP clients used by go-containerregistry and go-gather HTTP and OCI support via ORAS.

Requires enterprise-contract/go-gather#114 and enterprise-contract/go-gather#113 to be merged and versions to be bumped here.

@zregvart zregvart force-pushed the pr/go-gather-tracing-retry-backoff branch from 9ff2ed0 to d6089a2 Compare September 23, 2024 13:42
Adds a `internal/http` package that can be used to configure HTTP
clients with the default tracing, retry and backoff configuration. The
configuration is applied to the internal OCI client abstraction for use
in go-containerregistry.
Applies the common HTTP tracing, retry and backoff configuration to OCI
and HTTP go-gather implementations.
Updates HTTP and OCI modules of go-gather.
@zregvart zregvart force-pushed the pr/go-gather-tracing-retry-backoff branch from d6089a2 to 0cc70f2 Compare September 24, 2024 08:35
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.25%. Comparing base (103cb6a) to head (0cc70f2).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
internal/utils/oci/client.go 80.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1993      +/-   ##
==========================================
+ Coverage   74.05%   74.25%   +0.20%     
==========================================
  Files          87       88       +1     
  Lines        5716     5742      +26     
==========================================
+ Hits         4233     4264      +31     
+ Misses       1483     1478       -5     
Flag Coverage Δ
generative 74.25% <97.22%> (+0.20%) ⬆️
integration 74.25% <97.22%> (+0.20%) ⬆️
unit 74.25% <97.22%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/downloader/downloader.go 97.29% <100.00%> (+3.96%) ⬆️
internal/http/tracing.go 100.00% <100.00%> (ø)
internal/utils/oci/client.go 46.91% <80.00%> (+2.72%) ⬆️

@zregvart zregvart marked this pull request as ready for review September 24, 2024 08:46
Copy link
Member

@simonbaird simonbaird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave it a quick read. Lgtm, but maybe seek another review from a golang expert.


var _initialize = func() {
if log.IsLevelEnabled(logrus.TraceLevel) {
goci.Transport = http.NewTracingRoundTripperWithLogger(goci.Transport, log)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow up, we should use a solution that doesn't rely on global states. Besides being a safer approach it would also remove the need to use sync. I understand that that would require changes in go-gather itself. Could you file a follow up issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return gather.Gather(ctx, source, destination)
}

var _initialize = func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be done during init to avoid having to use sync.OnceFunc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not control it in tests then

@robnester-rh robnester-rh merged commit 5d96263 into enterprise-contract:main Sep 24, 2024
12 checks passed
@zregvart zregvart deleted the pr/go-gather-tracing-retry-backoff branch September 25, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants