-
Notifications
You must be signed in to change notification settings - Fork 448
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
[fix]: delete the NIC regardless of whether the Pod was found or not. #4500
Conversation
Signed-off-by: liyh <liyh@yusur.tech>
Signed-off-by: liyh <liyh@yusur.tech>
pkg/daemon/handler.go
Outdated
vmName := pod.Annotations[fmt.Sprintf(util.VMAnnotationTemplate, podRequest.Provider)] | ||
if vmName != "" { | ||
podRequest.PodName = vmName | ||
nicType = "veth-pair" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉像上面那样用个常量,用 nicType = util.VethType 会更好些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经改成了常量
Signed-off-by: liyh <liyh@yusur.tgech>
@@ -229,7 +229,7 @@ func (csh cniServerHandler) removeDefaultRoute(netns string, ipv4, ipv6 bool) er | |||
return nil | |||
} | |||
|
|||
func (csh cniServerHandler) deleteNic(podName, podNamespace, containerID, netns, deviceID, ifName, nicType, _ string) error { | |||
func (csh cniServerHandler) deleteNic(podName, podNamespace, containerID, netns, deviceID, ifName, nicType string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个参数在 windows 系统没有用到不需要修改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此处已恢复到更改前代码
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"not enough arguments in call to csh.deleteNic", 前面的函数调用需要,这里得去掉最后一个参数了
Signed-off-by: liyh <liyh@yusur.tgech>
Signed-off-by: liyh <liyh@yusur.tgech>
…#4500) * [fix]: delete the NIC regardless of whether the Pod was found or not. Signed-off-by: liyh <liyh@yusur.tech> * windows Remove Parameter Signed-off-by: liyh <liyh@yusur.tech> * -Using constants Signed-off-by: liyh <liyh@yusur.tgech> * Restore changes to Windows Signed-off-by: liyh <liyh@yusur.tgech> * Fix: Correct argument count for csh.deleteNic call Signed-off-by: liyh <liyh@yusur.tgech> --------- Signed-off-by: liyh <liyh@yusur.tech> Signed-off-by: liyh <liyh@yusur.tgech> Co-authored-by: liyh <liyh@yusur.tgech>
Pull Request
What type of this PR
Examples of user facing changes:
Describe
当删除pod时,若pod被直接删除cni来不及处理时,通过
pod, err := csh.Controller.podsLister.Pods(podRequest.PodNamespace).Get(podRequest.PodName)
获取pod进行后续的处理条件,会导致此时无法处理,直接在k8serrors.IsNotFound
中返回。复现
例如 在pod的部署yaml中设置了terminationGracePeriodSeconds: 0,导致 Pod 在删除 Deployment 后被立即终止,而 CNI 插件的 handleDel 函数还没来得及处理删除网卡的操作。
使用 podRequest.ContainerID 来识别 Pod,而不是使用 podRequest.PodName。这样即使 Pod 已经被删除,CNI 插件仍然可以通过容器 ID 来删除网卡。