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

fix(cpumanager): Do not release CPUs of init containers while they are being reused in app containers #104837

Merged
merged 1 commit into from
Jan 6, 2022

Conversation

eggiter
Copy link
Contributor

@eggiter eggiter commented Sep 8, 2021

What type of PR is this?

/kind bug

What this PR does / why we need it:

  • Currently, app containers in pod inherit CPUs from the pod's init containers when using static policy.
  • When init container is somehow removed(manually removed, GCed by docker, etc.), the inherited CPUs are released without checking if they are being used by app containers.
  • This PR fixes this by not releasing CPUs used by other containers in the pod.

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixes regression in CPUManager that it will release exclusive CPUs in app containers inherited from init containers when the init containers were removed. 

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 8, 2021
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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 cncf-cla: no Indicates the PR's author has not 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 Sep 8, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @eggiter!

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 8, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @eggiter. 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 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 Sep 8, 2021
@eggiter eggiter changed the title fix(cpumanager): Do not release CPUs of init containers while they are reusing in app containers fix(cpumanager): Do not release CPUs of init containers while they are being reused in app containers Sep 8, 2021
@eggiter
Copy link
Contributor Author

eggiter commented Sep 8, 2021

reply here with a new comment

I signed it.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 8, 2021
@eggiter

This comment has been minimized.

@matthyx
Copy link
Contributor

matthyx commented Sep 8, 2021

/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 Sep 8, 2021
@eggiter
Copy link
Contributor Author

eggiter commented Sep 8, 2021

/assign @klueska @matthyx

func (p *staticPolicy) RemoveContainer(s state.State, podUID string, containerName string) error {
klog.InfoS("Static policy: RemoveContainer", "podUID", podUID, "containerName", containerName)
cpusInUsing := getAssignedCPUsOfSiblings(s, podUID, containerName)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: cpusInUse ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks.

@eggiter eggiter requested a review from matthyx September 10, 2021 02:04
Copy link
Contributor

@matthyx matthyx left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 10, 2021
@pacoxu
Copy link
Member

pacoxu commented Sep 10, 2021

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 10, 2021
@pacoxu
Copy link
Member

pacoxu commented Sep 14, 2021

/priority important-soon
since it is regression

BTW, should it be cherry-picked to 1.19-1.22 once merged?

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 14, 2021
@ffromani
Copy link
Contributor

ffromani commented Sep 17, 2021

Thanks for this PR! does it fix a problem actually observed on some cluster or is it a robustness fix?
If this fixes a problem happened on a cluster, could you please file an issue describing the scenario and link it to this PR?
EDIT
that said, I see the merit in the fix here. I want to review a bit more the case but it seems a good fix.

@eggiter
Copy link
Contributor Author

eggiter commented Sep 18, 2021

does it fix a problem actually observed on some cluster or is it a robustness fix?
If this fixes a problem happened on a cluster, could you please file an issue describing the scenario and link it to this PR?

@ffromani
Copy link
Contributor

does it fix a problem actually observed on some cluster or is it a robustness fix?
If this fixes a problem happened on a cluster, could you please file an issue describing the scenario and link it to this PR?

* The former. it was indeed observed.

* sure thing.
  EDIT

* it was indeed observed but with **my intervention**, which i was testing some bug fixes of our internal Kubelet version. In order to do so, i manually removed the completed init container then the bug occurred.

* Is this robustness fix? i'm not sure. Anyway, the issued is filed: [CPUManager releases CPUs of init containers while they are being reused in app containers #105114](https://github.com/kubernetes/kubernetes/issues/105114).

Thanks. The only missing piece is if there is a kubernetes flow (GC is a good example) that triggers this bug without explicit manual action. The problem with manual action is that it's easy to void some key assumptions of the code, and in that case a fix is not warranted: in normal circumstances, the issue won't trigger.
Let's evaluate the scenarios on the issue discussion.

@eggiter
Copy link
Contributor Author

eggiter commented Sep 22, 2021

Let's evaluate the scenarios on the issue discussion.

Sure.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 21, 2021
@eggiter
Copy link
Contributor Author

eggiter commented Dec 24, 2021

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 24, 2021
@eggiter eggiter requested a review from matthyx December 24, 2021 06:50
@dims
Copy link
Member

dims commented Jan 6, 2022

/assign @mrunalp

@klueska @mrunalp this looks ready with at least one LGTM already.

@klueska
Copy link
Contributor

klueska commented Jan 6, 2022

This is a very weird edge case and can only be triggered if someone manually terminates a container using some mechanism external to kubernetes. I'm fine to include this change since it is fairly small and well contained, but as @fromanirh mentions in #104837 (comment) one should always be wary of what could happen when triggering container lifecycle events outside of the standard kubernetes mechanisms.

@klueska
Copy link
Contributor

klueska commented Jan 6, 2022

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eggiter, klueska, matthyx

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

The pull request process is described 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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 6, 2022
@k8s-ci-robot k8s-ci-robot merged commit 03ee86c into kubernetes:master Jan 6, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Jan 6, 2022
@eggiter eggiter deleted the fix-release-reused-cpus branch February 21, 2022 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

9 participants