Skip to content

Introduce system index types including external#68919

Merged
jaymode merged 24 commits intoelastic:masterfrom
jaymode:external_system_indices
Mar 1, 2021
Merged

Introduce system index types including external#68919
jaymode merged 24 commits intoelastic:masterfrom
jaymode:external_system_indices

Conversation

@jaymode
Copy link
Copy Markdown
Member

@jaymode jaymode commented Feb 11, 2021

This commit introduces system index types that will be used to
differentiate behavior. Previously system indices were all treated the
same regardless of whether they belonged to Elasticsearch, a stack
component, or one of our solutions. Upon further discussion and
analysis this decision was not in the best interest of the various
teams and instead a new type of system index was needed. These system
indices will be referred to as external system indices. Within external
system indices, an option exists for these indices to be managed by
Elasticsearch or to be managed by the external product.

In order to represent this within Elasticsearch, each system index will
have a type and this type will be used to control behavior.

Closes #67383

There are still some open items that need to be addressed:

This commit introduces system index types that will be used to
differentiate behavior. Previously system indices were all treated the
same regardless of whether they belonged to Elasticsearch, a stack
component, or one of our solutions. Upon further discussion and
analysis this decision was not in the best interest of the various
teams and instead a new type of system index was needed. These system
indices will be referred to as external system indices. Within external
system indices, an option exists for these indices to be managed by
Elasticsearch or to be managed by the external product.

In order to represent this within Elasticsearch, each system index will
have a type and this type will be used to control behavior.

Closes elastic#67383
@jaymode jaymode marked this pull request as ready for review February 16, 2021 19:39
@jaymode jaymode added :Core/Infra/Core Core issues without another label >non-issue v7.12.0 v8.0.0 labels Feb 16, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Feb 16, 2021
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@pugnascotia
Copy link
Copy Markdown
Contributor

I see this expression all over the tests:

new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY), new SystemIndices(Map.of()))

...and it makes me wonder whether it's worth putting it in a test utility class somewhere. That said, the only value it would add is cutting down some repetition, and at this point I'm not sure it'd be worth the cost of the extra refactoring.

Copy link
Copy Markdown
Contributor

@AthenaEryma AthenaEryma left a comment

Choose a reason for hiding this comment

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

Left a few minor comments but overall LGTM

.setIndexPattern(".apm-custom-link")
.setDescription("system index for APM custom links")
.setType(Type.EXTERNAL_UNMANAGED)
.setAllowedStackComponents(List.of("kibana"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Move "kibana" (or List.of("kibana")) to a constant.

Comment on lines +320 to +324
final Predicate<IndexMetadata> systemIndexAccessLevelPredicate = systemIndexAccessLevel == SystemIndexAccessLevel.NONE ?
indexMetadata -> true :
systemIndices
.getProductSystemIndexMetadataPredicate(threadContext.getHeader(EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY))
.negate();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be worth breaking this up a bit, it took me a minute to parse this expression.

return this;
}

public Builder setAllowedStackComponents(List<String> allowedStackComponents) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: It's allowedStackComponents here in the builder and allowedElasticProductOrigins elsewhere, we should probably be consistent.

Copy link
Copy Markdown
Contributor

@williamrandolph williamrandolph left a comment

Choose a reason for hiding this comment

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

Looks good to me! I have one little thought on a Javadoc.

/**
* The specific type of system index that this descriptor represents. System indices have three defined types, which is used to
* control behavior. Elasticsearch itself has system indices that are necessary for features of Elasticsearch; these system indices
* are referred to as internal system indices. Internal system indices are always managed indices that Elasticsearch itself manages.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it is worth mentioning that plugins, even third-party plugins, can implement internal indices. A plugin developer trying to implement SystemIndicesPlugin might look here to decide what type of index to choose.

@jaymode jaymode merged commit 1487a5a into elastic:master Mar 1, 2021
@jaymode jaymode deleted the external_system_indices branch March 1, 2021 17:39
jaymode added a commit that referenced this pull request Mar 2, 2021
This commit introduces system index types that will be used to
differentiate behavior. Previously system indices were all treated the
same regardless of whether they belonged to Elasticsearch, a stack
component, or one of our solutions. Upon further discussion and
analysis this decision was not in the best interest of the various
teams and instead a new type of system index was needed. These system
indices will be referred to as external system indices. Within external
system indices, an option exists for these indices to be managed by
Elasticsearch or to be managed by the external product.

In order to represent this within Elasticsearch, each system index will
have a type and this type will be used to control behavior.

Closes #67383
Backport of #68919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v7.13.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External system indices

6 participants