Skip to content

Commit

Permalink
Revert "Kibana system index does not allow user templates to affect it (
Browse files Browse the repository at this point in the history
#98696)"

This reverts commit 2239321.
  • Loading branch information
azasypkin authored Aug 25, 2023
1 parent c05e8da commit 2a5c532
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class KibanaPlugin extends Plugin implements SystemIndexPlugin {
.setAliasName(".kibana")
.setType(Type.EXTERNAL_UNMANAGED)
.setAllowedElasticProductOrigins(KIBANA_PRODUCT_ORIGIN)
.setAllowsTemplates()
.build();

public static final SystemIndexDescriptor REPORTING_INDEX_DESCRIPTOR = SystemIndexDescriptor.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
static final int EXTERNAL_UNMANAGED_FLAG_VALUE = 4;
static final String ASSOCIATED_INDEX_NAME = ".my-associated-idx";

public static final SystemIndexDescriptor ALLOW_TEMPLATES_MOCK_INDEX_DESCRIPTOR = SystemIndexDescriptor.builder()
.setIndexPattern(".allow_templates_*")
.setDescription("A system index that allows user templates")
.setAliasName(".allow_templates")
public static final SystemIndexDescriptor KIBANA_MOCK_INDEX_DESCRIPTOR = SystemIndexDescriptor.builder()
.setIndexPattern(".kibana_*")
.setDescription("Kibana saved objects system index")
.setAliasName(".kibana")
.setType(SystemIndexDescriptor.Type.EXTERNAL_UNMANAGED)
.setAllowedElasticProductOrigins(Collections.emptyList())
.setAllowedElasticProductOrigins(Collections.singletonList(ORIGIN))
Expand Down Expand Up @@ -281,13 +281,7 @@ public String getFeatureDescription() {

@Override
public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
return Arrays.asList(
INTERNAL_MANAGED,
INTERNAL_UNMANAGED,
EXTERNAL_MANAGED,
EXTERNAL_UNMANAGED,
ALLOW_TEMPLATES_MOCK_INDEX_DESCRIPTOR
);
return Arrays.asList(INTERNAL_MANAGED, INTERNAL_UNMANAGED, EXTERNAL_MANAGED, EXTERNAL_UNMANAGED, KIBANA_MOCK_INDEX_DESCRIPTOR);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ public void testBailOnMigrateWithTemplatesV1() throws Exception {
}

public void testMigrateWithTemplatesV1() throws Exception {
// this should pass for both, the first allows templates, the second INTERNAL_UNMANAGED doesn't match the template
migrateWithTemplatesV1(".allow_templates", ALLOW_TEMPLATES_MOCK_INDEX_DESCRIPTOR, INTERNAL_UNMANAGED);
// this should pass for both, kibana allows templates, the unmanaged doesn't match the template
migrateWithTemplatesV1(".kibana", KIBANA_MOCK_INDEX_DESCRIPTOR, INTERNAL_UNMANAGED);

assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
Expand Down Expand Up @@ -442,8 +442,8 @@ public void testBailOnMigrateWithTemplatesV2() throws Exception {
}

public void testMigrateWithTemplatesV2() throws Exception {
// this should pass for both, the first allows templates, the second INTERNAL_UNMANAGED doesn't match the template
migrateWithTemplatesV2(".allow_templates", ALLOW_TEMPLATES_MOCK_INDEX_DESCRIPTOR, INTERNAL_UNMANAGED);
// this should pass for both, kibana allows templates, the unmanaged doesn't match the template
migrateWithTemplatesV2(".kibana", KIBANA_MOCK_INDEX_DESCRIPTOR, INTERNAL_UNMANAGED);

assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable<Sy
private final boolean isNetNew;

/**
* Defaults to false as we typically don't want to apply user defined templates on system indices, since they may have unexpected
* behaviour when upgrading Elasticsearch versions.
* We typically don't want to apply user defined templates on system indices, since they may have unexpected
* behaviour when upgrading Elasticsearch versions. Currently, only the .kibana_ indices use templates, so we
* are making this property by default as false.
*/
private final boolean allowsTemplates;

Expand Down Expand Up @@ -207,7 +208,7 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable<Sy
* indices
* @param priorSystemIndexDescriptors A list of system index descriptors that describe the same index in a way that is compatible with
* older versions of Elasticsearch
* @param allowsTemplates if this system index descriptor allows templates to affect its settings
* @param allowsTemplates if this system index descriptor allows templates to affect its settings (e.g. .kibana_ indices)
*/
protected SystemIndexDescriptor(
String indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private void migrateSingleIndex(ClusterState clusterState, Consumer<BulkByScroll
String newIndexName = migrationInfo.getNextIndexName();

/**
* This is on for all system indices except when the system index explicitly opts out
* This should be on for all System indices except for .kibana_ indices. See allowsTemplates in KibanaPlugin.java for more info.
*/
if (migrationInfo.allowsTemplates() == false) {
final String v2template = MetadataIndexTemplateService.findV2Template(clusterState.metadata(), newIndexName, false);
Expand Down

0 comments on commit 2a5c532

Please sign in to comment.