-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add macvtap device plugin #2
Conversation
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.
Let me try this locally before merging, but, right now can't nit-pick.
Actually, I'm missing CI to run :) That could possibly be done on a PR to be merged before this one; I can work on that later this week. |
You can still do cluster-up and a manual test with your code on top if you like but I actually think that it is better to get this PR and the CNI (with ut) in first and then we can both work on the e2e tests. |
Of course; I just mean triggering the unit tests you've added as a result of this PR. |
WIP CI PR: kubevirt/project-infra#308 |
cmd/Dockerfile
Outdated
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal | ||
COPY --from=builder /macvtap /macvtap | ||
ENTRYPOINT [ "./macvtap", "-v", "3", "-logtostderr"] |
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.
Please insert a new line at the end of the file.
pkg/util/netlink.go
Outdated
func CreateMacvtap(name string, master string, mode string) (int, error) { | ||
// attempt to delete any previously existing link | ||
if l, _ := netlink.LinkByName(name); l != nil { | ||
_ = netlink.LinkDel(l) |
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.
You can drop _ =
if you don't care about the returned value
pkg/util/netlink.go
Outdated
} | ||
|
||
func CreateMacvtap(name string, master string, mode string) (int, error) { | ||
// attempt to delete any previously existing link |
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.
To make it clear what is the int
you are returning representing, would you please initialize the variable here with a proper name and default value 0
?
pkg/util/netlink.go
Outdated
return CreateMacvtap(name, master, mode) | ||
} | ||
|
||
func LinkExists(link 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.
This should return bool. If it fails, it does not necessarily mean the link does not exist. Could you check the returned value? As you do in the following function.
} | ||
|
||
func (ml MacvtapLister) Discover(pluginListCh chan dpm.PluginNameList) { | ||
var plugins = make(dpm.PluginNameList, 0) |
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.
So to apply new config, all DaemonSets need to be restarted? Could you document it?
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.
Yes, ideally deleting the config map and creating a new one would take care of it. I was waiting for the cni to wire an encompassing readme to include this information.
pkg/deviceplugin/plugin.go
Outdated
|
||
const ( | ||
tapPath = "/dev/tap" | ||
suffix = "Mvp" |
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's that?
pkg/deviceplugin/plugin.go
Outdated
} | ||
|
||
func (mdp *MacvtapDevicePlugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error { | ||
masterDevs := mdp.generateMacvtapDevices() |
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.
These are not master devs though, these are slaves connected to the master.
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.
@jcaamano I understand what you're doing, it's easier to follow now. Despite that, the name 'masterDevs' is extremely misleading.
Do you think allocatedMacvtaps
& emptyMacvtapList
is an acceptable compromise ?
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.
I see. I tried to improve these variable names on the latest push.
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.
Thanks for listening; it's now OK for me.
} | ||
} | ||
|
||
didMasterExist := false |
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 please add an inline comment documenting what are you doing in the following block?
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.
Added.
return true | ||
} | ||
|
||
func (mdp *MacvtapDevicePlugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) 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.
Please add a comment describing which interfaces are offered here. I don't get why it requires so much code, you just need to create bunch of fake Devices, no?
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 only that but also keeping up with the master device. If there is no master, there is no point in offering devices for allocation as it will fail.
var devices []*pluginapi.DeviceSpec | ||
for _, name := range req.DevicesIDs { | ||
dev := new(pluginapi.DeviceSpec) | ||
index, err := util.RecreateMacvtap(name, mdp.Master, mdp.Mode) |
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.
Please add a comment explaining why do you need to recreate
@phoracek hopefully addressed your requests. Thanks! |
This commit adds the initial implementation of the macvtap device plugin. Includes manifests & templates for deployment, as well as some basic tests. Further changes are expected as the macvtap cni is integrated. RBAC and more thorough testing pending for a later patch. Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
LGTM |
This commit adds the initial implementation of the macvtap device
plugin. Includes manifests & templates for deployment, as well as
some basic tests.
Further changes are expected as the macvtap cni is integrated.
RBAC and more thorough testing pending for a later patch.
What this PR does / why we need it:
Special notes for your reviewer: