-
Notifications
You must be signed in to change notification settings - Fork 180
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
Devlink Error message #413
Merged
Eoghan1232
merged 5 commits into
k8snetworkplumbingwg:master
from
Eoghan1232:DevlinkErrorMsg
Mar 2, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we are intentionally matching on the internal error returned by netlink.
+@almaslennikov
@Eoghan1232 are you hitting an issue with intel NICs not returning "no such device" error when trying to get devlink device attributes ?
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.
@adrianchiris "no such device" maybe gets returned in real environment but in a test environment with mock sysfs you won't necessarily get this exact error.
For example, in some external code that uses this function and have unit test with mock sysfs they might get "no such file or directory" instead. In that case, it breaks the non-devlink detection logic here.
Since
GetPfEswitchMode()
returns error string fromGetDevLinkDeviceEswitchAttrs()
it's safe to rely on that error message only if the underlying netlink fails to find such device in a system - real or mock.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.
if there is a mock sysfs ,cant you also mock
GetDevLinkDeviceEswitchAttrs
?we do not want to fallback to the regular flow if netlink failed for reason other than
since in this case, if device is in switchdev mode but failed for a reason other than the above, we would want to fail else we risk returning the wrong PF name.
I can think of two things:
do you have in house e2e tests that just use mock sysfs ? there are other calls to netlink in general are you not calling them ? (i.e GetLinkAttr)
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 is where the problem is. It does not come to the 2nd option at all because the first option return the error as with
GetPfEswitchMode(pciAddr)
returned ("", err). So it evaluates error string comparison and it evaluates to false and returnGetPfName()
to caller with error. Never get a chance to check sriov enable part. Please review the flow again.The
NetlinkProvider
interface is internal to this package only. External client of this package cannot and should not have to mock any internal interfaces of this package. Theutils.GetPfName()
function should be testable with a minimal mock sysfs as it used to be.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.
Do you mean the call to
GetPfAddr()
fails inGetPfEswitchMode()
and returns error toGetPfName()
?if
GetPfAddr()
fails, it means it failed to read symlink/sys/bus/pci/devices/<pci addr>/physfn
so in this case we would fail in
GetPfName()
even if we fallback to the previous flow since we try to read from the same base path. (unless in the mocked environment/sys/bus/pci/devices/<pci addr>/physfn
is not a symlink)or do you mean, GetPfAddr() call in
GetPfEswitchMode()
returns the PF addr of the VF (or its own address in case of PF) however the devlink call which follows this fails as the isnt actually a device ?can you walk me through the flow to help me understand ? what does
GetPfName
gets for input ? what is the mocked sysfs ?actually its public and you can get and set the implementation, defaulting to
defaultNetlinkProvider
which implements the NetlinkProvider interface, you can set a mock for it.I do not agree with this statement, i dont want to impose such constraints on implementation.
there are other places where we want to use devlink/netlink or other external libraries.
#399
#387
#306
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.
@Eoghan1232 could you rebase the PR ? there are some changes introduced with #410
i think we can simplify the whole flow flow here:
which should work with a mocked sysfs test env
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.
PR rebased.