Skip to content
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

Remove PF from pools with Pfnames and rootDevices #410

Merged

Conversation

SchSeba
Copy link
Collaborator

@SchSeba SchSeba commented Feb 22, 2022

This commit remove the PF from pools if a Pfnames or rootDevices
selector are implemented

Signed-off-by: Sebastian Sch sebassch@gmail.com

@@ -486,26 +478,6 @@ var _ = Describe("In the utils package", func() {
},
"0000:01:10.0", "fakeSwitchdevPF", false,
),
Entry("device is a PF in switchdev mode",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I remove all the PF verification

@SchSeba
Copy link
Collaborator Author

SchSeba commented Feb 23, 2022

reading the documentation we have carefully when using PfName and rootDevice we should only include the Vfs

"pfNames" N VFs from PF matches list of PF names string list Default: null "pfNames": ["enp2s2f0"] (See follow-up sections for some advance usage of "pfNames")
"rootDevices" N VFs from PF matches list of PF PCI addresses string list Default: null "rootDevices": ["0000:86:00.0"] (See follow-up sections for some advance usage of "rootDevices")

@SchSeba
Copy link
Collaborator Author

SchSeba commented Feb 23, 2022

I am not sure why the CI is not able to pull the go packages..

I test it locally and it pass

make test       
running gofmt...
Running golint...
running tests...
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/cmd/sriovdp	(cached)
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/accelerator	(cached)
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/factory	(cached)
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/netdevice	(cached)
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/resources	(cached)
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils	(cached)

@SchSeba
Copy link
Collaborator Author

SchSeba commented Feb 23, 2022

I also clean my cache and run it again

make test
running gofmt...
building golint...
go: downloading golang.org/x/text v0.3.7
go: downloading golang.org/x/sys v0.0.0-20211019181941-9d821ace8654
go: downloading golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
go get: installing executables with 'go get' in module mode is deprecated.
	To adjust and download dependencies of the current module, use 'go get -d'.
	To install using requirements of the current module, use 'go install'.
	To install ignoring the current module, use 'go install' with a version,
	like 'go install example.com/cmd@latest'.
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
go get: upgraded golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 => v0.0.0-20210508222113-6edffad5e616
go get: upgraded golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d => v0.0.0-20211015210444-4f30a5c0130f
go get: upgraded golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e => v0.0.0-20211019181941-9d821ace8654
go get: upgraded golang.org/x/tools v0.0.0-20210106214847-113979e3529a => v0.1.9
Running golint...
running tests...
go: downloading github.com/onsi/ginkgo v1.12.0
go: downloading github.com/onsi/gomega v1.9.0
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: downloading github.com/hpcloud/tail v1.0.0
go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: downloading gopkg.in/fsnotify.v1 v1.4.7
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/cmd/sriovdp	0.663s
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/accelerator	0.099s
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/factory	0.120s
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/netdevice	0.173s
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/resources	5.251s
ok  	github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils	0.959s

pkg/utils/utils.go Show resolved Hide resolved
pkg/utils/utils.go Show resolved Hide resolved
Signed-off-by: Sebastian Sch <sebassch@gmail.com>
@SchSeba SchSeba force-pushed the remove_pf_name_for_pf branch from 901fd44 to 18142d5 Compare February 24, 2022 09:46
@zshi-redhat
Copy link
Collaborator

/lgtm

@adrianchiris
Copy link
Contributor

please do not merge until i have a chance to review.

}
return "", fmt.Errorf("error getting PF for PCI device %s %v", pciAddr, err)
}
return filepath.Base(pciinfo), nil
}

// GetPfName returns SRIOV PF name for the given VF
// If device is not VF then it will return its own ifname if exist else empty string
// If device is not VF then it will return empty string
func GetPfName(pciAddr string) (string, error) {
pfEswitchMode, err := GetPfEswitchMode(pciAddr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should check if pciAddr is not a VF and exit early WDYT ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done can you have another look?

Copy link
Contributor

Choose a reason for hiding this comment

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

better to use !IsSriovVF() as you might get a PF which is capable of SR-IOV with no VFs.

in this case, if the PF is in switchdev you might hit L#81 below and return the PF netdev instead of ""

same might happen in getPfAddr() but its being prevented by lines 52-53 above (before your changes)

Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

one comment, otherwise LGTM

@SchSeba SchSeba force-pushed the remove_pf_name_for_pf branch from 18142d5 to 8035fd9 Compare February 28, 2022 09:25
}
return "", fmt.Errorf("error getting PF for PCI device %s %v", pciAddr, err)
}
return filepath.Base(pciinfo), nil
}

// GetPfName returns SRIOV PF name for the given VF
// If device is not VF then it will return its own ifname if exist else empty string
// If device is not VF then it will return empty string
func GetPfName(pciAddr string) (string, error) {
pfEswitchMode, err := GetPfEswitchMode(pciAddr)
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use !IsSriovVF() as you might get a PF which is capable of SR-IOV with no VFs.

in this case, if the PF is in switchdev you might hit L#81 below and return the PF netdev instead of ""

same might happen in getPfAddr() but its being prevented by lines 52-53 above (before your changes)

func GetPfAddr(pciAddr string) (string, error) {
if IsSriovPF(pciAddr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think its needed, lines 56-60 below ensure its a VF.

also you might still get PF (sriov capable) with no sriov configured.
so to exit early you can !IsSriovVF()

imo you can either

  1. remove this check
  2. replace the check with !IsSriovVF() and remove the check in L#59

This commit remove the PF from pools if a Pfnames or rootDevices
selector are implemented

Signed-off-by: Sebastian Sch <sebassch@gmail.com>
@SchSeba SchSeba force-pushed the remove_pf_name_for_pf branch from 8035fd9 to 6d8ad3e Compare March 1, 2022 11:59
@SchSeba
Copy link
Collaborator Author

SchSeba commented Mar 1, 2022

thanks for the comments @adrianchiris

can you please give it another look?

Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @SchSeba !

@zshi-redhat
Copy link
Collaborator

/cc @bn222

@bn222
Copy link
Contributor

bn222 commented Mar 1, 2022

/lgtm

@zshi-redhat zshi-redhat merged commit a51564f into k8snetworkplumbingwg:master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants