Skip to content

Extract hardcoded entitlements creation to a separate class #127698

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

Merged

Conversation

ldematte
Copy link
Contributor

@ldematte ldematte commented May 5, 2025

Moving creation of hardcoded entitlements (server policy + APM agent) to a separate class

@ldematte ldematte added >refactoring auto-backport Automatically create backport pull requests when merged v8.19.0 v9.1.0 :Core/Infra/Entitlements Entitlements infrastructure v8.18.2 v9.0.2 labels May 5, 2025
@ldematte ldematte requested a review from a team as a code owner May 5, 2025 07:22
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label May 5, 2025
@elasticsearchmachine
Copy link
Collaborator

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


class HardcodedEntitlements {

private static List<Scope> createServerEntitlements(Path pidFile) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to support multiple pid files for multiple nodes, I think. Perhaps pid file should be another BaseDir enum value. That would have a nice simplifying effect on the code below, actually, because serverModuleFileDatas would no longer need to be a mutable list.

Q: Why do we need read/write permission on the pid file? It's created in phase 2 before entitlements are initialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ for the Q: do we need this, especially for tests? I am assuming this will always be null for unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For context, we discussed both

Why do we need read/write permission on the pid file? It's created in phase 2 before entitlements are initialized.\

Ideally, we probably want to handle both creation and deletion of the PID file to happen in the CLI; that is additional work that we might want to do, but it will be separate

do we need this, especially for tests? I am assuming this will always be null for unit tests.

(where "this" is "support multiple pid files for multiple nodes") the answer is no; in unit and integ tests we still have one runner/one JVM, and we don't need the PID file permission anyway as there is no PID file; still, we can handle it more elegantly that this (testing for null) and simplify things as @prdoyle pointed out; I think it would be a great follow up, but for now I'm merging this as-is as it serves the purpose, and we can make it better in another PR.

@ldematte ldematte enabled auto-merge (squash) May 5, 2025 16:35
@ldematte ldematte merged commit 79ee234 into elastic:main May 5, 2025
17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts
8.18 Commit could not be cherrypicked due to conflicts
9.0 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 127698

ldematte added a commit to ldematte/elasticsearch that referenced this pull request May 6, 2025
…127698)

Moving creation of hardcoded entitlements (server policy + APM agent) to a separate class
@ldematte ldematte deleted the entitlements/extract-hardcoded-entitlements branch May 6, 2025 14:24
elasticsearchmachine pushed a commit that referenced this pull request May 6, 2025
* Extract hardcoded entitlements creation to a separate class (#127698)

Moving creation of hardcoded entitlements (server policy + APM agent) to a separate class

* Move FilesEntitlements validation to a separate class (#127703)

Moves FilesEntitlements validation to a separate class. This is the final PR to make EntitlementsInitialization a simpler "orchestrator" of the various steps in the initialization phase.
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/Entitlements Entitlements infrastructure >refactoring Team:Core/Infra Meta label for core/infra team v8.18.2 v8.19.0 v9.0.2 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants