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

Garbage collect unidentified Kubernetes containers. #5395

Merged
merged 1 commit into from
Mar 12, 2015

Conversation

vmarmol
Copy link
Contributor

@vmarmol vmarmol commented Mar 12, 2015

These containers may be caused by a change in the Kubernetes naming
convention. The old containers are killed, the new ones started, but the
old ones are never GC'd. This change makes Kubelet GC all Kubernetes
containers, old and new.

Fixes #5372.

@vmarmol
Copy link
Contributor Author

vmarmol commented Mar 12, 2015

Verified changes on a new cluster. PTAL @yujuhong @dchen1107 when you get a chance :)

@dchen1107 dchen1107 self-assigned this Mar 12, 2015
name string
}

unidentifiedContainers := make([]unidentifiedContainer, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Are you removing the user created dead containers which are not managed by kubernetes. Is that what we want?

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, never mind. Expanding the code a little, the logic is against kubernetes containers only.

@dchen1107
Copy link
Member

LGTM except one nit.

These containers may be caused by a change in the Kubernetes naming
convention. The old containers are killed, the new ones started, but the
old ones are never GC'd. This change makes Kubelet GC all Kubernetes
containers, old and new.

Fixes kubernetes#5372.
uidToIDMap := map[string][]string{}
for _, container := range containers {
_, uid, name, _ := dockertools.ParseDockerName(container.Names[0])
if uid == "" && name == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if this condition covers all cases (and you probably know better than me). It'd be more clear if we can get an error from ParseDockerName() if anything goes wrong, which will help if we ever change the naming scheme again. I see you have a TODO there though, so I guess it's fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am equally unhappy and I agree the error route is more correct. I guess I should tackle that sooner rather than later :P I'll send a PR your way sometime today.

@yujuhong
Copy link
Contributor

LGTM otherwise, and thanks for fixing this!

dchen1107 added a commit that referenced this pull request Mar 12, 2015
Garbage collect unidentified Kubernetes containers.
@dchen1107 dchen1107 merged commit ee4e887 into kubernetes:master Mar 12, 2015
@vmarmol vmarmol deleted the fix branch March 12, 2015 21:43
@brendandburns brendandburns mentioned this pull request Mar 16, 2015
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.

Kubelet log filled with errors
4 participants