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

Cleanup docker images #5768

Merged
merged 5 commits into from
Jun 4, 2019
Merged

Cleanup docker images #5768

merged 5 commits into from
Jun 4, 2019

Conversation

cgbaker
Copy link
Contributor

@cgbaker cgbaker commented May 29, 2019

Resolves #5659

Before 0.9, the docker driver would remove the docker container in run() after it had finished. After the refactor as a task driver plugin, this code was left in StartTask(). However, this was causing DestroyTask() to error early when it attempted to inspect the (deleted) container. This early exit was preventing image cleanup from happening.

This change moves the container remove over to DestroyTask(), so that it can be inspected and stopped. Tests are added for the image GC.

Update: Also, the process has been hardened to handle cases where the docker image has been removed out-of-band.

@cgbaker cgbaker requested a review from nickethier May 29, 2019 22:44
CHANGELOG.md Outdated Show resolved Hide resolved
drivers/docker/driver.go Outdated Show resolved Hide resolved
@cgbaker cgbaker force-pushed the b-nmd-1489-cleanup-docker-images branch 3 times, most recently from 13ad91b to d00ed5c Compare May 30, 2019 01:16
Copy link
Contributor

@notnoop notnoop left a comment

Choose a reason for hiding this comment

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

The change is lgtm - but we probably should be resilient so we handle out-of-band container removals.

drivers/docker/driver.go Outdated Show resolved Hide resolved
Chris Baker added 2 commits June 3, 2019 19:04
…erroring early due to an attempt to inspect an image that had already been removed
- modified tests to cleanup now that RemoveContainer isn't in StartTask
- fix some broken tests by removing docker images/containers before test
@cgbaker cgbaker force-pushed the b-nmd-1489-cleanup-docker-images branch from 45a3408 to 3b82770 Compare June 3, 2019 19:05
} else {
h.logger.Debug("not removing container due to config")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cgbaker cgbaker force-pushed the b-nmd-1489-cleanup-docker-images branch from 3b68ae6 to 262c863 Compare June 3, 2019 19:52
Copy link
Contributor

@notnoop notnoop left a comment

Choose a reason for hiding this comment

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

lgtm - with a minor point about logging level - merge when you are ready.

}
switch err.(type) {
case *docker.NoSuchContainer:
h.logger.Error("failed to inspect container state, will proceed with DestroyTask",
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels a bit odd to be Error log considering that we handle it quite well. I would downgrade it to info or debug with it indicating "container was deleted out-of-band, will proceed with DestroyTask"`.

@cgbaker cgbaker force-pushed the b-nmd-1489-cleanup-docker-images branch from 4211b39 to 7b6d233 Compare June 3, 2019 21:21
@cgbaker cgbaker merged commit 168e3e9 into master Jun 4, 2019
@cgbaker cgbaker deleted the b-nmd-1489-cleanup-docker-images branch June 4, 2019 00:16
@github-actions
Copy link

github-actions bot commented Feb 9, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nomad is no longer cleaning up unused Docker images.
3 participants