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

Fix Docker image deletion when using remove_images: true #361

Closed
wants to merge 3 commits into from

Conversation

rshad
Copy link

@rshad rshad commented Feb 5, 2020

Hi all!

This PR resolves #360

My fix is based on the idea of deleting the target Docker image only if it's not being used by an existing container, in other cases Kitchen will print an INFO message.

Note: I first merged the fix of #356 from the corresponding fork branch: paulcalabro:fix-ip-address-issue.

Kr,

Rshad

@@ -35,7 +35,7 @@ def parse_image_id(output)

def remove_image(state)
image_id = state[:image_id]
docker_command("rmi #{image_id}")
run_command("docker ps -a | grep -q #{image_id} && echo 'Can not delete such image; It is being used by running container/s' || docker rmi #{image_id}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we implement this using a new method inside this helper instead of in line with bash? I'd rather raise an exception and allow test kitchen to handle the exception instead of writing a message to stdout.

Something more like this?

def image_in_use?
  # determine if image is in use with a running container
end

def remove_image(state)
  image_id = state[:image_id]
  raise "Can not delete image #{state[:image_id]}. It is being used by a running container." if image_in_use?
  docker_command("rmi #{image_id}")
end

@jeffreycoe
Copy link
Contributor

jeffreycoe commented Jun 23, 2020

Hi @rshad - Do you have any update to this PR based on the previous feedback? Do we still need these updates or can this PR be closed?

Also, another PR was merged to fix #356, so this change would have to be removed from this PR. Thanks.

@rshad
Copy link
Author

rshad commented Jun 23, 2020

Hi @rshad - Do you have any update to this PR based on the previous feedback? Do we still need these updates or can this PR be closed?

Also, another PR was merged to fix #356, so this change would have to be removed from this PR. Thanks.

Hi @jeffreycoe, sorry I didn't have time to add the changes you requested before, but I think this issue is still persisting.

Kind regards,

@jeffreycoe
Copy link
Contributor

@rshad - Thanks for the response. Will you be updating this PR with these changes, or can this PR be closed out and be addressed at a later time?

@rshad
Copy link
Author

rshad commented Jul 1, 2020

@rshad - Thanks for the response. Will you be updating this PR with these changes, or can this PR be closed out and be addressed at a later time?

Sorry, I am not working with kitchen since many months ago and I don't think that I'll be adding the related changes soon.

Kind regards,

Rshad

@jeffreycoe
Copy link
Contributor

@rshad Ok - I'll close this PR for now, and we can revisit this at a later time. Thanks!

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

Successfully merging this pull request may close these issues.

Docker images deletions fails when instances share the same image ID
3 participants