Skip to content

Handle snapshot restore in file settings#89321

Merged
grcevski merged 11 commits intoelastic:mainfrom
grcevski:operator/file_settings_snapshots
Aug 16, 2022
Merged

Handle snapshot restore in file settings#89321
grcevski merged 11 commits intoelastic:mainfrom
grcevski:operator/file_settings_snapshots

Conversation

@grcevski
Copy link
Copy Markdown
Contributor

@grcevski grcevski commented Aug 12, 2022

Background information

File based settings create a reserved cluster state, preventing REST mutation of any settings/entities created in this mode. The only way these settings can be modified is through a change in the operator/settings.json file inside our config directory.

When we do snapshot restore we can also bring back the global cluster state, effectively rewriting the cluster state and with it any reserved state. This introduces few issues related to file based settings:

  • If there is an operator/settings.json file, it effectively won't be the source of truth anymore, until an update is made to this file.
  • If the restore is from another cluster, the metadata version of the reserved state can be higher than the current cluster version accounting, meaning settings updates might fail even if the file is updated.
  • If the cluster we are restoring into doesn't use file settings, but the snapshot we are restoring had some reserved state, we would be permanently locking from updates those settings that were reserved.

Adding support for snapshots in file based settings

To support snapshots in file based settings we take the following approach:

  1. If the snapshot doesn't restore the global state, we don't do anything.
  2. In case we are restoring the global state, we now call the file settings service to:
    • If there's an operator/settings.json file: reset the reserved state metadata version to 0 and touch the file so that the watcher service will apply the settings.
    • If there's no operator/settings.json, we remove the reserved cluster state effectively unlocking those settings that were reserved.

Relates to #89183

@grcevski grcevski added :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team auto-backport-and-merge v8.4.1 v8.5.0 labels Aug 12, 2022
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

* </p>
*/
public interface ReservedClusterStateHandler<T> {
String CONTENT = "content";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was just some dead code, left from earlier refactoring.

@grcevski grcevski added the >bug label Aug 12, 2022
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @grcevski, I've created a changelog YAML for you.

@grcevski
Copy link
Copy Markdown
Contributor Author

@elasticsearchmachine test this please

Copy link
Copy Markdown
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

LGTM.

*/
public Builder(ReservedStateMetadata metadata) {
this(metadata.namespace);
if (metadata != null) {
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.

Is this null check redundant? On the previous line, metadata.namespace will throw a NPE if metadata is null

@grcevski grcevski merged commit dc672b0 into elastic:main Aug 16, 2022
@grcevski grcevski deleted the operator/file_settings_snapshots branch August 16, 2022 21:18
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
8.4

grcevski added a commit to grcevski/elasticsearch that referenced this pull request Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team v8.4.0 v8.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants