-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New per-project only settings can be defined and used by components #127280
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
Merged
alexey-ivanov-es
merged 21 commits into
elastic:main
from
alexey-ivanov-es:per-project-settings
Apr 30, 2025
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7a5d446
New per-project only settings can be defined and used by components
alexey-ivanov-es 6eedbb4
Update docs/changelog/127252.yaml
alexey-ivanov-es a7ab20d
Merge branch 'main' into per-project-settings
alexey-ivanov-es 0c45219
[CI] Auto commit changes from spotless
elasticsearchmachine 20732ae
Fix tests
alexey-ivanov-es 671ae16
Remove comments
alexey-ivanov-es efebd32
[CI] Auto commit changes from spotless
elasticsearchmachine 1d42716
Update docs/changelog/127280.yaml
alexey-ivanov-es 0d60756
Delete old changelog file
alexey-ivanov-es 94b9fcd
Address review comments
alexey-ivanov-es a8a31c3
Move ProjectSettingsUpdater to serverless
alexey-ivanov-es 1d6ae73
Delete docs/changelog/127280.yaml
alexey-ivanov-es eebe304
Merge branch 'main' into per-project-settings
alexey-ivanov-es e040c9d
Fix tests
alexey-ivanov-es 0234193
Fix a bug in the cluster state application
alexey-ivanov-es 90f3c75
Make abstract
alexey-ivanov-es 910fd79
Merge branch 'main' into per-project-settings
alexey-ivanov-es dfc13a3
Make ingest.geoip.downloader.enabled project-scoped
alexey-ivanov-es 53d12e5
Merge branch 'main' into per-project-settings
alexey-ivanov-es 589105e
Merge branch 'main' into per-project-settings
alexey-ivanov-es 59adba1
Merge branch 'main' into per-project-settings
alexey-ivanov-es File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Move ProjectSettingsUpdater to serverless
- Loading branch information
commit a8a31c36ebc7e1a103a66cede9f58e74d4b6e0a4
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
server/src/main/java/org/elasticsearch/common/settings/BaseSettingsUpdater.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.common.settings; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.util.Supplier; | ||
import org.elasticsearch.core.Tuple; | ||
|
||
import java.util.Map; | ||
|
||
import static org.elasticsearch.common.settings.AbstractScopedSettings.ARCHIVED_SETTINGS_PREFIX; | ||
|
||
public class BaseSettingsUpdater { | ||
protected final AbstractScopedSettings scopedSettings; | ||
|
||
public BaseSettingsUpdater(AbstractScopedSettings scopedSettings) { | ||
this.scopedSettings = scopedSettings; | ||
} | ||
|
||
private static void logUnknownSetting(final String settingType, final Map.Entry<String, String> e, final Logger logger) { | ||
logger.warn("ignoring existing unknown {} setting: [{}] with value [{}]; archiving", settingType, e.getKey(), e.getValue()); | ||
} | ||
|
||
private static void logInvalidSetting( | ||
final String settingType, | ||
final Map.Entry<String, String> e, | ||
final IllegalArgumentException ex, | ||
final Logger logger | ||
) { | ||
logger.warn( | ||
(Supplier<?>) () -> "ignoring existing invalid " | ||
+ settingType | ||
+ " setting: [" | ||
+ e.getKey() | ||
+ "] with value [" | ||
+ e.getValue() | ||
+ "]; archiving", | ||
ex | ||
); | ||
} | ||
|
||
/** | ||
* Partitions the settings into those that are known and valid versus those that are unknown or invalid. The resulting tuple contains | ||
* the known and valid settings in the first component and the unknown or invalid settings in the second component. Note that archived | ||
* settings contained in the settings to partition are included in the first component. | ||
* | ||
* @param settings the settings to partition | ||
* @param settingsType a string to identify the settings (for logging) | ||
* @param logger a logger to sending warnings to | ||
* @return the partitioned settings | ||
*/ | ||
protected final Tuple<Settings, Settings> partitionKnownAndValidSettings( | ||
final Settings settings, | ||
final String settingsType, | ||
final Logger logger | ||
) { | ||
final Settings existingArchivedSettings = settings.filter(k -> k.startsWith(ARCHIVED_SETTINGS_PREFIX)); | ||
final Settings settingsExcludingExistingArchivedSettings = settings.filter(k -> k.startsWith(ARCHIVED_SETTINGS_PREFIX) == false); | ||
final Settings settingsWithUnknownOrInvalidArchived = scopedSettings.archiveUnknownOrInvalidSettings( | ||
settingsExcludingExistingArchivedSettings, | ||
e -> BaseSettingsUpdater.logUnknownSetting(settingsType, e, logger), | ||
(e, ex) -> BaseSettingsUpdater.logInvalidSetting(settingsType, e, ex, logger) | ||
); | ||
return Tuple.tuple( | ||
Settings.builder() | ||
.put(settingsWithUnknownOrInvalidArchived.filter(k -> k.startsWith(ARCHIVED_SETTINGS_PREFIX) == false)) | ||
.put(existingArchivedSettings) | ||
.build(), | ||
settingsWithUnknownOrInvalidArchived.filter(k -> k.startsWith(ARCHIVED_SETTINGS_PREFIX)) | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.