Skip to content

map: avoid misleading error message for storage maps#1978

Open
venk8 wants to merge 1 commit intocilium:mainfrom
venk8:test-fix
Open

map: avoid misleading error message for storage maps#1978
venk8 wants to merge 1 commit intocilium:mainfrom
venk8:test-fix

Conversation

@venk8
Copy link
Copy Markdown

@venk8 venk8 commented Apr 3, 2026

Description

This PR improves error handling in handleMapCreateError when creating BPF maps with zero MaxEntries.

It fixes a misleading error message when creating maps that require MaxEntries to be zero (such as SkStorage, InodeStorage, TaskStorage, CgroupStorage, CGroupStorage, and PerCPUCGroupStorage).

Previously, if map creation failed with EINVAL (e.g., due to missing BTF metadata) while MaxEntries was correctly set to 0, the error handler would wrongly suggest that MaxEntries may be incorrectly set to zero.

Changes

  • Added requiresZeroMaxEntries() to MapType in types.go to identify map types that require zero max entries (supporting CgroupStorage, CGroupStorage, PerCPUCGroupStorage, InodeStorage, TaskStorage, and SkStorage).
    *Updated handleMapCreateError in map.go to exempt these map types from the MaxEntries == 0 check.
  • Added tests to verify if misleading errors don't appear and actual error appears.

@dylandreimerink
Copy link
Copy Markdown
Member

These changes seem sensible to me. It might also make sense to check the opposite, throwing an more explicit error when entries is 0 for maps that require them to be non-zero. I would squash the second commit into the first one.

Avoid misleading error message suggesting MaxEntries may be incorrectly set to zero for map types that require it to be zero.

Add tests to verify that maps that cannot have zero max entries fail with the expected error message when created with MaxEntries: 0.

Add CGroupStorage and PerCPUCGroupStorage to requiresZeroMaxEntries.

Signed-off-by: Venkat Krishnan <venkatkr@google.com>
@venk8
Copy link
Copy Markdown
Author

venk8 commented Apr 7, 2026

@dylandreimerink Thanks for review! I have addressed the comments. Please take a look!

@venk8 venk8 marked this pull request as ready for review April 7, 2026 17:46
@venk8 venk8 requested a review from a team as a code owner April 7, 2026 17:46
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.

2 participants