Skip to content

DO NOT MERGE: Support dynamic fallback down registry chains - #1021

Closed
smarterclayton wants to merge 2 commits into
openshift:masterfrom
smarterclayton:mirrored
Closed

smarterclayton wants to merge 2 commits into
openshift:masterfrom
smarterclayton:mirrored

Conversation

@smarterclayton

Copy link
Copy Markdown
Contributor

Implements the core of the discussion around supporting multiple
sources of input. Each wrapped method in the mirroredRepository
structure that needs to check alternates (methods that invoke digest
lookups) will use that structure. Methods that cannot be retried
will use the first alternative that has a working client (such as
ServeBlob). Methods that must always use the source (mutable calls
or those that don't deal with a digest) will only look at the
original source, although the logic is structured so we can use
data about these requests in the future.

The strategy is clarified to call either FirstRequest and OnFailure,
or just FirstRequest. Each repository will make a single call to the
strategy, and it's up to the strategy to include the original source
when invoking FirstRequest.

Did a very, very, very minimal test of this against docker.io but
did not check anything except get.

@openshift-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 22, 2021

@dmage dmage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Honestly I don't like that it lookups alternatives from scratch from every method. If I want to pull (mirror) an image, I want to get all its blobs from the same repository. Most likely it'll be the first suggested repository and this approach will work, but what if the first mirror is down?
Otherwise, looks good, nice catch that write methods shouldn't use mirrors.


func (f mirroredTags) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
var desc distribution.Descriptor
err := f.repo.source(ctx, func(r distribution.Repository) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We never trust mirrored tags?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no because you don't know whether they are in sync. I think that would be a different type of behavior - we could call this "blobMirrored" to clarify because everything has to be content addressable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to make it a bit clearer and updated the godoc on the top most item.

@sallyom sallyom Mar 25, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i've been stuck I've incorporated this but when I run 'oc image mirror anything' I see a manifest blob unknown error w/ the manifests Put. - If I don't fix this I'll push my oc branch w/ the bump and have you try it/help tomorrow. (first I'll incorporate the name changes above)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ooooh got it to work - oc was considering a nil manifest and an empty Descriptor as 'already existing' once I fixed that the push goes through.. now, why is the regclient returning a nil manifest and empty Descriptor?


// initialRepos returns a list of locations to attempt to access, a boolean indicating that alternates
// were suggested, or an error.
func (r *mirroredRepository) initialRepos(ctx context.Context) ([]reference.DockerImageReference, bool, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can safely ditch this bool without sacrificing performance/readability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's subtle and necessary - the presence of the bool tells us whether the FirstRequest() gave us alternates or not. If it did, we never call OnFailure(). If it doesn't, we have to call OnFailure later. The difference is because the returned list of alternates always contains the source in the default path, so an empty alternates list (or nil) doesn't tell us what expected outcome from FirstRequest was().

return err
}
if alternateErr := r.attemptRepos(ctx, alternates, fn); alternateErr != nil {
return err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

err is nil here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yikes good catch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

renamed it attemptErr

})

klog.InitFlags(flag.CommandLine)
//cliflag.InitFlags()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WIP?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was just hacking it in while i debugged code, would not go in to final.

@smarterclayton

Copy link
Copy Markdown
Contributor Author

Honestly I don't like that it lookups alternatives from scratch from every method. If I want to pull (mirror) an image, I want to get all its blobs from the same repository. Most likely it'll be the first suggested repository and this approach will work, but what if the first mirror is down?

It should only lookup alternatives one time per Repository() object returned from the main call (maybe a bug if I'm looking wierdly)

Implements the core of the discussion around supporting multiple
sources of input. Each wrapped method in the mirroredRepository
structure that needs to check alternates (methods that invoke digest
lookups) will use that structure. Methods that cannot be retried
will use the first alternative that has a working client (such as
ServeBlob). Methods that must always use the source (mutable calls
or those that don't deal with a digest) will only look at the
original source, although the logic is structured so we can use
data about these requests in the future.

The strategy is clarified to call either FirstRequest and OnFailure,
or just FirstRequest. Each repository will make a single call to the
strategy, and it's up to the strategy to include the original source
when invoking FirstRequest.

Did a very, very, very minimal test of this against docker.io but
did not check anything except get.
@openshift-ci

openshift-ci Bot commented May 27, 2021

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot

Copy link
Copy Markdown

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 25, 2021
@openshift-ci

openshift-ci Bot commented Aug 25, 2021

Copy link
Copy Markdown
Contributor

@smarterclayton: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 25, 2021
@openshift-bot

Copy link
Copy Markdown

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci Bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 25, 2021
@openshift-bot

Copy link
Copy Markdown

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci Bot closed this Oct 25, 2021
@openshift-ci

openshift-ci Bot commented Oct 25, 2021

Copy link
Copy Markdown
Contributor

@openshift-bot: Closed this PR.

Details

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants