Skip to content

Conversation

@prdoyle
Copy link
Contributor

@prdoyle prdoyle commented Dec 18, 2024

The existing requestingModule logic skips a fixed number of frames, making highly sensitive to refactoring, and also making it impossible to call requestingModule from frames at two different depths.

The new logic inspects the frames to skip the runtime frames, and then the JDK frames, regardless of how many there are.

Supersedes #118796 with more to come.

@prdoyle prdoyle added >non-issue :Core/Infra/Core Core issues without another label auto-backport Automatically create backport pull requests when merged v9.0.0 labels Dec 18, 2024
@prdoyle prdoyle self-assigned this Dec 18, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Dec 18, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

This looks fine, though I find it a little confusing because of naming, and it seems a bit fragile to me. How do our existing entitlement IT tests work if this was incorrect? Can you at least add some comments to the requestingModule and findRequestingModule methods explaining the split and the expected outcome/behavior? Also, is there any anticipated performance hit by removing the constant skip?

Copy link
Contributor

@jdconrad jdconrad left a comment

Choose a reason for hiding this comment

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

I think this a good idea, but we should take it a bit further to be less lenient.

@prdoyle
Copy link
Contributor Author

prdoyle commented Dec 18, 2024

For the performance hit: it was already skipping frames in the JDK, and now the entitlement runtime frames have the same overhead as the JDK frames.

Copy link
Contributor

@jdconrad jdconrad left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for improving this.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

@prdoyle prdoyle enabled auto-merge (squash) December 18, 2024 18:56
@prdoyle prdoyle merged commit 9cc362b into elastic:main Dec 18, 2024
16 checks passed
prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request Dec 18, 2024
* More robust frame skipping

* Cosmetic improvements for clarity

* Explicit set of runtime classes

* Pass entitlements runtime module to PolicyManager ctor

* Use the term "entitlements module" and filter instead of dropWhile

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

@prdoyle prdoyle deleted the requesting-module branch December 18, 2024 19:27
elasticsearchmachine pushed a commit that referenced this pull request Dec 18, 2024
* More robust frame skipping

* Cosmetic improvements for clarity

* Explicit set of runtime classes

* Pass entitlements runtime module to PolicyManager ctor

* Use the term "entitlements module" and filter instead of dropWhile

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.18.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants