Skip to content

Conversation

@mark-vieira
Copy link
Contributor

@mark-vieira mark-vieira commented May 29, 2025

This refactors our reserved state infrastructure related to project-level reserved state handlers. The initial implementation of project state handlers worked on ProjectMetadata on the assumption that all per-project state will live there, however, this is not always the case. We may want to keep some per-project data directly on ClusterState, specifically per-project configuration that may be sourced from file-based configuration that we don't want to persist in ProjectMetadata. This change includes the following:

  1. ReservedClusterStateHandler has been reverted to remove the additional S generic type parameter. This type was technically unbounded but in practice could only be one of ClusterState or ProjectMetadata. To simplify things this has been removed and all state handlers (cluster or project level) transform a ClusterState.
  2. A new ReservedProjectStateHandler has been introduced whose transform() method accepts a ProjectId in addition to the state object.
  3. Existing ReservedClusterStateHandler implementations that work at the project level have been converted to ReservedProjectStateHandler thus removing a number of usages of the deprecated Metadata.getProject() method.

@mark-vieira mark-vieira requested a review from a team as a code owner May 29, 2025 19:40
@mark-vieira mark-vieira added the :Core/Infra/Core Core issues without another label label May 29, 2025
@elasticsearchmachine elasticsearchmachine added serverless-linked Added by automation, don't add manually v9.1.0 Team:Core/Infra Meta label for core/infra team labels May 29, 2025
@elasticsearchmachine
Copy link
Collaborator

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

* is {@link LocalStateAutoscaling}, therefore we need to provide a test version of this class.
*/
public class LocalStateReservedAutoscalingStateHandlerProvider implements ReservedClusterStateHandlerProvider {
public class LocalStateReservedAutoscalingStateHandlerProvider implements ReservedStateHandlerProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this class used?

Copy link
Contributor Author

@mark-vieira mark-vieira May 30, 2025

Choose a reason for hiding this comment

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

Implementations of ReservedStateHandlerProvider are loaded via SPI so there's no direct references to the class other than where the provider is registered in META-INF/services or module-info.java.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, this particular handler seems to be used only for mocking autoscaling events in tests.

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.

I just skimmed the interface changes, they look good. The rest seems to just be fallout from the name/type changes.

@mark-vieira mark-vieira merged commit 8fce15d into elastic:main Jun 3, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Core Core issues without another label >refactoring serverless-linked Added by automation, don't add manually Team:Core/Infra Meta label for core/infra team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants