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

Improves the error logs during the bpf maps updating #16034

Merged
merged 1 commit into from Jul 19, 2021

Conversation

elfadel
Copy link
Contributor

@elfadel elfadel commented May 6, 2021

Fixes: #15864

@elfadel elfadel requested a review from a team May 6, 2021 12:22
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 6, 2021
@elfadel elfadel requested a review from kkourt May 6, 2021 12:22
Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

I appreciate the effort to improve the errors in Cilium, as some of them a can be quite confusing. However, I noticed several issues with this PR as-is:

  • Please use a spellchecker.
  • Syscall library is deprecated
  • ENOENT message looks incorrect
  • E2BIG is assuming LB map but this is a generic function, it doesn't make sense to add such specific instructions in this generic code.
  • EINVAL, EPERM, ENOMEM adds no new information vs. the canonical string for that error
  • The default looks like it will hide the real error, which is worse than having a confusing error.

The current code also embeds the underlying error as a string, but it should wrap the error instead in all new code (%w).

@elfadel
Copy link
Contributor Author

elfadel commented May 7, 2021

@joestringer thank you for your review.

  • Please use a spellchecker.

Oki.

  • Syscall library is deprecated

Which library should we use therefore?

  • ENOENT message looks incorrect

I don't think so. Here I make the assumption that the user is trying to update an element that doesn't exist in the map. No?

  • E2BIG is assuming LB map but this is a generic function, it doesn't make sense to add such specific instructions in this generic code.

I am aware of that. That is why I added a condition to the specific instruction. Unless we have a way to retrieve the map name from it ID. Do we?

  • EINVAL, EPERM, ENOMEM adds no new information vs. the canonical string for that error

I will keep the canonical message in these cases.

  • The default looks like it will hide the real error, which is worse than having a confusing error.

Here too, I will keep the canonical message.

@joestringer
Copy link
Member

ENOENT message looks incorrect

I don't think so. Here I make the assumption that the user is trying to update an element that doesn't exist in the map. No?

The code says:

case syscall.ENOENT:
			errMsg = "Cannot add/update element to bpf map, the element already exist"

"the element already exist" is not the same as "the element doesn't exist".

Incidentally also, this error can only happen if the caller passes flags=BPF_EXIST which is never the case - all callers in the codebase pass BPF_ANY (see linux/bpf.h from the kernel tree for more details).

E2BIG is assuming LB map but this is a generic function, it doesn't make sense to add such specific instructions in this generic code.

I am aware of that. That is why I added a condition to the specific instruction. Unless we have a way to retrieve the map name from it ID. Do we?

Maybe not today. Depending on how comprehensively you want to solve this problem for various map types, you could either add code higher up the stack where the code is specific to LB map (eg by unwrapping the error and checking whether it matches E2BIG), or try to build out such a mapping layer (though I don't have a good idea about how that would look right now, you'd probably have to experiment a bit).

@elfadel elfadel force-pushed the map_error_msg branch 4 times, most recently from 5914a61 to ae42fb2 Compare May 12, 2021 11:29
@elfadel elfadel requested a review from a team as a code owner May 12, 2021 11:29
@elfadel
Copy link
Contributor Author

elfadel commented May 12, 2021

@joestringer

I finally chose to pass the map's name as an argument to updateElement() function. And performing a lookup of "lb" substring in the map's name.

Potential limit: I make the assumption that the LB bpf map ALWAYS contains "lb" substring in its name.

Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

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

Thanks for the patch! Please find some comments below.

pkg/bpf/bpf_linux.go Outdated Show resolved Hide resolved
pkg/bpf/bpf_linux.go Outdated Show resolved Hide resolved
pkg/bpf/bpf_linux.go Outdated Show resolved Hide resolved
pkg/bpf/bpf_linux.go Outdated Show resolved Hide resolved
@elfadel elfadel force-pushed the map_error_msg branch 2 times, most recently from fd282a8 to c7cc270 Compare May 20, 2021 15:38
@elfadel
Copy link
Contributor Author

elfadel commented May 20, 2021

@kkourt thanks for your review. The PR is updated with your suggestion.

pkg/bpf/bpf_linux.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM, assuming all the other concerns are resolved.

@twpayne twpayne added the release-note/misc This PR makes changes that have no direct user impact. label May 25, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 25, 2021
@twpayne twpayne added the kind/enhancement This would improve or streamline existing functionality. label May 25, 2021
@aanm aanm requested a review from brb May 28, 2021 01:04
pkg/bpf/bpf_linux.go Outdated Show resolved Hide resolved
pkg/maps/lbmap/lbmap.go Outdated Show resolved Hide resolved
@joestringer joestringer requested a review from brb July 1, 2021 22:11
Copy link
Member

@brb brb left a comment

Choose a reason for hiding this comment

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

Thanks!

@aanm
Copy link
Member

aanm commented Jul 2, 2021

test-me-please

@aanm
Copy link
Member

aanm commented Jul 2, 2021

@elfadel it seems like the unit tests are failing:

 	 # github.com/cilium/cilium/pkg/maps/ctmap [github.com/cilium/cilium/pkg/maps/ctmap.test]
	 pkg/maps/ctmap/ctmap_privileged_test.go:87:27: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:150:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:172:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:193:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:286:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:308:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:329:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:357:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 pkg/maps/ctmap/ctmap_privileged_test.go:412:25: not enough arguments in call to bpf.UpdateElement
	 	have (int, unsafe.Pointer, unsafe.Pointer, number)
	 	want (int, string, unsafe.Pointer, unsafe.Pointer, uint64)
	 make: *** [tests-privileged] Error 1

@elfadel
Copy link
Contributor Author

elfadel commented Jul 3, 2021

@aanm oki. I will fix it as soon as possible and make a new commit

@elfadel elfadel force-pushed the map_error_msg branch 2 times, most recently from 972909c to f74b8f0 Compare July 5, 2021 22:23
@aanm
Copy link
Member

aanm commented Jul 6, 2021

test-me-please

@joestringer
Copy link
Member

joestringer commented Jul 7, 2021

@elfadel could you please rebase against the latest master? The base commit for this branch is quite old, and this may hint at why the CI is so unhappy with the PR right now.

@elfadel
Copy link
Contributor Author

elfadel commented Jul 7, 2021

@joestringer Oki.

@joestringer
Copy link
Member

Sorry, there was another change merged into the tree (#16631) that requires all PRs to be rebased once more, otherwise some of the CI jobs will fail. One more time? Then we can run the tests again.

@elfadel
Copy link
Contributor Author

elfadel commented Jul 8, 2021

Done !

@joestringer
Copy link
Member

test-me-please

@joestringer
Copy link
Member

@elfadel When I click through to the commit of your PR (https://github.com/cilium/cilium/commits/e335addcc806d01362fcebe951f6217cd03cf64d), it shows as being based still on old code. Can you try pulling in the latest cilium/cilium repo code again and rebasing on top of master?

@elfadel
Copy link
Contributor Author

elfadel commented Jul 10, 2021

Oki @joestringer, I will proceed like that and make a new commit as soon as possible

Fixes: cilium#15864
Signed-off-by: El-Fadel Bonfoh <elfadel@accuknox.com>
@joestringer
Copy link
Member

test-me-please

@aanm
Copy link
Member

aanm commented Jul 19, 2021

Marking for backport since this will help users debug issues more easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement This would improve or streamline existing functionality. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace argument list too long with a more helpful message
6 participants