Allow private settings when system provided#133789
Conversation
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
Outdated
Show resolved
Hide resolved
|
The I'm probably missing something here.. |
|
Looks like we're skipping adding the private settings during template validation via this hack: I'd rather have the template validation work on the actual settings than the provider behaving differently during validation. |
dakrone
left a comment
There was a problem hiding this comment.
I looked at this and left a couple of comments (nothing of substance). I keep having a sneaking suspicion that there's a more elegant way to do this, but it might be the late-Friday-afternoon brain telling me that. I'm going to take another look at it next week.
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
Outdated
Show resolved
Hide resolved
...n/downsample/src/main/java/org/elasticsearch/xpack/downsample/TransportDownsampleAction.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Lee Hinman <dakrone@users.noreply.github.com>
…s-if-system-provided
martijnvg
left a comment
There was a problem hiding this comment.
LGTM, I think with this we can also remove the isTemplateValidation check in LogsdbIndexModeSettingsProvider.
I would like either Ryan or Lee to also take a look at this PR.
dakrone
left a comment
There was a problem hiding this comment.
LGTM, I left two really tiny optional things.
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
Outdated
Show resolved
Hide resolved
| final var combinedSettings = resolveSettings(indexTemplate, projectMetadata.componentTemplates()); | ||
| // First apply settings sourced from index setting providers: | ||
| var finalSettings = Settings.builder(); | ||
| var additionalSettingsBuilder = Settings.builder(); |
There was a problem hiding this comment.
Minor suggestion (take it or leave it), perhaps call this systemSettingsBuilder and systemSettings instead of additional… since it gets passed to the validation as the system-provided settings?
There was a problem hiding this comment.
OTOH, it's coming from the provideAdditionalSettings method and it's being passed in to the validateAdditionalSettings method. I think it make sense as-is. The main thing to convey about these within validateIndexTemplateV2 are that these are additional settings. What's more important about these in the context of validation is that these additional settings are indeed system provided.
prdoyle
left a comment
There was a problem hiding this comment.
Like @dakrone I'm a bit worried that we have three different names for what appears to be the same concept:
- "additional settings"
- "system provided settings"
- settings from an
IndexSettingProvider
I think we should either use the same name everywhere, or else very clearly define the differences between these concepts.
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java
Show resolved
Hide resolved
...java/org/elasticsearch/action/admin/indices/create/CreateIndexClusterStateUpdateRequest.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java
Show resolved
Hide resolved
The thought process behind it was that getIndexSettingsValidationErrors(
final Settings settings,
@Nullable Settings systemProvided,
final boolean forbidPrivateIndexSettings
)to getIndexSettingsValidationErrors(
final Settings settings,
@Nullable Settings additionalSettings,
final boolean forbidPrivateIndexSettings
)to match the naming in The main concern of What do you think about calling it consistently Personally, I still like it the best as-is. But I'm definitely not married to a particular name and I'm happy to rename to something y'all feel more comfortable with. This doesn't seem like a make or break kind of decision. So let's align on something so that we can move on. |
prdoyle
left a comment
There was a problem hiding this comment.
Re my naming comment, I'm happy that @felixbarny has thought about it a bunch, and that simplifying the naming isn't straightforward, so let's just merge it as is.
As discussed in #132566, we'd like to provide private index settings with an
IndexSettingsProvider. This is currently not possible because it fails validation for composable index templates (template v2). That's because we first merge all settings from the index template with the ones from theIndexSettingsProvidersand then check whether there are private settings.I've added a way so pass down the settings provided by the
IndexSettingsProvidersto the validation so that these system-provided settings are allowed to contain private settings.Another area that needs to be enhanced is to allow downsampling to create indices containing private settings that are copied from the source index. For that reason, I've added a
settingsSystemProvidedflag toCreateIndexClusterStateUpdateRequest.