Skip to content

[问题] Device Plugin allocate 选出的 pod 是否会跟 Kubelet 绑定的不一致 #16

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

Open
orainxiong opened this issue Sep 24, 2019 · 4 comments

Comments

@orainxiong
Copy link

看 Kubelet 调用 allocate 的实现

		resp, err := eI.e.allocate(devs)
                 ....
		m.podDevices.insert(podUID, contName, resource, allocDevices, resp.ContainerResponses[0])

deviceplug.allocate

  • 会列出该节点中所有状态为 Pending 并且ALIYUN_COM_GPU_MEM_ASSIGNED为false的 GPU Share Pod
  • 选择出其中 Pod Annotation 的ALIYUN_COM_GPU_MEM_POD的数量与 Allocate 申请数量一致的 Pod。如果有多个符合这种条件的 Pod,就会选择其中ALIYUN_COM_GPU_MEM_ASSUME_TIME最早的 Pod。
  • 将该 Pod 的 annotation ALIYUN_COM_GPU_MEM_ASSIGNED设置为true,并且将 Pod annotation 中的 GPU 信息转化为环境变量返回给 Kubelet 用以真正的创建 Pod。

但是在 Kubelet 调用deviceplug.allocate时已经确定了podUID. 两者是否会不同?

@cheyang
Copy link
Collaborator

cheyang commented Oct 8, 2019

这里依赖是Pod在调度器是按顺序bind的,而且在bind过程中已经加了锁。是能够保证顺序性的。

@payall4u
Copy link

这里依赖是Pod在调度器是按顺序bind的,而且在bind过程中已经加了锁。是能够保证顺序性的。

@cheyang
bind是有顺序的,但kubelet不一定会按照bind的顺序创建pod。

@xiaoxubeii
Copy link

看 Kubelet 调用 allocate 的实现

		resp, err := eI.e.allocate(devs)
                 ....
		m.podDevices.insert(podUID, contName, resource, allocDevices, resp.ContainerResponses[0])

deviceplug.allocate

  • 会列出该节点中所有状态为 Pending 并且ALIYUN_COM_GPU_MEM_ASSIGNED为false的 GPU Share Pod
  • 选择出其中 Pod Annotation 的ALIYUN_COM_GPU_MEM_POD的数量与 Allocate 申请数量一致的 Pod。如果有多个符合这种条件的 Pod,就会选择其中ALIYUN_COM_GPU_MEM_ASSUME_TIME最早的 Pod。
  • 将该 Pod 的 annotation ALIYUN_COM_GPU_MEM_ASSIGNED设置为true,并且将 Pod annotation 中的 GPU 信息转化为环境变量返回给 Kubelet 用以真正的创建 Pod。

但是在 Kubelet 调用deviceplug.allocate时已经确定了podUID. 两者是否会不同?

是的,这里实现可能会造成不一致。kubelet device plugin allocate 是按照 container 调用,但在 gpushare-device-plugin 是按照自有逻辑找到 candidate pod,不一定是 kubelet 调用的那个 pod。并且如果单 pod 下有多个 container 申请了 gpu 资源,这里肯定匹配不到。

for _, req := range reqs.ContainerRequests {
podReqGPU += uint(len(req.DevicesIDs))
}
log.Infof("RequestPodGPUs: %d", podReqGPU)
m.Lock()
defer m.Unlock()
log.Infoln("checking...")
pods, err := getCandidatePods(m.queryKubelet, m.kubeletClient)
if err != nil {
log.Infof("invalid allocation requst: Failed to find candidate pods due to %v", err)
return buildErrResponse(reqs, podReqGPU), nil
}
if log.V(4) {
for _, pod := range pods {
log.Infof("Pod %s in ns %s request GPU Memory %d with timestamp %v",
pod.Name,
pod.Namespace,
getGPUMemoryFromPodResource(pod),
getAssumeTimeFromPodAnnotation(pod))
}
}
for _, pod := range pods {
if getGPUMemoryFromPodResource(pod) == podReqGPU {
log.Infof("Found Assumed GPU shared Pod %s in ns %s with GPU Memory %d",
pod.Name,
pod.Namespace,
podReqGPU)
assumePod = pod
found = true
break
}
}

@gaoyangcaiji
Copy link

请问大佬有啥好的解决办法吗?这个不一致的问题

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

5 participants