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

ErrMapIncompatible should contain additional information #1034

Closed
ti-mo opened this issue May 5, 2023 · 6 comments
Closed

ErrMapIncompatible should contain additional information #1034

ti-mo opened this issue May 5, 2023 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ti-mo
Copy link
Collaborator

ti-mo commented May 5, 2023

In cilium/cilium#22693, Cilium will start relying exclusively on the library to tell it when a map is incompatible with an existing pinned map, but right now ErrMapIncompatible is a little vague. Callers need to open the old map explicitly, inspect its info, and work out the differences with the MapSpec.


Updated to echo #1093 (comment).

I think there are 2 issues with the existing code:

  • No clear communication (towards the user) of what 'expected' and 'got' means in (expected type %v, got %v). We should settle on language that clarifies which side is the existing Map and which is the incoming Spec.
  • Only one error is surfaced at a time, being the first-found one.

As a bonus, it would be nice if this would return a new ebpf.IncompatibleMapError{OldType, NewType ebpf.MapType, ...} that .Unwrap()s to ErrMapIncompatible so it can be used like:

var merr *ebpf.IncompatibleMapError
if errors.As(err, &merr) {
  if merr.OldType == ebpf.ArrayOfMaps && merr.NewType == ebpf.HashOfMaps {
    // Convert the old map from ArrayOfMaps to HashOfMaps here..
  }
}

This would be really useful to trigger up/downgrade logic.

Also, .Error() should only return a diff of the map's properties, not a dump of all old/new properties. That's just something I hacked up in Cilium to move ahead with the changes there.

@swastik959
Copy link

@ti-mo hi I am new to this org and want to contribute to this issue can you please guide me through it

@ti-mo
Copy link
Collaborator Author

ti-mo commented May 25, 2023

@swastik959 There's a short document at https://github.com/cilium/ebpf/blob/master/CONTRIBUTING.md. Do you have any specific questions?

@sharathsivakumar
Copy link

Hello @ti-mo, I would like to work on this if no one is actively working on this.

@ti-mo
Copy link
Collaborator Author

ti-mo commented Jun 12, 2023

@sharathsivakumar Sure thing! Assigned the issue to you.

@sharathsivakumar
Copy link

Thanks!

@lmb
Copy link
Collaborator

lmb commented Mar 13, 2024

Closing this for now, since it's actually quite tricky to implement. This should happen if / when we use the info from the cilium side.

@lmb lmb closed this as completed Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Status: Done
Development

No branches or pull requests

4 participants