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

feat(sync): use regclient for sync extension #2524

Conversation

eusebiu-constantin-petu-dbk
Copy link
Collaborator

replaced containers/image package with regclient/regclient package

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk force-pushed the sync_regclient branch 2 times, most recently from 7dcb55f to ac000c0 Compare July 5, 2024 12:40
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 84.98024% with 76 lines in your changes missing coverage. Please review.

Project coverage is 92.80%. Comparing base (002ff05) to head (4d75aa8).

Files Patch % Lines
pkg/extensions/sync/remote.go 74.28% 33 Missing and 12 partials ⚠️
pkg/extensions/sync/destination.go 78.68% 10 Missing and 3 partials ⚠️
pkg/extensions/sync/utils.go 80.00% 6 Missing and 3 partials ⚠️
pkg/extensions/sync/service.go 96.31% 5 Missing and 1 partial ⚠️
pkg/extensions/sync/referrers.go 86.66% 1 Missing and 1 partial ⚠️
pkg/extensions/sync/oci_layout.go 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2524      +/-   ##
==========================================
- Coverage   92.82%   92.80%   -0.02%     
==========================================
  Files         169      163       -6     
  Lines       22304    21646     -658     
==========================================
- Hits        20703    20089     -614     
+ Misses        998      965      -33     
+ Partials      603      592      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk marked this pull request as ready for review July 5, 2024 13:06
@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk force-pushed the sync_regclient branch 2 times, most recently from 23a0ab2 to 4d75aa8 Compare July 5, 2024 18:22
}

// this function will check if tag is a cosign tag (signature or sbom).
func isCosignTag(tag string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we already have a function like this in the common package and another in the gc package. Could we consolidate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it doesn't check for sboms :D

pkg/extensions/sync/sync_internal_test.go Outdated Show resolved Hide resolved
return nil
}
// we want referrers using sha-<digest>.*" tags
// service.copyOptions = append(service.copyOptions, regclient.ImageWithDigestTags())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I let both options enabled, regclient will overwrite some of the referrers.
Because regclient will create tags for all referrers it copies, even if there's no referrer tag on upstream.

I think this issue arises only if the upstream is older zot, or the upstream supports both digest referrers and subject referrers.

I'm not 100% percent sure what is the exact behaviour though.

I will try to fully grasp it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean zot manages the referrers tag internally, and updates it every time we copy something to the storage? In that case I think we should not copy it from upstream.

pkg/extensions/sync/service.go Outdated Show resolved Hide resolved
case mediatype.Docker2ManifestList:
buf, desc, err = convertDockerListToOCI(ctx, man, imageReference, registry.client)
isConverted = true
case mediatype.OCI1Manifest, mediatype.OCI1ManifestList:
Copy link
Contributor

Choose a reason for hiding this comment

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

Off topic: let's make sure when we sync we don't unmarshall/marshal the manifest when writing to the destination.

Currently there's an open bug that sync reorders the fields in the image manifest, resulting in a different digest, and broken referrers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only for docker images we don't do any marshal unmarshal for oci.

For docker images I guess it's normal that referrers are lost in process of converting.

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to make sure that by switching to regclient this will also be resolved #2417

examples/config-sync.json Outdated Show resolved Hide resolved
@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk force-pushed the sync_regclient branch 2 times, most recently from 0f45962 to c13fbb9 Compare August 8, 2024 13:40
replaced containers/image package with regclient/regclient package

Signed-off-by: Petu Eusebiu <[email protected]>

rebased

Signed-off-by: Petu Eusebiu <[email protected]>
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.

2 participants