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

internal: add a way to write portable feature tests #1592

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Oct 18, 2024

Feature tests are used to enable new features in a backwards compatible manner. They exercise very specific code paths in the kernel. It makes sense to assume that the existing feature tests will not work as intended when porting to a new platform. Change the existing NewFeatureTest constructor to return a new sentinel error when invoked on non-Linux OS.

Add a new constructor NewPortableFeatureTest which allows indicating on which platforms and versions a feature test is reliable.

@lmb lmb requested a review from a team as a code owner October 18, 2024 09:24
Feature tests are used to enable new features in a backwards compatible
manner. They exercise very specific code paths in the kernel. It makes
sense to assume that the existing feature tests will not work as intended
when porting to a new platform. Change the existing NewFeatureTest
constructor to return a new sentinel error when invoked on non-Linux OS.

Add a new constructor NewPortableFeatureTest which allows indicating on
which platforms and versions a feature test is reliable.

Signed-off-by: Lorenz Bauer <[email protected]>
@lmb lmb merged commit d084e84 into cilium:main Oct 21, 2024
17 checks passed
@lmb lmb deleted the portable-feature-tests branch October 21, 2024 13:02
// The minimum version required for this feature.
//
// On Linux this refers to the mainline kernel version, on other platforms
// to the version of the runtime.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: careful to distinguish between 'bpf runtime' and 'Go runtime' when phrasing things like this.

// NewPortableFeatureTest creates a cross-platform [FeatureTest].
//
// versions are in the format "GOOS:Major.Minor[.Patch]"
func NewPortableFeatureTest(name string, fn FeatureTestFn, versions ...string) func() error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why this needs to have a separate constructor. Couldn't we take Linux:6.11 and 6.11 to mean the same thing for backwards compat? (or just rewrite all the ones we have) Making version variadic in NewFeatureTest isn't a huge problem as it only has a few dozen invocations. Refactoring should be fairly straightforward.

@lmb
Copy link
Collaborator Author

lmb commented Oct 24, 2024

For posterity: I think I accidentally deleted this code when correcting my mistake of force pushing to main.

@lmb
Copy link
Collaborator Author

lmb commented Oct 24, 2024

See #1592

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