Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Refactor network.go #811

Merged
merged 5 commits into from
Oct 15, 2018
Merged

Conversation

amshinde
Copy link
Member

@amshinde amshinde commented Oct 9, 2018

Split network.go into separate endpoint implementations.

@amshinde
Copy link
Member Author

amshinde commented Oct 9, 2018

/test

// Attach for virtual endpoint bridges the network pair and adds the
// tap interface of the network pair to the hypervisor.
func (endpoint *BridgedMacvlanEndpoint) Attach(h hypervisor) error {
networkLogger().Info("Attaching macvlan endpoint")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, this should be:

networkLogger().WithField("endpoint-type", "bridged-macvlan").Info("Attaching endpoint")

But as mentioned recently, it would be good if we could factor out all these log calls for Attach() and Detach() and maybe get the caller to call Type() on the endpoint and log that in a single location (maybe in add() and remove() in virtcontainers/default_network.go?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jodh-intel Missed that from our previous conversation! I have fixed this now, by getting rid of all those calls and logging at a single location.

@jodh-intel
Copy link
Contributor

Hi @amshinde - our friendly neighbourhood CI has found a minor issue:

INFO: Checking for SPDX license headers
ERROR: Required license identifier ('SPDX-License-Identifier: Apache-2.0') missing from following files:

virtcontainers/endpoint.go

@amshinde amshinde force-pushed the network_refactor branch 2 times, most recently from 676b792 to f68d964 Compare October 9, 2018 17:55
@amshinde
Copy link
Member Author

amshinde commented Oct 9, 2018

/retest

@amshinde amshinde requested a review from sboeuf October 9, 2018 17:56
@amshinde
Copy link
Member Author

amshinde commented Oct 9, 2018

@sboeuf PTAL

@codecov
Copy link

codecov bot commented Oct 9, 2018

Codecov Report

Merging #811 into master will increase coverage by 0.44%.
The diff coverage is 14.28%.

@@            Coverage Diff             @@
##           master     #811      +/-   ##
==========================================
+ Coverage   65.64%   66.09%   +0.44%     
==========================================
  Files          87       87              
  Lines       10802    10505     -297     
==========================================
- Hits         7091     6943     -148     
+ Misses       3004     2863     -141     
+ Partials      707      699       -8

@amshinde
Copy link
Member Author

amshinde commented Oct 9, 2018

/retest

@caoruidong
Copy link
Member

I think macvtap hotplug is supported now. So what is relationship between XconnectNetModel and type of endpoint? like this NetXConnectBridgedModel->VethEndpoint NetXConnectMacVtapModel->MacvtapEndpoint?

@jodh-intel
Copy link
Contributor

jodh-intel commented Oct 10, 2018

Thanks @amshinde.

lgtm

Approved with PullApprove

@@ -833,7 +833,7 @@ func (q *qemu) hotplugVFIODevice(device *config.VFIODev, op operation) error {
return nil
}

func (q *qemu) hotplugMacvtap(drive *VirtualEndpoint) error {
func (q *qemu) hotplugMacvtap(drive *VethEndpoint) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is for macvtap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caoruidong Yes, but the underlying interface is the Veth interface. Macvtap is used as the bridging mechanism. Answering your previous question, the difference is when you get a macvtap interface from the network plugin that you can directly pass to the VM vs an interface such as a veth that you get from the plugin wherein you use a macvtap or a bridge+tap for bridging the interface to the VM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so the new MacvtapEndpoint is without veth pair? Got it.

@caoruidong
Copy link
Member

Why not create a sub-directory under virtcontainers?

Split endpoint implementations into their own file.

Fixes kata-containers#799

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Split network_test.go into separate test files.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
As this really represents a veth pair rather than a generic
virtual interface, rename VirtualEndpoint to VethEndpoint.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Explicitly check for "veth" intergace type while creating a
veth endpoint. Error out for unsupported network interfaces.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Log Attach, Detach, HotAttach and HotDetach at a single
location.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
@amshinde
Copy link
Member Author

/retest

Copy link

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @amshinde ! I bet this was not fun but it helps clarifying the code base a lot :)

@amshinde
Copy link
Member Author

/retest

@jodh-intel
Copy link
Contributor

/me grinds his teeth at CI failures - 2 nodes missing VT-x and a network timeout. Re-spinnning...

/cc @chavafg, @mnaser.

Copy link
Member

@egernst egernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @amshinde

@bergwolf
Copy link
Member

bergwolf commented Oct 15, 2018

Thanks @amshinde ! It makes the code a lot more clear.
LGTM!

Approved with PullApprove

@devimc
Copy link

devimc commented Oct 15, 2018

lgtm

Approved with PullApprove

@amshinde amshinde merged commit d00742f into kata-containers:master Oct 15, 2018
@amshinde amshinde deleted the network_refactor branch July 11, 2019 22:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants