Skip to content

kubelet: cm: refactor QoS logic into seperate interface#41833

Merged
k8s-github-robot merged 1 commit into
kubernetes:masterfrom
sjenning:qos-refactor
Mar 1, 2017
Merged

kubelet: cm: refactor QoS logic into seperate interface#41833
k8s-github-robot merged 1 commit into
kubernetes:masterfrom
sjenning:qos-refactor

Conversation

@sjenning

@sjenning sjenning commented Feb 21, 2017

Copy link
Copy Markdown
Contributor

This commit has no functional change. It refactors the QoS cgroup logic into a new QOSContainerManager interface to allow for better isolation for QoS cgroup features coming down the pike.

This is a breakout of the refactoring component of my QoS memory limits PR #41149 which will need to be rebased on top of this.

@vishh @derekwaynecarr

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 21, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Feb 21, 2017
@k8s-reviewable

Copy link
Copy Markdown

This change is Reviewable

@derekwaynecarr derekwaynecarr added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Feb 21, 2017
@derekwaynecarr

Copy link
Copy Markdown
Member

Per our chat @vishh , I will take over review of this PR.

@derekwaynecarr derekwaynecarr added this to the v1.6 milestone Feb 21, 2017

@derekwaynecarr derekwaynecarr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

few minor nits, update then I will tag.

Comment thread pkg/kubelet/cm/container_manager.go Outdated
// - Ensures that the Docker daemon is in a container.
// - Creates the system container where all non-containerized processes run.
Start(*v1.Node) error
Start(*v1.Node, func() []*v1.Pod) error

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you create a type in kubelet/cm that is

// ActivePodsFunc returns pods bound to the kubelet that are active (i.e. non-terminal state)
type ActivePodsFunc func() []*v1.Pod

so the signature is clear about the call expects?

Comment thread pkg/kubelet/cm/container_manager.go Outdated
// GetQOSContainersInfo returns the names of top level QoS containers
GetQOSContainersInfo() QOSContainersInfo

// UpdateQOSCgroups returns the names of top level QoS containers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

godoc is wrong, it performs housekeeping updates to ensure that the top level QoS containers have their desired state. also note that this operation is thread-safe.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

or needs to be.

}

func (cm *containerManagerImpl) setupNode() error {
func (cm *containerManagerImpl) setupNode(getPods func() []*v1.Pod) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

activePodsFn ActivePodsFunc as argument.

}

func (cm *containerManagerImpl) Start(node *v1.Node) error {
func (cm *containerManagerImpl) Start(node *v1.Node, getPods func() []*v1.Pod) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here, take an ActivePodsFunc, and make sure active name propagates.

return m.qosContainersInfo
}

func (m *qosContainerManagerImpl) Start(nodeInfo *v1.Node, getPods func() []*v1.Pod) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here..

qosContainersInfo QOSContainersInfo
subsystems *CgroupSubsystems
cgroupManager CgroupManager
getPods func() []*v1.Pod

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

activePods

@derekwaynecarr

Copy link
Copy Markdown
Member

@k8s-bot -- lets try now!

@derekwaynecarr

Copy link
Copy Markdown
Member

@k8s-bot test this

@sjenning

Copy link
Copy Markdown
Contributor Author

@k8s-bot gce etcd3 e2e test this
@k8s-bot cvm gce e2e test this

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2017
@sjenning

Copy link
Copy Markdown
Contributor Author

@k8s-bot test this

@sjenning

Copy link
Copy Markdown
Contributor Author

@k8s-bot gce etcd3 e2e test this

m.Lock()
defer m.Unlock()

