Closed yb01 closed 2 years ago
the parameter diff from netpod and vm pod. the only difference is the IFName. in vmpod, it is virtlet-eth0.
mizarcni.go:57] Network variables: {"Command":"ADD","ContainerID":"9fd465eb-8d8a-4fe2-bcea-c98f82db48fc","NetNS":"/var/run/netns/9fd465eb-8d8a-4fe2-bcea-c98f82db48fc","IfName":"virtlet-eth0","CniPath":"/opt/cni/bin","K8sPodNamespace":"default","K8sPodName":"vmdefault","K8sPodTenant":"system","CniVersion":"0.3.1","NetworkName":"mizarcni","Plugin":"mizarcni"}
mizarcni.go:57] Network variables: {"Command":"ADD","ContainerID":"d682b478b7dfdb479de6989e68e9b2bb5d5c38221d3e3590484f9957e98e5718","NetNS":"/var/run/netns/cni-9169dd3f-c78b-5abf-b35c-6a3926a5cf21","IfName":"eth0","CniPath":"/opt/cni/bin","K8sPodNamespace":"kube-system","K8sPodName":"netpod1-1","K8sPodTenant":"system","CniVersion":"0.3.1","NetworkName":"mizarcni","Plugin":"mizarcni"}
in this code, it should at least check err and/or link object before using link
// moves the interface to the CNI netnt, rename it, set the IP address, and the gatewey.
func ActivateInterface(
ifName string,
netNSName string,
vethName string,
ipPrefix string,
ipAddress string,
gatewayIp string) (string, error) {
link, err := netlink.LinkByName(vethName)
if err == nil {
if link.Attrs().OperState == netlink.OperUp {
return fmt.Sprintf("Interface %s has already been UP.", vethName), nil
}
}
What happened: try create vm pod with this pod def, which works fine with bridge cni.
What you expected to happen:
cni might raise error if there is some config it does not support or not as expected, it should not panic, i.e to handle it gracefully.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
cat /etc/os-release
):uname -a
):