-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Dockerregistry hard prune fix layer links #17020
Dockerregistry hard prune fix layer links #17020
Conversation
/lgtm |
/hold |
logger := context.GetLogger(ctx) | ||
vacuum := storage.NewVacuum(ctx, r.storageDriver) | ||
|
||
logger.Debugln("Removing %s repository", r.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debugf
err = repositoryEnumerator.Enumerate(ctx, func(repoName string) error { | ||
if !dryRun { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dryRun is confusing, after Enumerate you call these functions unconditionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's ok because the pruner's never get values set if it's dryrun.
but i agree that some comments would go a long way in this logic.
After discussion with Oleg and Michael, we realized that in its current form, this PR is not good enough. |
f25315b
to
465ad83
Compare
465ad83
to
eed4633
Compare
/test extended_image_registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits.
gc.repoName = repoName | ||
} | ||
|
||
func (gc *garbageColletor) SetManifestLink(svc distribution.ManifestService, repoName string, dgst digest.Digest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd prefer add instead of set to make it more aligned with real-world garbage collectors.
By marking an object for garbage collection, you don't want to clear the mark from any other marked object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think Set is appropriate here because it's not appending the value to anything, it's replacing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's replacing it.
And that's the problem. Those attributes holding objects marked for deletion should be arrays or set.
Requiring a user to call Collect()
each time when he marks a single object for deletion (otherwise the garbage collector forgets earlier object) suggests broken design and makes the gb unusable for generic use.
But as I said, it's a nit since the gb is not exported.
return nil | ||
} | ||
|
||
type garbageColletor struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Godoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also typo. should be garbageCollector.
return fmt.Errorf("failed to delete the manifest link %s@%s: %v", repoName, dgst, err) | ||
} | ||
|
||
gc.SetManifestLink(manifestService, repoName, dgst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put here a comment why the deletion needs to be delayed.
// We cannot delete the repository at this point, because it would break Enumerate. | ||
reposToDelete = append(reposToDelete, repoName) | ||
|
||
gc.SetRepository(repoName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain why the deletion needs to be delayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please doc the whole logic of how this deferred deletion works (and why it is necessary).
logger := context.GetLogger(ctx) | ||
vacuum := storage.NewVacuum(ctx, p.StorageDriver) | ||
|
||
logger.Debugln("Removing %s repository", reponame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugf?
func (p *RegistryPruner) DeleteManifestLink(ctx context.Context, svc distribution.ManifestService, reponame string, dgst digest.Digest) error { | ||
logger := context.GetLogger(ctx) | ||
|
||
logger.Printf("Deleting manifest link: %s@%s", reponame, dgst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how you've made the decision between printf and debugf for the various Delete* functions, but it seems inconsistent.
} | ||
|
||
func (p *RegistryPruner) DeleteBlob(ctx context.Context, dgst digest.Digest) error { | ||
vacuum := storage.NewVacuum(ctx, p.StorageDriver) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why no logging for this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vacuum logs this operation on its own.
gc.repoName = repoName | ||
} | ||
|
||
func (gc *garbageColletor) SetManifestLink(svc distribution.ManifestService, repoName string, dgst digest.Digest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think Set is appropriate here because it's not appending the value to anything, it's replacing it.
return nil | ||
} | ||
|
||
type garbageColletor struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also typo. should be garbageCollector.
// We cannot delete the repository at this point, because it would break Enumerate. | ||
reposToDelete = append(reposToDelete, repoName) | ||
|
||
gc.SetRepository(repoName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please doc the whole logic of how this deferred deletion works (and why it is necessary).
eed4633
to
0684af4
Compare
/test extended_image_registry |
/lgtm |
@legionus i guess you can just remove the hold once the registry test passes. |
0684af4
to
79afcb3
Compare
Signed-off-by: Gladkov Alexey <[email protected]>
79afcb3
to
9421ecc
Compare
/test extended_image_registry |
/retest |
@legionus: you cannot LGTM your own PR. In response to this:
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. |
/hold cancel |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bparees, dmage, legionus The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue (batch tested with PRs 17020, 17026, 17000, 17010). |
This commits allows to deploy the RDO registry with OpenShift 3.7. It currently uses the "rdo-test" branch because there is still one unmerged pull request upstream that hasn't merged yet upstream. Delta from OpenShift 3.5 that is interesting to us: - Significant improvements for registry and image pruning see [1][2][3][4] - docker-registry can now use reencrypt routes [5] - Metrics and logging were deployed by default in 3.5, this is no longer the case in 3.7, avoiding an unnecessary impact on performance. [6] - We're now deploying a persistent volume for the docker-registry service on the local filesystem. [1]: openshift/origin#13671 [2]: openshift/origin#16717 [3]: openshift/origin#16656 [4]: openshift/origin#17020 [5]: openshift/origin#14249 [6]: openshift/openshift-ansible@660bafe Change-Id: I5c364a1aab883b6af061051bf190ce857bf2e1f9
Fixes BZ#1483930