qosConfigs := map[v1.PodQOSClass]*CgroupConfig{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do you mind if we add this in a follow-on and just have this return nil after the lock/defer lock call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure

@derekwaynecarr

Copy link
Copy Markdown
Member

one minor request so the change is entirely structural, we can do the writes in our follow-on for memory/cpu but at least we can get the scaffolding in asap.

@sjenning

Copy link
Copy Markdown
Contributor Author

@k8s-bot gce etcd3 e2e test this
@k8s-bot non-cri e2e test this
@k8s-bot non-cri node e2e test this

Comment thread pkg/kubelet/kubelet.go Outdated
if err := pcm.EnsureExists(pod); err != nil {
return fmt.Errorf("failed to ensure that the pod: %v cgroups exist and are correctly applied: %v", pod.UID, err)
}
if err := kl.containerManager.UpdateQOSCgroups(); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@sjenning -- this is the wrong order... this should be before EnsureExists, not after. sorry for just catching this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i also wonder if we should change the pcm.EnsureExists step for now to the following:

if !pcm.Exists {
updateQOSCgroups()
pcm.EnsureExists()
}

in this way we don't attempt any update when its not necessary.

Comment thread pkg/kubelet/kubelet_pods.go Outdated
// been decreased earlier
reduceCpuLimits = false
}
if err := kl.containerManager.UpdateQOSCgroups(); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this needs to be after KillPod(), not before.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 27, 2017
@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 27, 2017
@sjenning

Copy link
Copy Markdown
Contributor Author

rebased on top of #41234 that will hopefully merge soon

Comment thread pkg/kubelet/cm/container_manager.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i know @vishh asked that this be called "Containers".

similar to the discussion on node allocatable, i am not going to hold up this pr on naming conventions.

we can fix that across the board in a later pr.

right now "Cgroups" is consistent with "PodContainerManager" terminology.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i also want to go on the record that "container" is not defined in the kernel, but "cgroup" is. and container is an overloaded term in a project like this.

// - Ensures that the Docker daemon is in a container.
// - Creates the system container where all non-containerized processes run.
Start(*v1.Node) error
Start(*v1.Node, ActivePodsFunc) error

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think we can move this to a struct in a follow-on. i do not want to hold this pr on that change.

@derekwaynecarr

Copy link
Copy Markdown
Member

any nits can be handled in a follow-on. i am tagging this /lgtm and marking do-not-merge to ensure that node allocatable pr lands first.

@derekwaynecarr derekwaynecarr added do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Feb 27, 2017
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 27, 2017
@sjenning

Copy link
Copy Markdown
Contributor Author

Rebased on top of node alloc PR w/ systemd fixes and it works. Add to add new commit to work with new node allocatable code ee2dcce

The changes mostly center around the cgroupRoot being modified from nodeConfig.CgroupRoot and the kubepods cgroup not being created at constructor time, but rather at setupNode() time, meaning the sanity checks in NewQOSContainerManager() needed to move to Start().

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 28, 2017
@derekwaynecarr

Copy link
Copy Markdown
Member

/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 Feb 28, 2017
@derekwaynecarr derekwaynecarr removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Feb 28, 2017
@k8s-github-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

The following people have approved this PR: derekwaynecarr, k8s-merge-robot, sjenning

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 28, 2017
@k8s-github-robot

Copy link
Copy Markdown

Automatic merge from submit-queue (batch tested with PRs 38676, 41765, 42103, 41833, 41702)

@k8s-github-robot k8s-github-robot merged commit 1351324 into kubernetes:master Mar 1, 2017
k8s-github-robot pushed a commit that referenced this pull request Mar 1, 2017
Automatic merge from submit-queue (batch tested with PRs 41644, 42020, 41753, 42206, 42212)

Burstable QoS cgroup has cpu shares assigned

**What this PR does / why we need it**:
This PR sets the Burstable QoS cgroup cpu shares value to the sum of the pods cpu requests in that tier.  We need it for proper evaluation of CPU shares in the new QoS hierarchy.

**Special notes for your reviewer**:
It builds against the framework proposed for #41833
@sjenning sjenning deleted the qos-refactor branch August 16, 2017 02: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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

7 participants