Skip to content

[Transform] Auto-migrate max_page_search_size #119348

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 9 commits into from
Jan 7, 2025
Merged

Conversation

prwhelan
Copy link
Member

max_page_search_size had been deprecated in Pivot and migrated to Settings in ES 7.x. We are removing the key in Pivot in 9.x. It is still possible to create Pivots with max_page_search_size, though a deprecation is logged. To prep for its removal, this change automatically migrates max_page_search_size from Pivot to Settings as if the user called _update.

  • PUT _transform with max_page_search_size in Pivot will migrate the value to Settings as part of the Transform's creation. The user will receive an additional deprecation warning informing of this migration.
  • Existing transforms with max_page_search_size in Pivot will migrate the value to Settings as part of node assignment during start. Transform Messages and Elasticsearch logs will record this event so users will know what happened.

`max_page_search_size` had been deprecated in Pivot and migrated to
Settings in ES 7.x.  We are removing the key in Pivot in 9.x.  It is
still possible to create Pivots with `max_page_search_size`, though a
deprecation is logged.  To prep for its removal, this change
automatically migrates `max_page_search_size` from Pivot to Settings as
if the user called `_update`.

- `PUT _transform` with `max_page_search_size` in Pivot will migrate the
  value to Settings as part of the Transform's creation.  The user will
  receive an additional deprecation warning informing of this migration.
- Existing transforms with `max_page_search_size` in Pivot will migrate
  the value to Settings as part of node assignment during start.
  Transform Messages and Elasticsearch logs will record this event so
  users will know what happened.
@elasticsearchmachine
Copy link
Collaborator

Hi @prwhelan, I've created a changelog YAML for you.

@prwhelan prwhelan marked this pull request as ready for review December 30, 2024 17:23
@elasticsearchmachine elasticsearchmachine added the Team:ML Meta label for the ML team label Dec 30, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

assertThat(createTransformResponse.get("acknowledged"), equalTo(Boolean.TRUE));

Map<String, Object> transform = getTransformConfig(transformId, BASIC_AUTH_VALUE_TRANSFORM_ADMIN_WITH_SOME_DATA_ACCESS);
assertThat(XContentMapValues.extractValue("pivot.max_page_search_size", transform), equalTo(null));
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Can just use assertNull here.

.withThrowable(validationException)
.log(
"Failed to validate auto-migrated Config. Please use the _update API to correct and update "
+ "the Transform configuration. Continuing with old config."
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Extra whitespace in between sentences.

private TransformConfig autoMigrateConfig(Request request) {
var config = transformConfigAutoMigration.migrate(request.getConfig());
if (config != request.getConfig()) {
deprecationLogger.warn(
Copy link
Member

Choose a reason for hiding this comment

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

Could this logging logic be contained within the transformConfigAutoMigration.migrate(...) function logic? Seems like something we'd want to happen whenever we call migrate and adding the logic there instead would also add a deprecation log when we call migrateAndSave.

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

public class TransformConfigAutoMigrationTests extends ESTestCase {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a test for when the transform has a max_page_search_size in both pivot config and settings and we just set the value to null? I know it's not a case we expect to actually hit but the code does specifically has this as an implementation decision we made so it's nice to have a test for it so we don't accidentally change this behavior.

@prwhelan
Copy link
Member Author

prwhelan commented Jan 3, 2025

@elasticmachine update branch

Copy link
Member

@dan-rubinstein dan-rubinstein left a comment

Choose a reason for hiding this comment

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

LGTM!

@prwhelan
Copy link
Member Author

prwhelan commented Jan 7, 2025

@elasticmachine update branch

@prwhelan
Copy link
Member Author

prwhelan commented Jan 7, 2025

@elasticmachine update branch

@prwhelan
Copy link
Member Author

prwhelan commented Jan 7, 2025

Verified with latest changes, settings max_page_search_size in PUT:

ElasticsearchWarning: Automatically migrating [max_page_search_size] from the pivot to the transform setting.
{
  "_index": ".ds-metrics-apm.app.elasticsearch-default-2025.01.07-000001",
  "_version": 1,
  "_source": {
    "@timestamp": "2025-01-07T17:09:04.516Z",
    "agent": {
      "activation_method": "javaagent-flag",
      "ephemeral_id": "<>",
      "name": "java",
      "version": "1.52.0"
    },
    "data_stream": {
      "dataset": "apm.app.elasticsearch",
      "namespace": "default",
      "type": "metrics"
    },
    "es": {
      "transform": {
        "automigration": {
          "count": {
            "total": 1
          }
        }
      },
  }
}

@prwhelan prwhelan enabled auto-merge (squash) January 7, 2025 17:15
@prwhelan prwhelan merged commit 7262fb3 into elastic:main Jan 7, 2025
15 of 16 checks passed
prwhelan added a commit to prwhelan/elasticsearch that referenced this pull request Jan 7, 2025
`max_page_search_size` had been deprecated in Pivot and migrated to
Settings in ES 7.x.  We are removing the key in Pivot in 9.x.  It is
still possible to create Pivots with `max_page_search_size`, though a
deprecation is logged.  To prep for its removal, this change
automatically migrates `max_page_search_size` from Pivot to Settings as
if the user called `_update`.

- `PUT _transform` with `max_page_search_size` in Pivot will migrate the
  value to Settings as part of the Transform's creation.  The user will
  receive an additional deprecation warning informing of this migration.
- Existing transforms with `max_page_search_size` in Pivot will migrate
  the value to Settings as part of node assignment during start.
  Transform Messages and Elasticsearch logs will record this event so
  users will know what happened.
prwhelan added a commit that referenced this pull request Jan 7, 2025
`max_page_search_size` had been deprecated in Pivot and migrated to
Settings in ES 7.x.  We are removing the key in Pivot in 9.x.  It is
still possible to create Pivots with `max_page_search_size`, though a
deprecation is logged.  To prep for its removal, this change
automatically migrates `max_page_search_size` from Pivot to Settings as
if the user called `_update`.

- `PUT _transform` with `max_page_search_size` in Pivot will migrate the
  value to Settings as part of the Transform's creation.  The user will
  receive an additional deprecation warning informing of this migration.
- Existing transforms with `max_page_search_size` in Pivot will migrate
  the value to Settings as part of node assignment during start.
  Transform Messages and Elasticsearch logs will record this event so
  users will know what happened.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants