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

Implement TopologyInfo and cpu_ids in podresources interface #93243

Merged

Conversation

AlexeyPerevalov
Copy link
Contributor

@AlexeyPerevalov AlexeyPerevalov commented Jul 20, 2020

/kind api-change

This PR introduces additional information numaid and cpu_ids list (in cpuset list format ).
It implements KEP 1884
It's necessary for topology aware scheduling, this information will be used in topology exposing daemon.

To test it you need to enable KubeletPodResources feature gate in the command line option or in the KubeletConfiguration (by default it's in the /var/lib/kubelet/config.yaml file)

Also you can use following sample to track down pod resources

package main

import (
        "context"
        "fmt"
        "time"

        podresources "k8s.io/kubernetes/pkg/kubelet/apis/podresources"
        podresourcesapi "k8s.io/kubernetes/pkg/kubelet/apis/podresources/v1alpha1"
)

var timeout = 2 * time.Minute

func main() {
        socket := "unix:///var/lib/kubelet/pod-resources/kubelet.sock"
        client, _, err := podresources.GetClient(socket, timeout, 1000)
        if err != nil {
                fmt.Println("Can't create client:", err)
                return
        }
        req := podresourcesapi.ListPodResourcesRequest{}
        resp, err := client.List(context.TODO(), &req)
        if err != nil {
                fmt.Println("Can't receive response:", err)
                return
        }
        for idx := range resp.PodResources {
                podresource := resp.PodResources[idx]
                fmt.Printf("podresource: %v", podresource)
        }
}

Issue: kubernetes/enhancements#2043

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 20, 2020
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 20, 2020
@AlexeyPerevalov AlexeyPerevalov marked this pull request as draft July 20, 2020 08:04
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 20, 2020
// DevicesProvider knows how to provide the devices used by the given container
type CPUsProvider interface {
GetCPUs(podUID, containerName string) []uint32
UpdateAllocatedDevices()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should name this more appropriately, maybe UpdateAllocatedCPUs(). Also, where is this method implemented? I assumed that it would be implemented in cpu_manager.go but didn't find its implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, nice catch, I forget to remove it from here. In DeviceManager this interface is necessary to actualize podDevices state (GetDevice of DeviceManager return devices from podDevices), for CPUManager, where we return cpu directly - UpdateAllocatedDevices interface is not necessary as well as something like podDevices abstraction, since CPUManager uses CheckpointState for such purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds reasonable!

func (m *manager) GetCPUs(podUID, containerName string) []uint32 {
cpus := m.state.GetCPUSetOrDefault(string(podUID), containerName)
result := []uint32{}
for cpu := range cpus.ToSliceNoSort() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This line should be corrected to : for _, cpu := range cpus.ToSliceNoSort() The current implementation results in the index values being stored in the result slice (e.g. []int32{0,1,2,3,4....} )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly

@AlexeyPerevalov AlexeyPerevalov force-pushed the NUMAidAndCPUidsInPodResources branch 2 times, most recently from df42f42 to a2bdeb9 Compare August 12, 2020 15:00
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 9, 2020
@AlexeyPerevalov AlexeyPerevalov changed the title Implement NUMA id and cpu_ids in podresources Implement TopologyInfo and cpu_ids in podresources interface Sep 9, 2020
@AlexeyPerevalov AlexeyPerevalov marked this pull request as ready for review October 13, 2020 12:53
@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 Oct 13, 2020
@AlexeyPerevalov
Copy link
Contributor Author

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 13, 2020
@AlexeyPerevalov
Copy link
Contributor Author

/retest

@dims
Copy link
Member

dims commented Nov 10, 2020

/milestone v1.20

@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Nov 10, 2020
@AlexeyPerevalov
Copy link
Contributor Author

/retest

@spiffxp
Copy link
Member

spiffxp commented Nov 10, 2020

possible github issue, please link if you run into this on other PR's kubernetes/test-infra#19910

@AlexeyPerevalov
Copy link
Contributor Author

possible github issue, please link if you run into this on other PR's kubernetes/test-infra#19910

Yes, it's
I and prow robot can't
git fetch https://github.com/kubernetes/kubernetes.git pull/93243/head
as result no commits after fetch.

@AlexeyPerevalov AlexeyPerevalov force-pushed the NUMAidAndCPUidsInPodResources branch 2 times, most recently from 2560c69 to f221e13 Compare November 11, 2020 08:07
This change is necessary for supporting Topology in the ContainerDevices.

Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 11, 2020
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 11, 2020

@AlexeyPerevalov: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce-device-plugin-gpu 6e4cc919b5e6ed4bf3e4c1bcfe5d7d22eda31f8a link /test pull-kubernetes-e2e-gce-device-plugin-gpu

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.

Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
PodDevices will have its own guard

Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
It covers deviceplugin & cpumanager.

It has drawback, since cpuset and all other structs including cadvisor's keep
cpu as int, but for protobuf based interface is better to have fixed
int.
This patch also introduces additional interface CPUsProvider, while
DeviceProvider might have been extended too.

Checkpoint not covered by unit test.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
@RenaudWasTaken
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 11, 2020
Copy link
Member

@derekwaynecarr derekwaynecarr left a comment

Choose a reason for hiding this comment

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

can you add a node_e2e test that invokes this in a follow-on?

/lgtm
/approve

@@ -393,11 +393,8 @@ func (m *ManagerImpl) Allocate(pod *v1.Pod, container *v1.Container) error {
func (m *ManagerImpl) UpdatePluginResources(node *schedulerframework.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error {
pod := attrs.Pod

m.mutex.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

just noting this appears resolved below

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexeyPerevalov, derekwaynecarr

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 Nov 11, 2020
@ffromani
Copy link
Contributor

ffromani commented Nov 11, 2020

can you add a node_e2e test that invokes this in a follow-on?

/lgtm
/approve

@derekwaynecarr I'm adding e2e tests for podresources in my PR which depends on this one (see 2bda2a7 and
cba703b) We already have basic coverage. If works for you I'll prepare a followup PR to make sure this case is covered explicitely (e.g. checking the NUMA ids)

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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants