program/loader: properly log verifier errors #504
Merged
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.
Recent changes to cilium/ebpf have changed the way verifier logs are handled such that they are truncated to a single line by default and can be expanded with a
"%+v"
formatting directive. An unfortunate consequence of this was that our current implementation would always truncate verifier log dumps to a single line because the fmt.Errorf wrapper was implicitly using a"%s"
formatting directive to print the root cause.To rectify this issue, use the
errors.As()
helper to cast the verifier error down to an ebpf.VerifierError and use the entire verifier error in the call toslimVerifierError
. This enables us to pretty print the first and last 30 lines as before.While fixing this bug, I realized it would probably be a reasonable idea to support higher verbosity levels that would dump the entire verifier logs. While this wouldn't be useful in many cases, one could imagine specific use cases coming up where just the truncated dump may not be sufficient to debug an issue.
Finally, let's take advantage of the new default verifier log behaviour of cilium/ebpf to append a one line description of the problem to program load error messages. Example output without the --verbose flag looks like the following:
Signed-off-by: William Findlay [email protected]