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

specify garbage collection #13087

Merged

Conversation

dalanlan
Copy link
Contributor

Fix #13065

@k8s-bot
Copy link

k8s-bot commented Aug 24, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

@yujuhong yujuhong added sig/node Categorizes an issue or PR as relevant to SIG Node. kind/documentation Categorizes issue or PR as related to documentation. labels Aug 24, 2015
@dalanlan
Copy link
Contributor Author

Copied from #13065

My main concerns about gc comes to

  • What would kubelet do with the volumes (hostPath, for instance) of the container precisely when it's gonna to remove a exited container. l'll bet It wont please the users whether kubelet cleans the volumes or not. Greater customization should be allowed here.
  • Should warn the users that an external garbage collection tool is not recommended since it would break kubelet's behavior.
  • Since flag like --maximum-dead-containers-per-container has been provided to the users, what if we set it to 0? Would kubelet just accept this happily even it could hurt?
  • Is there still race condition (like break the pulling-image-process when gc) existing?

It would be nice to consider these for anyone who is going to review this pr.

@pwittrock
Copy link
Member

I'll take a look. Thanks Emma.

On Mon, Aug 24, 2015 at 5:13 PM Emma He notifications@github.com wrote:

Copied from #13065 #13065

My main concerns about gc comes to

  • What would kubelet do with the volumes (hostPath, for instance) of
    the container precisely when it's gonna to remove a exited container. *l'll
    bet It wont please the users whether kubelet cleans the volumes or not.
    Greater customization should be allowed here. *
  • Should warn the users that an external garbage collection tool is
    not recommended since it would break kubelet's behavior.
  • Since flag like --maximum-dead-containers-per-container has been
    provided to the users, what if we set it to 0? Would kubelet just accept
    this happily even it could hurt?
  • Is there still race condition (like break the pulling-image-process
    when gc) existing?
    It would be nice to consider these for anyone who
    is going to review this pr.


Reply to this email directly or view it on GitHub
#13087 (comment)
.

kubernetes manages lifecycle of all images through `imageManager`。
The policy for garbage collecting images we apply takes two factors into consideration,
`HighThresholdPercent` and `LowThresholdPercent`. Disk usage above the the high threshold
will trigger garbage collection, and never down to low threshold.
Copy link
Member

Choose a reason for hiding this comment

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

nit:

, and never down to low threshold.

Is this strictly true? Garbage collection attempts to free space by deleting images until "usage - (int64(im.policy.LowThresholdPercent) * capacity / 100)" bytes are freed. Maybe something like "Disk usage above the the high threshold will trigger garbage collection, which will attempt to delete unused images until the LowThresholdPercent is met"?

nit:
Maybe also mention that least recently used images are deleted first.

@pwittrock
Copy link
Member

Hey Emma,

with respect to the concerns you listed, are you concerned about what the current behavior is and how to document it, or are you asking how we can improve the existing behavior?


<!-- END MUNGE: UNVERSIONED_WARNING -->

# Garbage Collection
Copy link
Member

Choose a reason for hiding this comment

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

Please move this doc to docs/admin and add a link to the README.md in that directory, as a sub-bullet under "The kubelet binary"

@bgrant0607
Copy link
Member

cc @kubernetes/goog-node

@bgrant0607
Copy link
Member

cc @vishh re. disk management

container takes up some disk space.
Values less than zero for the last two are regarded as no limit.

> Note that we don't recommend external garbage collection tool, since it could break the behavior
Copy link
Member

Choose a reason for hiding this comment

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

Was the leading > intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was. Deprecated now (though).

@dalanlan dalanlan force-pushed the specify-garbage-collection branch 2 times, most recently from 5679d0b to 1536f78 Compare August 26, 2015 05:06
@dalanlan
Copy link
Contributor Author

with respect to the concerns you listed, are you concerned about what the current behavior is and how to document it, or are you asking how we can improve the existing behavior?

Mostly the latter one.

What would kubelet do with the volumes (hostPath, for instance) of the container precisely when it's gonna to remove a exited container. l'll bet It wont please the users whether kubelet cleans the volumes or not. Greater customization should be allowed here.

Cleaning up all of the volumes roughly seems a little unfriendly to me. What do you say?

Since flag like --maximum-dead-containers-per-container has been provided to the users, what if we set it to 0? Would kubelet just accept this happily even it could hurt?

kubelet relies on the dead containers to make the strategy sort of. Hence zero should be a unwanted param value theoretically, yet permitted now.

Is there still race condition (like break the pulling-image-process when gc) existing?

This is simply a question. Inspired by #3393

/cc @pwittrock The comments has been addressed. Please have a double check:)

@dalanlan
Copy link
Contributor Author

Fix #8416

@pwittrock
Copy link
Member

@dalanlan Thanks for writing this documentation up. I am sure folks will find it very helpful.

What would kubelet do with the volumes (hostPath, for instance) of the container precisely when it's gonna to remove a exited container. l'll bet It wont please the users whether kubelet cleans the volumes or not. Greater customization should be allowed here.

I am still learning about how GC interacts with volumes, but @vishh may be able to give a better answer here. If this is something that you would like to discuss more, it probably makes sense to open a separate issue to do so.

Should warn the users that an external garbage collection tool is not recommended since it would break kubelet's behavior.

I agree we should warn users about this. I saw that you did so in your doc. Thanks!

Since flag like --maximum-dead-containers-per-container has been provided to the users, what if we set it to 0? Would kubelet just accept this happily even it could hurt? kubelet relies on the dead containers to make the strategy sort of. Hence zero should be a unwanted param value theoretically, yet permitted now.

Good point about relying on dead containers, this would be a bug. From looking at the code, is does look like the GC will accept a flag of 0 for dead-per-container, and perform the garbage collection. We should probably create an issue to address bugs caused by garbage collecting containers we rely upon for correctly obeying restart policy. I am not certain that setting the min flag value to 1 will solve this issue entirely because the flag for max total dead containers may cause the same issue. I would consider flag values that cause undesirable but correct behavior (such as poor performance or deleting containers the use may want to examine later) to be a separate and more complicated issue.

Is there still race condition (like break the pulling-image-process when gc) existing?

I am not aware of any known race conditions caused by container or image garbage collection, and didn't see any open issues after doing a simple search. @yujuhong can you confirm?

Garbage collection is managed by kubelet automatically, mainly including unreferenced
images and dead containers. kubelet applies container garbage collection every minute
and image garbage collection every 5 minutes.
Note that we don't recommend external garbage collection tool, since it could break
Copy link
Contributor

Choose a reason for hiding this comment

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

A side note: Docker still can leak files and forget about them. External garbage collection tools to clean up behind docker might be useful. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The leaking issues troubles us a lot as well, i'll admit it, yet it's (maybe) a long-term run pb. External gc could be an short-term option, as long as it wont break kubelet itself.

@vishh
Copy link
Contributor

vishh commented Aug 26, 2015

  1. We generally discourage using hostpath for storing data. Use a volume. What if your container were to run on a machine with no local disk? May be, we need to document the recommendation clearly.
    The more the knobs the harder it is to understand and maintain the system.
  2. +1 for warning. As I mentioned in a comment, docker might still leak, and we might need an external garbage collector, or make kubelet smart enough to handle that.
  3. Not storing previous dead containers will affect debugging - mainly access to logs. On a node with very little disk space, it is possible for users to not retain any old containers, except for the running ones. WDYT? Our APIs should fail gracefully, if previous instances of a container is not found.
  4. I would hope for docker to handle these races. A image pull and deletion that ends up touching the same layers, should be synchronized by docker.

@dalanlan dalanlan force-pushed the specify-garbage-collection branch 2 times, most recently from 87e800d to b43e931 Compare August 27, 2015 06:45
@dalanlan
Copy link
Contributor Author

The comments have been fully addressed.
/cc @pwittrock @vishh


1. `minimum-container-ttl-duration`, minimum age for a finished container before it is
garbage collected. Default is 1 minute.
2. `maximum-dead-containers-per-container`, maximum number of old instances to retain
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a line stating that this should be set to a minimum value of 2 as of 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.

It's kinda tricky. What do you say about maximum-dead-containers flag then? That one could hurt as well :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Thats true. I was thinking that providing hints to have a stable
system will be very helpful to users. WDYT?

On Fri, Aug 28, 2015 at 5:57 PM, Emma He notifications@github.com wrote:

In docs/admin/garbage-collection.md
#13087 (comment)
:

+Note that we will skip the containers that are not managed by kubelet.
+
+### User Configuration
+
+Users are free to set their own value to address image garbage collection.
+
+1. image-gc-high-threshold, the percent of disk usage which triggers image garbage collection.
+Default is 90%.
+2. image-gc-low-threshold, the percent of disk usage to which image garbage collection attempts
+to free. Default is 80%.
+
+We also allow users to customize garbage collection policy, basically via following three flags.
+
+1. minimum-container-ttl-duration, minimum age for a finished container before it is
+garbage collected. Default is 1 minute.
+2. maximum-dead-containers-per-container, maximum number of old instances to retain

It's kinda tricky. What do you say about maximum-dead-containers flag
then? That one could hurt as well :-)


Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/13087/files#r38256861.

Copy link
Member

Choose a reason for hiding this comment

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

It is probably worth mentioning that maximum-dead-containers should be large enough to allow at least 2 dead containers-per-expected-container? May be also reference #13287 as an explanation for why these values are recommended.

@vishh
Copy link
Contributor

vishh commented Aug 29, 2015

Just one more comment @dalanlan! Otherwise LGTM.
@pwittrock I will let you make a final approval!

@dalanlan dalanlan force-pushed the specify-garbage-collection branch 2 times, most recently from 90ca4ec to b1f6321 Compare September 1, 2015 02:14
@dalanlan
Copy link
Contributor Author

dalanlan commented Sep 1, 2015

I'd updated the doc.

  1. Add the logic of policy dealing with the case in which maximum-dead-containers-per-container and maximum-dead-containers conflict.
  2. Sort out the previous mentioned flags pb.
    PTAL /cc @vishh @pwittrock

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 1, 2015
@k8s-github-robot
Copy link

Labelling this PR as size/L

@pwittrock pwittrock added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 1, 2015
@pwittrock
Copy link
Member

@dalanlan Thanks for all your work on this

@k8s-github-robot
Copy link

@k8s-bot ok to test

pr builder appears to be missing, activating due to 'lgtm' label.

@k8s-bot
Copy link

k8s-bot commented Sep 2, 2015

GCE e2e build/test failed for commit f5bdea8.

@dalanlan
Copy link
Contributor Author

dalanlan commented Sep 2, 2015

Shame. I cannot really access the test details for Jenkins. And it should not break anything to change doc.
May trigger this again, please? @pwittrock

@pwittrock
Copy link
Member

@k8s-bot test this again please

@k8s-bot
Copy link

k8s-bot commented Sep 2, 2015

GCE e2e build/test passed for commit f5bdea8.

@k8s-github-robot
Copy link

The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label?

@k8s-github-robot
Copy link

Automatic merge from SubmitQueue

k8s-github-robot pushed a commit that referenced this pull request Sep 3, 2015
@k8s-github-robot k8s-github-robot merged commit 80f2d89 into kubernetes:master Sep 3, 2015
@dalanlan dalanlan deleted the specify-garbage-collection branch October 14, 2015 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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

9 participants