Skip to content

Fix entitlements in internalClusterTest #131539

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
merged 25 commits into from
Jul 29, 2025

Conversation

mosche
Copy link
Contributor

@mosche mosche commented Jul 18, 2025

  • Previously, entitlement checks got disabled when resetting the policy manager (which defaults to inactive).
  • The shared data dir is granted as additional data base directory.
  • Due to the lack of entitlement delegation and wipePendingDataDirectories using server's FileSystemUtils, node base directories won't be removed until after the test.
  • Disable entitlement checks for some command tests.
  • Disable entitlement checks for some tests requiring entitlement delegation.

I'll follow up with better managing the lifecycle of test entitlement state, as discussed on Slack.

* Previously, entitlement checks got disabled when resetting the policy
  manager (which defaults to inactive).
* The shared data dir is granted as additional data base directory.
* Due to the lack of entitlement delegation and wipePendingDataDirectories using
  server's FileSystemUtils, node base directories won't be removed until
  after the test.
* Disable entitlement checks for some command tests.
* Disable entitlement checks for some tests requiring entitlement delegation.
@mosche mosche requested a review from a team July 18, 2025 15:12
@mosche mosche added >refactoring test-windows Trigger CI checks on Windows :Core/Infra/Entitlements Entitlements infrastructure test-fips Trigger CI checks for FIPS labels Jul 18, 2025
@elasticsearchmachine elasticsearchmachine added v9.2.0 Team:Core/Infra Meta label for core/infra team labels Jul 18, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@@ -115,20 +134,31 @@ private static Collection<Path> dataDirs(Settings settings, Path homeDir) {
: dataDirs.stream().map(TestEntitlementBootstrap::absolutePath).toList();
}

private static Path sharedDataDir(Settings settings) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is required for some tests, though it looks like we never grant PATH_SHARED_DATA_SETTING in production.
Is this a test-only thing? Or is that a bug?

@@ -93,6 +94,7 @@
import static org.hamcrest.Matchers.startsWith;

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
@ESTestCase.WithoutEntitlements // commands don't run with entitlements enforced
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit unfortunate how often we need to do this. Makes me wonder if there's a more general rule we could apply so that WithoutEntitlements only needs to be used in exceptional cases. 🤔

Copy link
Contributor

@prdoyle prdoyle left a comment

Choose a reason for hiding this comment

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

We're on the same page about what's needed. I'll proactively approve to avoid delays.

@mosche mosche added the auto-backport Automatically create backport pull requests when merged label Jul 25, 2025
@mosche mosche merged commit 5d72a3f into elastic:main Jul 29, 2025
45 checks passed
mosche added a commit to mosche/elasticsearch that referenced this pull request Jul 29, 2025
Previously, entitlement checks got disabled when resetting the policy manager (which defaults to inactive). This change makes sure entitlements are correctly enabled during tests.

Due to the lack of entitlement delegation (and usage of server's FileSystemUtils and similar in test code), there's a few remaining issues:
- various tests have to run without entitlements
- node base dirs cannot be removed immediately when shutting down the node due to pending cleanups (wipePendingDataDirectories)

Due to Netty dependency issues (ES-12435), azure and inference tests have to run without entitlements.
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

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

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

mosche added a commit to mosche/elasticsearch that referenced this pull request Jul 29, 2025
Previously, entitlement checks got disabled when resetting the policy manager (which defaults to inactive). This change makes sure entitlements are correctly enabled during tests.

Due to the lack of entitlement delegation (and usage of server's FileSystemUtils and similar in test code), there's a few remaining issues:
- various tests have to run without entitlements
- node base dirs cannot be removed immediately when shutting down the node due to pending cleanups (wipePendingDataDirectories)

Due to Netty dependency issues (ES-12435), azure and inference tests have to run without entitlements.

(cherry picked from commit 5d72a3f)

# Conflicts:
#	modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureBlobStoreRepositoryTests.java
@mosche
Copy link
Contributor Author

mosche commented Jul 29, 2025

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

elasticsearchmachine pushed a commit that referenced this pull request Jul 29, 2025
Previously, entitlement checks got disabled when resetting the policy manager (which defaults to inactive). This change makes sure entitlements are correctly enabled during tests.

Due to the lack of entitlement delegation (and usage of server's FileSystemUtils and similar in test code), there's a few remaining issues:
- various tests have to run without entitlements
- node base dirs cannot be removed immediately when shutting down the node due to pending cleanups (wipePendingDataDirectories)

Due to Netty dependency issues (ES-12435), azure and inference tests have to run without entitlements.
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 backport pending :Core/Infra/Entitlements Entitlements infrastructure >refactoring Team:Core/Infra Meta label for core/infra team test-fips Trigger CI checks for FIPS test-windows Trigger CI checks on Windows v8.19.1 v9.1.1 v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants