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

Dockerregistry hard prune fix layer links #17020

Conversation

legionus
Copy link
Contributor

Fixes BZ#1483930

@legionus legionus self-assigned this Oct 24, 2017
@legionus legionus requested a review from dmage October 24, 2017 12:49
@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 24, 2017
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 24, 2017
@legionus legionus requested a review from bparees October 24, 2017 13:55
@bparees
Copy link
Contributor

bparees commented Oct 24, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 24, 2017
@dmage
Copy link
Member

dmage commented Oct 24, 2017

/hold
/test extended_image_registry

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 24, 2017
logger := context.GetLogger(ctx)
vacuum := storage.NewVacuum(ctx, r.storageDriver)

logger.Debugln("Removing %s repository", r.name)
Copy link
Member

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 {
Copy link
Member

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.

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 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.

@legionus legionus changed the title Dockerregistry hard prune fix layer links [WIP] Dockerregistry hard prune fix layer links Oct 24, 2017
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 24, 2017
@legionus
Copy link
Contributor Author

After discussion with Oleg and Michael, we realized that in its current form, this PR is not good enough.
I'm reworking it.

@legionus legionus force-pushed the dockerregistry-hard-prune-fix-layer-links branch from f25315b to 465ad83 Compare October 25, 2017 10:11
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 25, 2017
@legionus legionus force-pushed the dockerregistry-hard-prune-fix-layer-links branch from 465ad83 to eed4633 Compare October 25, 2017 10:21
@legionus
Copy link
Contributor Author

@bparees @miminar please review again

@legionus legionus changed the title [WIP] Dockerregistry hard prune fix layer links Dockerregistry hard prune fix layer links Oct 25, 2017
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 25, 2017
@legionus
Copy link
Contributor Author

/test extended_image_registry

Copy link

@miminar miminar left a 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) {
Copy link

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.

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 Set is appropriate here because it's not appending the value to anything, it's replacing it.

Copy link

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 {
Copy link

Choose a reason for hiding this comment

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

Godoc.

Copy link
Contributor

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)
Copy link

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)
Copy link

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.

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link

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) {
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 Set is appropriate here because it's not appending the value to anything, it's replacing it.

return nil
}

type garbageColletor struct {
Copy link
Contributor

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)
Copy link
Contributor

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).

@legionus legionus force-pushed the dockerregistry-hard-prune-fix-layer-links branch from eed4633 to 0684af4 Compare October 25, 2017 12:20
@legionus
Copy link
Contributor Author

@bparees @miminar comments addressed.

@legionus
Copy link
Contributor Author

/test extended_image_registry

@bparees
Copy link
Contributor

bparees commented Oct 25, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
@bparees
Copy link
Contributor

bparees commented Oct 25, 2017

@legionus i guess you can just remove the hold once the registry test passes.

@legionus legionus force-pushed the dockerregistry-hard-prune-fix-layer-links branch from 0684af4 to 79afcb3 Compare October 25, 2017 14:31
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
Signed-off-by: Gladkov Alexey <agladkov@redhat.com>
@legionus legionus force-pushed the dockerregistry-hard-prune-fix-layer-links branch from 79afcb3 to 9421ecc Compare October 25, 2017 14:50
@legionus
Copy link
Contributor Author

/test extended_image_registry

@legionus
Copy link
Contributor Author

/retest

@openshift-ci-robot
Copy link

@legionus: you cannot LGTM your own PR.

In response to this:

/lgtm
/unhold

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.

@legionus
Copy link
Contributor Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 25, 2017
@dmage
Copy link
Member

dmage commented Oct 25, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2017
@openshift-merge-robot
Copy link
Contributor

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@bparees bparees added the kind/bug Categorizes issue or PR as related to a bug. label Oct 25, 2017
@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 17020, 17026, 17000, 17010).

@openshift-merge-robot openshift-merge-robot merged commit e0032c4 into openshift:master Oct 25, 2017
rdoproject pushed a commit to rdo-infra/rdo-container-registry that referenced this pull request Nov 6, 2017
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
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. component/imageregistry kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants