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

question about pods with multiple containers #12

Open
monstercy opened this issue May 8, 2019 · 3 comments
Open

question about pods with multiple containers #12

monstercy opened this issue May 8, 2019 · 3 comments

Comments

@monstercy
Copy link

monstercy commented May 8, 2019

Hi @cheyang,

I am currently studing the code and have a question about pods that have multiple containers.
I trace the code in kubelet and find that it called the allocate function for each container.

for _, container := range pod.Spec.Containers {
		if err := m.allocateContainerResources(pod, &container, devicesToReuse); err != nil {
			return err
		}
		m.podDevices.removeContainerAllocatedResources(string(pod.UID), container.Name, devicesToReuse)
	}
		devs := allocDevices.UnsortedList()
		// TODO: refactor this part of code to just append a ContainerAllocationRequest
		// in a passed in AllocateRequest pointer, and issues a single Allocate call per pod.
		klog.V(3).Infof("Making allocation request for devices %v for device plugin %s", devs, resource)
		resp, err := eI.e.allocate(devs)
		metrics.DevicePluginAllocationDuration.WithLabelValues(resource).Observe(metrics.SinceInSeconds(startRPCTime))
		metrics.DeprecatedDevicePluginAllocationLatency.WithLabelValues(resource).Observe(metrics.SinceInMicroseconds(startRPCTime))

this case may corrupt the finding pod logic in device plugin allocate function . Have you meet this issue?

@YuxiJin-tobeyjin
Copy link

Thanks @cheyang 👍 for all the work you have done, really an excellent job.

I vote for this issue:
+1

For example, one pod have two containers, each needs 3Gi memory, kubelet will call allocate function for each container:

   	for _, container := range pod.Spec.Containers {
		if err := m.allocateContainerResources(pod, &container, devicesToReuse); err != nil {
			return err
		}
...
        resp, err := eI.e.allocate(devs)
...
	return e.client.Allocate(context.Background(), &pluginapi.AllocateRequest{
		ContainerRequests: []*pluginapi.ContainerAllocateRequest{
			{DevicesIDs: devs},
		},
	})

So such logic in device plugin makes no sense, cause reqs only contains one container

	// podReqGPU = uint(0)
	for _, req := range reqs.ContainerRequests {
		podReqGPU += uint(len(req.DevicesIDs))
	}

Thus the following equation may never be satisfied for this case

	if getGPUMemoryFromPodResource(pod) == podReqGPU {

@cheyang WDYT

@cheyang
Copy link
Collaborator

cheyang commented Jun 15, 2019

Thanks, @YuxiJin-tobeyjin @monstercy , I think you are right. It should be handled. I will take a look at this later. If you have solutions, your contributions are welcome.

@xhejtman
Copy link

Anything new here? It seems that the issue is still present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants