mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-13 13:05:42 +00:00
multus: fail if given pod UID does not match Kube API pod UID
If the runtime passes a pod UID via K8S_POD_UID (which both CRIO and containerd do as of mid-2021) then fail if the pod we get from the Kube API has a different UID. This would indicate that the pod was deleted and recreated while Multus was attempting to set up networking for the old pod instance's sandbox, and it's pointless to continue setting up a sandbox for a dead pod instance. Also pass the pod UID through to plugins so they can perform additional checking and validation on the pods they get from the Kube API. Signed-off-by: Dan Williams <dcbw@redhat.com>
This commit is contained in:
committed by
Tomofumi Hayashi
parent
392726842f
commit
cb19a22cb9
@@ -204,8 +204,6 @@ func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, r
|
||||
}
|
||||
|
||||
// In part, adapted from K8s pkg/kubelet/dockershim/network/cni/cni.go#buildCNIRuntimeConf
|
||||
// Todo
|
||||
// ingress, egress and bandwidth capability features as same as kubelet.
|
||||
rt := &libcni.RuntimeConf{
|
||||
ContainerID: args.ContainerID,
|
||||
NetNS: args.Netns,
|
||||
@@ -216,6 +214,7 @@ func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, r
|
||||
{"K8S_POD_NAMESPACE", string(k8sArgs.K8S_POD_NAMESPACE)},
|
||||
{"K8S_POD_NAME", string(k8sArgs.K8S_POD_NAME)},
|
||||
{"K8S_POD_INFRA_CONTAINER_ID", string(k8sArgs.K8S_POD_INFRA_CONTAINER_ID)},
|
||||
{"K8S_POD_UID", string(k8sArgs.K8S_POD_UID)},
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -157,6 +157,7 @@ type K8sArgs struct {
|
||||
K8S_POD_NAME types.UnmarshallableString //revive:disable-line
|
||||
K8S_POD_NAMESPACE types.UnmarshallableString //revive:disable-line
|
||||
K8S_POD_INFRA_CONTAINER_ID types.UnmarshallableString //revive:disable-line
|
||||
K8S_POD_UID types.UnmarshallableString //revive:disable-line
|
||||
}
|
||||
|
||||
// ResourceInfo is struct to hold Pod device allocation information
|
||||
|
Reference in New Issue
Block a user