Skip to content
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

Migrations always run if there is an old index template #28174

Closed
chrisdavies opened this issue Jan 7, 2019 · 4 comments · Fixed by #28252
Closed

Migrations always run if there is an old index template #28174

chrisdavies opened this issue Jan 7, 2019 · 4 comments · Fixed by #28252
Assignees
Labels
Team:Operations Team label for Operations Team

Comments

@chrisdavies
Copy link
Contributor

chrisdavies commented Jan 7, 2019

Latest master, running against a shared cloud ES instance that has an old index template.

The pattern is adding this mapping: gis-map.properties.bounds.strategy: 'recursive', which no longer exists in the latest version of Kibana. As a result, each time Kibana restarts, it sees that the Kibana index has an old mapping and attempts to migrate.

I think the solution is to remove / disable .kibana index templates prior to running migration, but I'm uncertain what potential negative consequences this might have.

Repro steps

  • Start Kibana in repl mode: yarn start --repl
  • After Kibana is done booting up, paste in the following:
var callCluster = kbnServer.server.plugins.elasticsearch.getCluster('admin').callWithInternalUser;

callCluster('indices.putTemplate', {
  name: 'kibana_index_template',
  body: {
    index_patterns: '.kibana',
    mappings: {
      "doc": {
        "dynamic": "strict",
        "properties": {
          "gis-map": {
            "properties": {
              "foo": {
                "type": "text",
              },
            },
          },
        },
      },
    },
  }
});
  • Delete the Kibana index (e.g. callCluster('indices.delete', { index: '.kibana_1' }) or whatever)
  • Restart Kibana
  • Note it migrates, restart again, and again, and it migrates each time...

NOTE: if you add "dynamic": "strict" to the index template mappings, the migration will fail (because it's adding fields to the mapping).

@chrisdavies chrisdavies added the Team:Operations Team label for Operations Team label Jan 7, 2019
@chrisdavies chrisdavies self-assigned this Jan 7, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations

@chrisdavies chrisdavies changed the title Migrations always run if there is an old index pattern Migrations always run if there is an old index template Jan 7, 2019
@chrisdavies
Copy link
Contributor Author

Seems like Tyler is addressing this specific instance with this PR: #28038

@chrisdavies
Copy link
Contributor Author

chrisdavies commented Jan 7, 2019

Seems we may want to remove the putTemplate call from the saved objects service while we're looking into this: #23661

Edit: @spalger pointed out that this is a breaking change, and should be 7.x or 8.x if we can't get it into 7.x

@chrisdavies
Copy link
Contributor Author

We discussed this at length yesterday, and came to a few different conclusions.

We should delete the Kibana index template prior to migrating, as we know it contains the old mappings, and that will cause unwanted interference with migrations.

But, that's only a partial fix. There still could be other index templates that target the Kibana index, and ES seems to have some magical mapping properites that will just reappear even though they weren't eplicitly stated at creation time: #28038

We need a less fragile way of determining if mapping changes should trigger a migration.

@spalger suggested hashing each plugin's mappings, and storing / diffing those hashes. Early on, we abandoned the hashing approach because we thought it'd trigger migrations too often (e.g. in situations where all we really need to do is patch the index mappings (such as adding a new field to a mapping). The hash approach will trigger a full migration on any change, unless we employ some complicated tricks.

I think we should move forward with a hash-based mappings diff, though, unless someone can think of a better approach that is robust to mapping properties being inserted by ES internals or broadly scoped index templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Operations Team label for Operations Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants