-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
specify garbage collection #13087
Conversation
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. |
Copied from #13065 My main concerns about gc comes to
It would be nice to consider these for anyone who is going to review this pr. |
I'll take a look. Thanks Emma. On Mon, Aug 24, 2015 at 5:13 PM Emma He notifications@github.com wrote:
|
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. |
There was a problem hiding this comment.
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.
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? |
0da63b6
to
271895d
Compare
|
||
<!-- END MUNGE: UNVERSIONED_WARNING --> | ||
|
||
# Garbage Collection |
There was a problem hiding this comment.
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"
cc @kubernetes/goog-node |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the leading >
intentional?
There was a problem hiding this comment.
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).
5679d0b
to
1536f78
Compare
Mostly the latter one.
Cleaning up all of the volumes roughly seems a little unfriendly to me. What do you say?
kubelet relies on the dead containers to make the strategy sort of. Hence zero should be a unwanted param value theoretically, yet permitted now.
This is simply a question. Inspired by #3393 /cc @pwittrock The comments has been addressed. Please have a double check:) |
Fix #8416 |
@dalanlan Thanks for writing this documentation up. I am sure folks will find it very helpful.
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.
I agree we should warn users about this. I saw that you did so in your doc. Thanks!
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.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
87e800d
to
b43e931
Compare
The comments have been fully addressed. |
|
||
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
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 retainIt'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.
There was a problem hiding this comment.
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.
Just one more comment @dalanlan! Otherwise LGTM. |
90ca4ec
to
b1f6321
Compare
b1f6321
to
f5bdea8
Compare
I'd updated the doc.
|
Labelling this PR as size/L |
@dalanlan Thanks for all your work on this |
@k8s-bot ok to test
|
GCE e2e build/test failed for commit f5bdea8. |
Shame. I cannot really access the test details for Jenkins. And it should not break anything to change doc. |
@k8s-bot test this again please |
GCE e2e build/test passed for commit f5bdea8. |
The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label? |
Automatic merge from SubmitQueue |
Auto commit by PR queue bot
Fix #13065