Skip to content

Conversation

@nielsbauman
Copy link
Contributor

By making the step more generic, we can reuse it in other actions (such as the upcoming improvements to the force-merge action).

The change is relatively straightforward as the name of the step is already generic enough.

By making the step more generic, we can reuse it in other actions (such
as the upcoming improvements to the force-merge action).

The change is relatively straightforward as the name of the step is
already generic enough.
@nielsbauman nielsbauman requested a review from Copilot August 21, 2025 14:24
@nielsbauman nielsbauman added >refactoring :Data Management/ILM+SLM Index and Snapshot lifecycle management auto-backport Automatically create backport pull requests when merged v8.19.3 labels Aug 21, 2025
@elasticsearchmachine elasticsearchmachine added v9.2.0 Team:Data Management Meta label for data/management team labels Aug 21, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the UpdateSettingsStep class to use function suppliers instead of static settings, making it more generic and reusable for other ILM actions like the upcoming force-merge improvements.

  • Replaces static Settings field with Function<IndexMetadata, Settings> supplier for dynamic settings generation
  • Adds support for customizable target index name via Function<IndexMetadata, String> supplier
  • Updates all test files to use the new getSettingsSupplier().apply(null) pattern instead of getSettings()

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
UpdateSettingsStep.java Main refactoring - replaces static settings with function suppliers and removes equals/hashCode methods
UpdateSettingsStepTests.java Updates test methods to use new supplier-based API and removes settings mutation test case
SetPriorityActionTests.java Updates test assertions to call settings supplier instead of direct settings access
MigrateActionTests.java Updates test assertions to use settings supplier pattern
ForceMergeActionTests.java Updates test assertion to use settings supplier
AllocateActionTests.java Updates test assertions and extracts settings to variables for cleaner code

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

@Override
public boolean equals(Object obj) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's not much value in overriding hashCode and equals when the only two fields are functions (which might be lambdas) and thus do not implement those methods.

}

assertThat(firstStep.getSettings(), equalTo(expectedSettings.build()));
assertThat(firstStep.getSettingsSupplier().apply(null), equalTo(expectedSettings.build()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered adding a getter like so in UpdateSettingsStep:

// visibility for testing
Settings getSettings() {
	return settingsApplier(null);
}

to avoid having to do this in several tests, but I didn't feel like that was a good place for such test-only code, and I couldn't think of a sensible other place, so decided to update the few tests that required updating.

@nielsbauman nielsbauman requested a review from dakrone August 21, 2025 14:28
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, I left one super minor comment

private final Settings settings;
private static final BiFunction<String, LifecycleExecutionState, String> DEFAULT_TARGET_INDEX_NAME_SUPPLIER = (index, state) -> index;

private final BiFunction<String, LifecycleExecutionState, String> targetIndexNameSupplier;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the signature of the field to match the signature of similar fields in other steps, such as:

private final BiFunction<String, LifecycleExecutionState, String> targetIndexNameSupplier;

While I would prefer using Function<IndexMetadata, String> which still gives access to the name and state, and is more compact, having only one ShrinkIndexNameSupplier#getShrinkIndexName is more worth it IMO. We can always refactor all usages if one go if we change our mind.

@nielsbauman nielsbauman removed auto-backport Automatically create backport pull requests when merged v8.19.3 labels Aug 22, 2025
@nielsbauman nielsbauman enabled auto-merge (squash) August 22, 2025 05:26
@nielsbauman nielsbauman merged commit 5ad6a0e into elastic:main Aug 22, 2025
33 checks passed
@nielsbauman nielsbauman deleted the ilm-update-settings branch August 22, 2025 06:27
pabloem pushed a commit to pabloem/elasticsearch that referenced this pull request Aug 22, 2025
By making the step more generic, we can reuse it in other actions (such
as the upcoming improvements to the force-merge action).

The change is relatively straightforward as the name of the step is
already generic enough.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/ILM+SLM Index and Snapshot lifecycle management >refactoring Team:Data Management Meta label for data/management team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants