-
Notifications
You must be signed in to change notification settings - Fork 115
Cni integration #62
Cni integration #62
Conversation
39081a9
to
f3f3c38
Compare
@@ -23,6 +23,7 @@ import ( | |||
"github.com/golang/glog" | |||
"github.com/golang/protobuf/proto" | |||
|
|||
"github.com/rajatchopra/ocicni" |
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.
Could you also moves this to a local packages? It will be moved into cri-o, refer here.
f3f3c38
to
2ec3032
Compare
bf9fecd
to
193bde2
Compare
// SetUpPod is the method called after the infra container of | ||
// the pod has been created but before the other containers of the | ||
// pod are launched. | ||
SetUpPod(netnsPath string, namespace string, name string, containerID 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.
what is namespace for? I don't think it is required.
@@ -60,7 +62,18 @@ func NewHyperRuntime(hyperEndpoint string, streamingConfig *streaming.Config) (* | |||
} | |||
} | |||
|
|||
return &Runtime{client: hyperClient, streamingServer: streamingServer}, streamingServer, nil | |||
netPlugin, err := ocicni.InitCNI("") |
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.
We should make pluginDir and cniDir configurable via frakti flags.
ifaces = append(ifaces, &types.UserInterface{ | ||
Ifname: fmt.Sprintf("eth%d", seq), | ||
Bridge: bridge, | ||
Ip: iface.Ip, |
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.
missing mac and gateway here.
969814f
to
d0df8d4
Compare
@YaoZengzeng Why includes commits from master? rebase error? |
d0df8d4
to
dfa82a5
Compare
Already fix rebase error @feiskyer |
Ifaces []*InterfaceInfo | ||
} | ||
|
||
type InterfaceInfo struct { |
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.
nit: use full name instead of short one
|
||
mac := link.Attrs().HardwareAddr.String() | ||
|
||
addrs, err := netlink.AddrList(link, netlink.FAMILY_V4) |
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.
nit: add a TODO comment for supporting v6 in the future
mac := link.Attrs().HardwareAddr.String() | ||
|
||
addrs, err := netlink.AddrList(link, netlink.FAMILY_V4) | ||
if err != nil { |
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.
Log error here for easy tracking problems
|
||
gw := "" | ||
routes, err := netlink.RouteList(link, netlink.FAMILY_V4) | ||
if err != nil { |
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.
same here, log error message
continue | ||
} | ||
for _, route := range routes { | ||
if route.Gw != nil { |
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.
Add a comments of losing routes here, we may add them back in the future
} | ||
|
||
func (plugin *cniNetworkPlugin) syncNetworkConfig() { | ||
network, err := getDefaultCNINetwork(plugin.netDir, plugin.pluginDirs, plugin.vendorCNIDirPrefix) |
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.
Could we support multiple networks?
if err != nil { | ||
glog.Errorf("Error while adding to cni lo network: %s", err) | ||
return err | ||
} |
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.
nit: add a info log of CNI response
if err != nil { | ||
glog.Errorf("Error while adding to cni network: %s", err) | ||
return err | ||
} |
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.
nit: add a info log of CNI response
glog.V(4).Infof("About to run with conf.Network.Type=%v", netconf.Network.Type) | ||
res, err := cninet.AddNetwork(netconf, rt) | ||
if err != nil { | ||
glog.Errorf("Error adding network: %v", err) |
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.
also add podID and netns in error logs (and also other places)
@@ -51,6 +79,28 @@ func (h *Runtime) RunPodSandbox(config *kubeapi.PodSandboxConfig) (string, error | |||
return podID, nil | |||
} | |||
|
|||
func addNetNsInfos2UserPod(userpod *types.UserPod, info *NetNsInfos) { |
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.
Only bridge plugin is supported in this PR, add a TODO of supporting other plugins
Signed-off-by: Yao Zengzeng <yaozengzeng@zju.edu.cn>
Signed-off-by: Yao Zengzeng <yaozengzeng@zju.edu.cn>
Signed-off-by: Yao Zengzeng <yaozengzeng@zju.edu.cn>
Signed-off-by: YaoZengzeng <zengzengyao@harmonycloud.cn>
dfa82a5
to
9abb7da
Compare
Signed-off-by: Yao Zengzeng <yaozengzeng@zju.edu.cn>
9abb7da
to
34d82e2
Compare
Ready for review again @feiskyer |
LGTM. Thanks. |
No description provided.