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

allow oras command to skip referrer index clean up #954

Closed
1 task done
qweeah opened this issue May 22, 2023 · 13 comments · Fixed by #957
Closed
1 task done

allow oras command to skip referrer index clean up #954

qweeah opened this issue May 22, 2023 · 13 comments · Fixed by #957
Labels
enhancement New feature or request
Milestone

Comments

@qweeah
Copy link
Contributor

qweeah commented May 22, 2023

What is the version of your ORAS CLI

1.0.0

What would you like to be added?

To all oras commands causing referrers update, a new flag --gc should be added to skip deleting the dangling referrers index:

  • By default, --gc is not set, dangling referrers index will not be clean
  • If --gc is set, clean dangling referrers index when needed

This flag should be added to below commands

  • oras attach
  • oras cp
  • oras manifest push
  • oras manifest delete

Why is this needed for ORAS?

Referrer index is the alternative that OCI-1.0 compliant registries can utilize to support artifact reference types, see OCI spec 1.0-rc.2.

If a referrers index i exists for a certain subject artifact a. When adding or removing referrers for a, content of i will be updated and a new referrers index will be created and retagged following the tag schema. The index i contains obsolete content without any tag referenced.

When running commands like oras attach and oras cp, it's possible that the used token scope doesn't cover delete, or the registry might disable deletion, so it's better to provide oras an option to skip cleaning the dangling referrers index.

Also checked OCI spec, cleanup is optional for registry clients.

Are you willing to submit PRs to contribute to this feature?

  • Yes, I am willing to implement it.
@FeynmanZhou
Copy link
Member

FeynmanZhou commented May 24, 2023

Let me provide more context about this proposal. As I mentioned in #915 , ORAS CLI attempts to delete the dangling referrers index (outdated referrers index) by default for garbage collection purposes when attaching/pushing/copying an artifact in the OCI v1.0 compliant registry (referrers API is not supported).

However, Cleaning up dangling referrers index when pushing content to the OCI v1.0 compliant registry is not defined in OCI Distribution Spec v1.1.0-RC.2. This is not an officially recommended behavior from the OCI Distribution Spec. In fact, most of the OCI registries support garbage collection. Clean up might be out of the scope of a registry client like ORAS.

I think ORAS can give the responsibility to users or registry operators instead of helping users clean up those dangling referrers index from the registry automatically. Having a --gc flag to enable users to delete the outdated referrers index manually when pushing or operating artifacts in the registry would be much more flexible.

@FeynmanZhou
Copy link
Member

linking oras-project/oras-go#510

@SteveLasker
Copy link
Contributor

What is the expected behavior of this command if the user has push but not delete rights?

@sajayantony
Copy link
Contributor

--gc seems overloaded without context. Are we GCing blobs, manifests, indexes, tags and list might go on. I can see the appeal of having a nice short flag, but it is really overarching. It would be clearer if the flag was indicative of the action like cleaning up referrers or tag-schema etc.

@qweeah
Copy link
Contributor Author

qweeah commented May 26, 2023

What is the expected behavior of this command if the user has push but not delete rights?

which command are you referring to? Generally, the cmd execution should success if user doesn't enforce referrers GC.

@qweeah
Copy link
Contributor Author

qweeah commented May 26, 2023

--gc seems overloaded without context. Are we GCing blobs, manifests, indexes, tags and list might go on. I can see the appeal of having a nice short flag, but it is really overarching. It would be clearer if the flag was indicative of the action like cleaning up referrers or tag-schema etc.

Trying to avoid tag schema or any other terms that normal user won't be able to understand. How about --gc-referrers? User should be able to understand referrers.

@FeynmanZhou
Copy link
Member

opencontainers/distribution-spec#406 had a discussion about GC. It seems OCI Distribution-spec will not define GC policy and behavior for OCI registries in the short term.

@sajayantony
Copy link
Contributor

Also wanted to include the option to consider manually scripting this. Manifest delete of a tagged digest to some extent is like pushing to latest.

Can the user script and pipe the output into manifest delete? Is this flag even needed since this is until we have referrers as default and this flag becomes obsolete and a no-op.

I not really certain this is necessary since manifest deletes of untagged manifests are handled by registries differently.

@qweeah
Copy link
Contributor Author

qweeah commented May 27, 2023

Also wanted to include the option to consider manually scripting this. ... Can the user script and pipe the output into manifest delete?

This requires a change in oras-go, to return an aggregate error including all the dangling referrers index nodes that failed to be cleaned. I want to point out that if registry deletion is disabled, the piped command will still fail.

Is this flag even needed since this is until we have referrers as default and this flag becomes obsolete and a no-op.

No, but the proposed change is aiming for registries without referrers API. We can keep it in oras v1 which serves as long term support for OCI 1.0 registries and remove it in oras v2.

@sajayantony
Copy link
Contributor

sajayantony commented May 31, 2023

Even if we keep the flag scope it so that we don't end up with things like --insecure which caused and overly generic term to that could not be used again. I would say make it specific so that it avoids overarching implications. Steer clear of using generic terms that can apply to a wide range of things. Instead, opt for more specific terms that highlight the unique aspects of what you are naming.

For e.g --skip-delete-referrers to me this flag is clearer and yes it can apply to other commands and hopefully will not be passed by the user and we avoid confusion of the topic of GC that is a whole new can of worms.

@qweeah
Copy link
Contributor Author

qweeah commented May 31, 2023

For e.g --skip-delete-referrers to me this flag is clearer and yes it can apply to other commands and hopefully will not be passed by the user and we avoid confusion of the topic of GC that is a whole new can of worms.

Agree. GC is too generic and we should avoid it. --skip-delete-referrers sounds good to me.

@FeynmanZhou
Copy link
Member

--skip-delete-referrers sounds good to me.

@qweeah
Copy link
Contributor Author

qweeah commented Jun 5, 2023

Had a discussion offline with @FeynmanZhou @yizha1 and @shizhMSFT, want to point out that to avoid breaking change, @shizhMSFT suggested to set --skip-delete-referrers default to false, which is the same behavior as the stable release oras 1.0.0.

opencontainers/distribution-spec#406 had a discussion about GC. It seems OCI Distribution-spec will not define GC policy and behavior for OCI registries in the short term.

I agree that removing unused referrers index goes beyond the common scope of registry clients, so we will change the default value to true in oras 2.0 release if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants