[MM-49084] public/model/config: elasticsearch: add ingore option to some indexes to purge (#23571)

This commit is contained in:
Ibrahim Serdar Acikgoz 2023-06-10 00:50:08 +03:00 committed by GitHub
parent b9f52126c2
commit 446b474489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 82 additions and 0 deletions

View File

@ -566,6 +566,7 @@ const defaultServerConfig: AdminConfig = {
ClientCert: '',
ClientKey: '',
Trace: '',
IgnoredPurgeIndexes: '',
},
BleveSettings: {
IndexDir: '',

View File

@ -8687,6 +8687,10 @@
"id": "model.config.is_valid.elastic_search.enable_searching.app_error",
"translation": "Elasticsearch EnableIndexing setting must be set to true when Elasticsearch EnableSearching is set to true"
},
{
"id": "model.config.is_valid.elastic_search.ignored_indexes_dash_prefix.app_error",
"translation": "Ignored indexes for purge should not start with dash."
},
{
"id": "model.config.is_valid.elastic_search.live_indexing_batch_size.app_error",
"translation": "Elasticsearch Live Indexing Batch Size must be at least 1."

View File

@ -2628,6 +2628,7 @@ type ElasticsearchSettings struct {
ClientCert *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
ClientKey *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
Trace *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
IgnoredPurgeIndexes *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` // telemetry: none
}
func (s *ElasticsearchSettings) SetDefaults() {
@ -2726,6 +2727,10 @@ func (s *ElasticsearchSettings) SetDefaults() {
if s.Trace == nil {
s.Trace = NewString("")
}
if s.IgnoredPurgeIndexes == nil {
s.IgnoredPurgeIndexes = NewString("")
}
}
type BleveSettings struct {
@ -3874,6 +3879,15 @@ func (s *ElasticsearchSettings) isValid() *AppError {
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.request_timeout_seconds.app_error", nil, "", http.StatusBadRequest)
}
if ign := *s.IgnoredPurgeIndexes; ign != "" {
s := strings.Split(ign, ",")
for _, ix := range s {
if strings.HasPrefix(ix, "-") {
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.ignored_indexes_dash_prefix.app_error", nil, "", http.StatusBadRequest)
}
}
}
return nil
}

View File

@ -362,6 +362,25 @@ exports[`components/ElasticSearchSettings should match snapshot, disabled 1`] =
}
}
/>
<AdminTextSetting
disabled={true}
helpText={
<Memo(MemoizedFormattedMessage)
defaultMessage="When filled in, these indexes will be ignored during the purge, separated by commas."
id="admin.elasticsearch.ignoredPurgeIndexesDescription"
/>
}
id="ignoredPurgeIndexes"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Indexes to skip while purging:"
id="admin.elasticsearch.ignoredPurgeIndexes"
/>
}
onChange={[Function]}
placeholder="E.g.: .opendistro*,.security*"
setByEnv={false}
/>
<BooleanSetting
disabled={true}
falseText={
@ -829,6 +848,25 @@ exports[`components/ElasticSearchSettings should match snapshot, enabled 1`] = `
}
}
/>
<AdminTextSetting
disabled={false}
helpText={
<Memo(MemoizedFormattedMessage)
defaultMessage="When filled in, these indexes will be ignored during the purge, separated by commas."
id="admin.elasticsearch.ignoredPurgeIndexesDescription"
/>
}
id="ignoredPurgeIndexes"
label={
<Memo(MemoizedFormattedMessage)
defaultMessage="Indexes to skip while purging:"
id="admin.elasticsearch.ignoredPurgeIndexes"
/>
}
onChange={[Function]}
placeholder="E.g.: .opendistro*,.security*"
setByEnv={false}
/>
<BooleanSetting
disabled={false}
falseText={

View File

@ -31,6 +31,7 @@ export default class ElasticsearchSettings extends AdminSettings {
config.ElasticsearchSettings.EnableIndexing = this.state.enableIndexing;
config.ElasticsearchSettings.EnableSearching = this.state.enableSearching;
config.ElasticsearchSettings.EnableAutocomplete = this.state.enableAutocomplete;
config.ElasticsearchSettings.IgnoredPurgeIndexes = this.state.ignoredPurgeIndexes;
return config;
};
@ -51,6 +52,7 @@ export default class ElasticsearchSettings extends AdminSettings {
configTested: true,
canSave: true,
canPurgeAndIndex: config.ElasticsearchSettings.EnableIndexing,
ignoredPurgeIndexes: config.ElasticsearchSettings.IgnoredPurgeIndexes,
};
}
@ -430,6 +432,26 @@ export default class ElasticsearchSettings extends AdminSettings {
/>
)}
/>
<TextSetting
id='ignoredPurgeIndexes'
label={
<FormattedMessage
id='admin.elasticsearch.ignoredPurgeIndexes'
defaultMessage='Indexes to skip while purging:'
/>
}
placeholder={'E.g.: .opendistro*,.security*'}
helpText={
<FormattedMessage
id='admin.elasticsearch.ignoredPurgeIndexesDescription'
defaultMessage='When filled in, these indexes will be ignored during the purge, separated by commas.'
/>
}
value={this.state.ignoredPurgeIndexes}
disabled={this.props.isDisabled || !this.state.enableIndexing}
onChange={this.handleSettingChanged}
setByEnv={this.isSetByEnv('ElasticsearchSettings.IgnoredPurgeIndexes')}
/>
<BooleanSetting
id='enableSearching'
label={

View File

@ -772,6 +772,8 @@
"admin.elasticsearch.enableIndexingTitle": "Enable Elasticsearch Indexing:",
"admin.elasticsearch.enableSearchingDescription": "Requires a successful connection to the Elasticsearch server. When true, Elasticsearch will be used for all search queries using the latest index. Search results may be incomplete until a bulk index of the existing post database is finished. When false, database search is used.",
"admin.elasticsearch.enableSearchingTitle": "Enable Elasticsearch for search queries:",
"admin.elasticsearch.ignoredPurgeIndexes": "Indexes to skip while purging:",
"admin.elasticsearch.ignoredPurgeIndexesDescription": "When filled in, these indexes will be ignored during the purge, separated by commas.",
"admin.elasticsearch.password": "E.g.: \"yourpassword\"",
"admin.elasticsearch.passwordDescription": "(Optional) The password to authenticate to the Elasticsearch server.",
"admin.elasticsearch.passwordTitle": "Server Password:",

View File

@ -774,6 +774,7 @@ export type ElasticsearchSettings = {
ClientCert: string;
ClientKey: string;
Trace: string;
IgnoredPurgeIndexes: string;
};
export type BleveSettings = {