Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1494,12 +1494,6 @@ public Builder templates(Map<String, IndexTemplateMetadata> templates) {
return this;
}

@Deprecated(forRemoval = true)
public Builder put(String name, ComponentTemplate componentTemplate) {
getSingleProject().put(name, componentTemplate);
return this;
}

@Deprecated(forRemoval = true)
public Builder componentTemplates(Map<String, ComponentTemplate> componentTemplates) {
getSingleProject().componentTemplates(componentTemplates);
Expand Down Expand Up @@ -1540,12 +1534,6 @@ public boolean put(String aliasName, String dataStream, Boolean isWriteDataStrea
return getSingleProject().put(aliasName, dataStream, isWriteDataStream, filter);
}

@Deprecated(forRemoval = true)
public Builder removeDataStream(String name) {
getSingleProject().removeDataStream(name);
return this;
}

public Builder putCustom(String type, ClusterCustom custom) {
customs.put(type, Objects.requireNonNull(custom, type));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ProjectState;
import org.elasticsearch.cluster.metadata.ComponentTemplate;
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
import org.elasticsearch.cluster.metadata.IndexMetadata;
Expand All @@ -19,7 +20,6 @@
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.metadata.ProjectMetadata;
import org.elasticsearch.cluster.metadata.Template;
import org.elasticsearch.cluster.project.ProjectResolver;
import org.elasticsearch.cluster.routing.allocation.DataTier;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -178,16 +178,15 @@ private MetadataMigrateToDataTiersRoutingService() {}
* ILM routing allocations. It also returns a summary of the affected abstractions encapsulated in {@link MigratedEntities}
*/
public static Tuple<ClusterState, MigratedEntities> migrateToDataTiersRouting(
ClusterState currentState,
ProjectResolver projectResolver,
ProjectState currentState,
@Nullable String nodeAttrName,
@Nullable String indexTemplateToDelete,
NamedXContentRegistry xContentRegistry,
Client client,
XPackLicenseState licenseState,
boolean dryRun
) {
ProjectMetadata currentProjectMetadata = projectResolver.getProjectMetadata(currentState);
ProjectMetadata currentProjectMetadata = currentState.metadata();
if (dryRun == false) {
IndexLifecycleMetadata currentMetadata = currentProjectMetadata.custom(IndexLifecycleMetadata.TYPE);
if (currentMetadata != null && currentILMMode(currentProjectMetadata) != STOPPED) {
Expand All @@ -197,7 +196,7 @@ public static Tuple<ClusterState, MigratedEntities> migrateToDataTiersRouting(
}
}

Metadata.Builder mb = Metadata.builder(currentState.metadata());
Metadata.Builder mb = Metadata.builder(currentState.cluster().metadata());
ProjectMetadata.Builder newProjectMetadataBuilder = ProjectMetadata.builder(currentProjectMetadata);

// remove ENFORCE_DEFAULT_TIER_PREFERENCE from the persistent settings
Expand Down Expand Up @@ -245,7 +244,7 @@ public static Tuple<ClusterState, MigratedEntities> migrateToDataTiersRouting(
attribute
);
return Tuple.tuple(
ClusterState.builder(currentState).metadata(mb).putProjectMetadata(newProjectMetadataBuilder).build(),
ClusterState.builder(currentState.cluster()).metadata(mb).putProjectMetadata(newProjectMetadataBuilder).build(),
Copy link
Member

Choose a reason for hiding this comment

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

Your change here seems like a straight refactoring, so that's fine, but I have a wider question. This code is working at project scope, but it's also mutating state at the cluster scope (removing the ENFORCE_DEFAULT_TIER_PREFERENCE setting). That can't be safe, can it? Do we just not care because it's ILM? If so, it feels like we should use your annotation to call that out. If we plan to make it safe, is that tracked somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree that it's not ideal, but I figured we can make an exception for ILM. I have a feeling that we'll be making some changes to ProjectState at some point, to avoid these kinds of things (i.e. to make it safer in terms of what is modifiable). When we do so, we'll have to take places like this into account. Adding a @NotMultiProjectCapable sounds like a good idea. Will do.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks.

new MigratedEntities(removedIndexTemplateName, migratedIndices, migratedPolicies, migratedTemplates)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ protected void masterOperation(
ClusterState state,
ActionListener<MigrateToDataTiersResponse> listener
) throws Exception {
final var projectId = projectResolver.getProjectId();
if (request.isDryRun()) {
MigratedEntities entities = migrateToDataTiersRouting(
state,
projectResolver,
state.projectState(projectId),
request.getNodeAttributeName(),
request.getLegacyTemplateToDelete(),
xContentRegistry,
Expand Down Expand Up @@ -131,8 +131,7 @@ protected void masterOperation(
@Override
public ClusterState execute(ClusterState currentState) {
Tuple<ClusterState, MigratedEntities> migratedEntitiesTuple = migrateToDataTiersRouting(
currentState,
projectResolver,
currentState.projectState(projectId),
request.getNodeAttributeName(),
request.getLegacyTemplateToDelete(),
xContentRegistry,
Expand Down
Loading