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

kubelet/image: improve error handling on noImageToCleanup #117981

Closed
wants to merge 4 commits into from

Conversation

haitch
Copy link

@haitch haitch commented May 12, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

basically move 2 condition checks ahead, to scanning phase, instead of delete phase.

  • LastUsed condition check
  • FirstDetected condition check

then we can elegantly report no image to cleanup, in stead of failed to garbage collect required amount of images. Wanted to free 473842483 bytes, but freed 0 bytes

after the change, you either get no image to cleanup or image cleanup error.

Which issue(s) this PR fixes:

fixes #71869

Special notes for your reviewer:

  • .freeSpace is internal method, update to return error on NoImageToCleanup
  • only 2 caller on this method
    • GarbageCollect
    • DeleteUnusedImages
  • both caller been update to aware of this error pattern

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 12, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @haitch!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 12, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @haitch. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label May 12, 2023
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 12, 2023
@haitch haitch changed the title [WIP] kubelet/image: improve error handling on noImageToCleanup kubelet/image: improve error handling on noImageToCleanup May 12, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 12, 2023
@helayoty
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 12, 2023
@kubernetes kubernetes deleted a comment from haitch May 12, 2023
@kubernetes kubernetes deleted a comment from k8s-ci-robot May 12, 2023
@bart0sh bart0sh added this to Triage in SIG Node PR Triage May 14, 2023
@bart0sh
Copy link
Contributor

bart0sh commented May 15, 2023

/triage accepted
/priority important-longterm
/cc

@k8s-ci-robot k8s-ci-robot requested a review from bart0sh May 15, 2023 12:00
@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels May 15, 2023
@haitch
Copy link
Author

haitch commented May 19, 2023

Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! The changes look good.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: a791702cae8b85aee38a386ebac494dbb6a3b417

@bart0sh
Copy link
Contributor

bart0sh commented Jun 1, 2023

/assign @mrunalp @derekwaynecarr @dchen1107

@bart0sh bart0sh moved this from Needs Reviewer to Needs Approver in SIG Node PR Triage Jun 1, 2023
@mrunalp
Copy link
Contributor

mrunalp commented Oct 26, 2023

@haircommander ptal

@@ -39,6 +39,10 @@ import (
"k8s.io/kubernetes/pkg/kubelet/util/sliceutils"
)

var (
errNoImageToCleanup = goerrors.New("NoImageToCleanup")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing a reason to have this look like an event type. Maybe it would be better as "no images to cleanup" and then the error condition below would read more like a sentence?

@@ -323,6 +327,11 @@ func (im *realImageGCManager) GarbageCollect(ctx context.Context) error {
klog.InfoS("Disk usage on image filesystem is over the high threshold, trying to free bytes down to the low threshold", "usage", usagePercent, "highThreshold", im.policy.HighThresholdPercent, "amountToFree", amountToFree, "lowThreshold", im.policy.LowThresholdPercent)
freed, err := im.freeSpace(ctx, amountToFree, time.Now())
if err != nil {
if goerrors.Is(err, errNoImageToCleanup) {
klog.InfoS("No images eligible for garbage collection")
im.recorder.Eventf(im.nodeRef, v1.EventTypeWarning, events.FreeDiskSpaceFailed, err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

why only an event here?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 26, 2023
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot
Copy link
Contributor

Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Oct 26, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: feiskyer, haitch
Once this PR has been reviewed and has the lgtm label, please ask for approval from dchen1107. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

@haitch: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-unit 3957432 link true /test pull-kubernetes-unit
pull-kubernetes-integration 3957432 link true /test pull-kubernetes-integration
pull-kubernetes-dependencies 3957432 link true /test pull-kubernetes-dependencies
pull-kubernetes-conformance-kind-ga-only-parallel 3957432 link true /test pull-kubernetes-conformance-kind-ga-only-parallel
pull-kubernetes-e2e-gce 3957432 link true /test pull-kubernetes-e2e-gce
pull-kubernetes-verify 3957432 link true /test pull-kubernetes-verify
pull-kubernetes-typecheck 3957432 link true /test pull-kubernetes-typecheck
pull-kubernetes-node-e2e-containerd 3957432 link true /test pull-kubernetes-node-e2e-containerd
pull-kubernetes-e2e-kind 3957432 link true /test pull-kubernetes-e2e-kind
pull-kubernetes-linter-hints 3957432 link false /test pull-kubernetes-linter-hints
pull-kubernetes-e2e-kind-ipv6 3957432 link true /test pull-kubernetes-e2e-kind-ipv6
pull-kubernetes-verify-lint 3957432 link false /test pull-kubernetes-verify-lint

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dims dims added the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jan 4, 2024
@haitch haitch closed this Jan 30, 2024
SIG Node PR Triage automation moved this from Needs Approver to Done Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

failed to garbage collect required amount of images. Wanted to free 473842483 bytes, but freed 0 bytes
10 participants