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

Always run untag when removing docker image #70647

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

corvus-ch
Copy link
Contributor

@corvus-ch corvus-ch commented Nov 5, 2018

What type of PR is this?
/kind bug

What this PR does / why we need it:

Under certain conditions a docker image can have one tag while
assiciated to multiple repositories. This prevents the image from being
removed due to the multi repository association. Always removing all
tags, prevents this from happening.

This can be reproduced with the following:

docker pull centos:7
docker tag centos:7 example.com:1234/centos:latest
docker push example.com:1234/centos:latest
docker rmi example.com:1234/centos:latest
docker pull example.com:1234/centos:latest

This ends with an image which has one image tag but multiple repo digests.

docker image inspect centos:7 | jq '.[0] | .RepoTags, .RepoDigests'
[
  "centos:latest"
]
[
  "centos@sha256:67dad89757a55bfdfabec8abd0e22f8c7c12a1856514726470228063ed86593b",
  "example.com:1234/centos@sha256:67dad89757a55bfdfabec8abd0e22f8c7c12a1856514726470228063ed86593b"
]

Which issue(s) this PR fixes
none

Special notes for your reviewer:
none

Does this PR introduce a user-facing change?:

Image garbage collection no longer fails for images with only one tag but more than one repository associated.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 5, 2018
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 5, 2018
@corvus-ch corvus-ch changed the title Always run untag when removing docker image [WIP] Always run untag when removing docker image Nov 6, 2018
@k8s-ci-robot k8s-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 Nov 6, 2018
@corvus-ch corvus-ch force-pushed the imagegc_multi_repo_image_removal branch from aa84567 to 1d8e461 Compare November 6, 2018 15:41
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 6, 2018
@corvus-ch corvus-ch changed the title [WIP] Always run untag when removing docker image Always run untag when removing docker image Nov 6, 2018
@k8s-ci-robot k8s-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 Nov 6, 2018
@corvus-ch corvus-ch force-pushed the imagegc_multi_repo_image_removal branch from 1d8e461 to 9e8df0f Compare November 6, 2018 16:02
@sjenning
Copy link
Contributor

sjenning commented Nov 7, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 7, 2018
@corvus-ch
Copy link
Contributor Author

corvus-ch commented Dec 4, 2018

Is there some action required on my side for this to proceed? If this is the case, please let me known and I will take care of it.

@mhutter
Copy link

mhutter commented Dec 17, 2018

@sjenning is there something more required before this can be merged and backported?

@sjenning
Copy link
Contributor

needs lgtm and approval. I can only lgtm. This makes sense to me.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 17, 2018
@sjenning
Copy link
Contributor

/assign @derekwaynecarr @yujuhong
for review/approval

@derekwaynecarr
Copy link
Member

this makes sense to me as well.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: corvus-ch, derekwaynecarr

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2019
@k8s-ci-robot k8s-ci-robot merged commit cf24d24 into kubernetes:master Feb 26, 2019
@corvus-ch corvus-ch deleted the imagegc_multi_repo_image_removal branch February 27, 2019 05:19

for _, image := range images {
if _, err := ds.client.RemoveImage(image, dockertypes.ImageRemoveOptions{PruneChildren: true}); err != nil && !libdocker.IsImageNotFoundError(err) {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it start returning image not found error after all tags are deleted?

@redbaron
Copy link
Contributor

@corvus-ch , which problem does it solve? comment suggests that repo digests are preventing image from being deleted, but in my testing digests do not create any references, tags do and deleting all tags is enough to delete image

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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. 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

8 participants