AliyunContainerService / pouch

An Efficient Enterprise-class Container Engine
https://pouchcontainer.io
Apache License 2.0
4.64k stars 949 forks source link

bugfix: removing image by ID should conflict with running container. #2926

Closed zjumoon01 closed 5 years ago

zjumoon01 commented 5 years ago

Ⅰ. Describe what this PR did

If image is used by a running container and this image has another tag, there are two reference of this image. Remove the image by ID without "--force" will success that is unexpected.

This patch will fix it. We should check if any containers using this image ID.

Ⅱ. Does this pull request fix one issue?

NONE

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

step 1. Pull image registry.hub.docker.com/library/busybox:1.28 step 2. Tag this image to registry.hub.docker.com/library/busybox:tag2 step 3. Run a container with this image step 4. Pouch rmi without "--force", the image will removed unexpected.

Ⅴ. Special notes for reviews

codecov[bot] commented 5 years ago

Codecov Report

Merging #2926 into master will decrease coverage by 15.7%. The diff coverage is 30.76%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2926       +/-   ##
===========================================
- Coverage   66.78%   51.07%   -15.71%     
===========================================
  Files         289      286        -3     
  Lines       18299    18178      -121     
===========================================
- Hits        12221     9285     -2936     
- Misses       4645     7396     +2751     
- Partials     1433     1497       +64
Flag Coverage Δ
#integration_test_0 36.14% <15.38%> (+0.05%) :arrow_up:
#integration_test_1 35.07% <30.76%> (-0.43%) :arrow_down:
#integration_test_2 ?
#integration_test_3 ?
#node_e2e_test 34.15% <7.69%> (-0.07%) :arrow_down:
#unittest ?
Impacted Files Coverage Δ
storage/quota/quota.go 6.45% <0%> (ø) :arrow_up:
daemon/mgr/container.go 56.19% <0%> (-3.75%) :arrow_down:
daemon/mgr/container_storage.go 43.92% <33.33%> (-10.99%) :arrow_down:
apis/server/image_bridge.go 60.44% <60%> (-18.02%) :arrow_down:
client/container_restart.go 0% <0%> (-100%) :arrow_down:
client/image_pull.go 0% <0%> (-100%) :arrow_down:
apis/opts/sysctl.go 0% <0%> (-100%) :arrow_down:
client/volume_create.go 0% <0%> (-100%) :arrow_down:
client/image_remove.go 0% <0%> (-100%) :arrow_down:
client/daemon_update.go 0% <0%> (-100%) :arrow_down:
... and 168 more