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: return mirror pod in GetActivePods() #74222

Merged
merged 2 commits into from
Mar 5, 2019

Conversation

Huang-Wei
Copy link
Member

@Huang-Wei Huang-Wei commented Feb 18, 2019

What type of PR is this?

/kind bug

What this PR does / why we need it:

For static pod, kubelet maintains a pair of {static pod, mirror pod} internally. Mirror pod reflects the real status of the pod, and also persisted in etcd/apiserver, audited by admission plugins, etc.

But when kubelet makes eviction decisions, it fetches regular pods + static pods. It's problematic b/c "static pod" is just a snapshot of the yaml file, hence it doesn't carry the real info like "spec.priority" (usually only "spec.priorityClassName" is defined in yaml file and hence "spec.priority" is nil b/c it's updated by admission plugin). This is what issue #73572 reported.

Which issue(s) this PR fixes:

Fixes #73572

Special notes for your reviewer:

This PR is based on the assumption that static pod don't need or can't be updated. Otherwise I can come up with optimal solutions.

Does this PR introduce a user-facing change?:

Kubelet won't evict a static pod with priority `system-node-critical` upon resource pressure.

/sig node
/sig scheduling

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 18, 2019
@Huang-Wei
Copy link
Member Author

/retest

@anarchistHH1983
Copy link

anarchistHH1983 commented Feb 18, 2019 via email

@Huang-Wei Huang-Wei marked this pull request as ready for review February 18, 2019 22:09
@Huang-Wei
Copy link
Member Author

cc/ @yujuhong as you seem to be most recent author on mirror pod related logic. Ignore if I'm wrong.

/priority important-soon

@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 Feb 18, 2019
@Huang-Wei
Copy link
Member Author

/retest

@Huang-Wei
Copy link
Member Author

pull-kubernetes-local-e2e-containerized keeps failing. Related with #73073

@Huang-Wei
Copy link
Member Author

/retest

1 similar comment
@Huang-Wei
Copy link
Member Author

/retest

@Huang-Wei
Copy link
Member Author

/assign @yujuhong

for reviewing.

@derekwaynecarr
Copy link
Member

is there a e2e or unit test we can write around eviction manager to confirm this does not regress again?

@Huang-Wei
Copy link
Member Author

@derekwaynecarr I will try to compose a test.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 25, 2019
@Huang-Wei
Copy link
Member Author

/retest

@Huang-Wei
Copy link
Member Author

@derekparker e2e test has been added, PTAL. I verified locally that it fails on codebase without my change, and passes with my change.

PS: the local test is running as make test-e2e-node SKIP="XYZ" FOCUS="SystemNodeCriticalPod" TEST_ARGS='--feature-gates=DynamicKubeletConfig=true,LocalStorageCapacityIsolation=true'.

PSS: the e2e test gets skipped due to keyword "slow/serial/disruptive tests". Let me know if you'd like to enable it in ci pre-commit temporarily.

@derekwaynecarr
Copy link
Member

I will verify locally for now, thanks for test.

@@ -88,7 +88,19 @@ func (kl *Kubelet) listPodsFromDisk() ([]types.UID, error) {

// GetActivePods returns non-terminal pods
func (kl *Kubelet) GetActivePods() []*v1.Pod {
allPods := kl.podManager.GetPods()
allPods, mirrorPods := kl.podManager.GetPodsAndMirrorPods()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we make this change within GetPodsAndMirrorPods() fn? I don't see any other place in the code where this is being used.

Copy link
Member Author

Choose a reason for hiding this comment

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

GetPodsAndMirrorPods() is defined as:

// GetPodsAndMirrorPods returns the both regular and mirror pods.

So IMO "regular pods" literally means all pods including "real regular" and "static" pods. I prefer to think of current function as a consistent behavior with the comment.

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 fine with the change, just that I am not sure, if there is a need of using static pods somewhere else in the code base instead of using mirror pods. If we have some use then it makes sense to keep the function as is.

@ravisantoshgudimetla
Copy link
Contributor

I verified this test locally on kube master branch, it is working as expected but I see the following the logs even when the eviction is not happening.

kubelet_pods.go:914] Pod "hello-world-127.0.0.1_kube-system(8c4c406b-3aa1-11e9-b9d9-c85b76333877)" is terminated, but some containers are still running

@Huang-Wei
Copy link
Member Author

Kindly ping @derekwaynecarr as 1.14 code freeze is approaching.

cc/ @bsalamat @k82cn

@derekwaynecarr
Copy link
Member

thank you for adding the test case.

/approve
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: derekwaynecarr, Huang-Wei

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 Mar 5, 2019
@Huang-Wei
Copy link
Member Author

/retest

@namreg
Copy link
Contributor

namreg commented Mar 7, 2019

this patch does not work. see #73572 (comment)

@@ -88,7 +88,19 @@ func (kl *Kubelet) listPodsFromDisk() ([]types.UID, error) {

// GetActivePods returns non-terminal pods
func (kl *Kubelet) GetActivePods() []*v1.Pod {
allPods := kl.podManager.GetPods()
allPods, mirrorPods := kl.podManager.GetPodsAndMirrorPods()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the other usage of mirrorPods in removeOrphanedPodStatuses, the mirrorPods can be in the Map structure shown below (and not affecting functionality).
I wonder if GetPodsAndMirrorPods should return mirror pods in Map.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tedyu this PR is incomplete. Please check the other PR #75144.

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. 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. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

Static and critical pod is evicted
8 participants