-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Adjust snapshot index resolution behavior to be more intuitive #79670
Conversation
This PR removes the logic used to ensure backwards-compatible behavior in the Snapshot and Restore APIs and updates the tests to check the new logic. This is technically a breaking change, but significantly improves the usability of snapshots in the presence of system indices. The new behavior is as follows: - When creating a snapshot, system indices are not resolved based on the `indices` field in the request. System indices are included or excluded using the `include_global_state` or `feature_states` fields, defaulting to snapshotting all system indices. - When restoring a snapshot, system indices cannot be requested using the `indices` field in the request. System indices are included or excluded using the `include_global_state` or `feature_states` fields, defaulting to restoring no system indices.
Pinging @elastic/es-distributed (Team:Distributed) |
mockLogAppender.stop(); | ||
Loggers.removeAppender(LogManager.getLogger("org.elasticsearch.deprecation.snapshots.RestoreService"), mockLogAppender); | ||
IndexNotFoundException ex = expectThrows( | ||
IndexNotFoundException.class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love that this results in an IndexNotFoundException
vs something more informative - I'd like to improve this and welcome suggestions on what to do instead. Unfortunately, I think anything reasonable here is going to mean more involved changes to RestoreService
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Production code changes look straightforward. I only have a couple of cleanup nitpicks and suggestions, and it looks like there might be a nontrivial test failure to fix.
@@ -237,7 +227,6 @@ public void testRestoreByFeature() { | |||
// restore indices by feature, with only the regular index named explicitly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: this comment is now out of date
@@ -484,7 +456,6 @@ public void testRestoreSystemIndicesAsGlobalStateWithEmptyListOfFeatureStates() | |||
|
|||
// restore regular index, with global state and an empty list of feature states |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: comment is out of date, since we're not specifying the single index anymore
.setFeatureStates(new String[] { randomFrom("none", "NONE") }) | ||
.get(); | ||
assertThat(restoreResponse.getRestoreInfo().successfulShards(), equalTo(restoreResponse.getRestoreInfo().successfulShards())); | ||
// GWB> What do we check here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we delete the system index before restoring, then verify that the snapshot didn't recreate it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case was now a duplicate of another! So I deleted it.
@@ -753,7 +710,6 @@ public void testNoneFeatureStateOnRestore() { | |||
|
|||
// Restore the snapshot specifying the regular index and "none" for feature states |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: update comment
// Strip system indices out of the list of "available" indices - these should only come from feature states. | ||
List<String> availableNonSystemIndices = new ArrayList<>(snapshotInfo.indices()); | ||
{ | ||
Set<String> systemIndicesInSnapshot = snapshotInfo.featureStates() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code might make sense as a method on the SnapshotInfo object, but I wouldn't insist on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from my end :) Sorry for the delay here!
💚 Backport successful
|
…ic#79670) This PR removes the logic used to ensure backwards-compatible behavior in the Snapshot and Restore APIs and updates the tests to check the new logic. This is technically a breaking change, but significantly improves the usability of snapshots in the presence of system indices. The new behavior is as follows: - When creating a snapshot, system indices are not resolved based on the `indices` field in the request. System indices are included or excluded using the `include_global_state` or `feature_states` fields, defaulting to snapshotting all system indices. - When restoring a snapshot, system indices cannot be requested using the `indices` field in the request. System indices are included or excluded using the `include_global_state` or `feature_states` fields, defaulting to restoring no system indices.
… (#81180) This PR removes the logic used to ensure backwards-compatible behavior in the Snapshot and Restore APIs and updates the tests to check the new logic. This is technically a breaking change, but significantly improves the usability of snapshots in the presence of system indices. The new behavior is as follows: - When creating a snapshot, system indices are not resolved based on the `indices` field in the request. System indices are included or excluded using the `include_global_state` or `feature_states` fields, defaulting to snapshotting all system indices. - When restoring a snapshot, system indices cannot be requested using the `indices` field in the request. System indices are included or excluded using the `include_global_state` or `feature_states` fields, defaulting to restoring no system indices.
This commit changes SnapshotsService to throw an error when a system index is explicitly requested, rather than silently dropping it, and adds a test to verify that behavior. Note that *only* system indices requested by full name return an error, requesting e.g. `"indices": ".geo*"` (which would normally resolve to `.geoip_databases`) does not include its system index and does not error, but requesting `"indices": ".geoip_databases"` *will* return an error. Follow-up to #79670 --- This should have been part of the original change - I thought we had already done this, but @jrodewig pointed out to me that it silently dropped system indices instead.
…1235) This commit changes SnapshotsService to throw an error when a system index is explicitly requested, rather than silently dropping it, and adds a test to verify that behavior. Note that *only* system indices requested by full name return an error, requesting e.g. `"indices": ".geo*"` (which would normally resolve to `.geoip_databases`) does not include its system index and does not error, but requesting `"indices": ".geoip_databases"` *will* return an error. Follow-up to elastic#79670 --- This should have been part of the original change - I thought we had already done this, but @jrodewig pointed out to me that it silently dropped system indices instead.
…81346) This commit changes SnapshotsService to throw an error when a system index is explicitly requested, rather than silently dropping it, and adds a test to verify that behavior. Note that *only* system indices requested by full name return an error, requesting e.g. `"indices": ".geo*"` (which would normally resolve to `.geoip_databases`) does not include its system index and does not error, but requesting `"indices": ".geoip_databases"` *will* return an error. Follow-up to #79670 --- This should have been part of the original change - I thought we had already done this, but @jrodewig pointed out to me that it silently dropped system indices instead.
With elastic/elasticsearch#79670, you can only include system indices in a snapshot using feature states. This updates some references to taking a snapshots of the `.kibana*` system indices. Relates to elastic/elasticsearch#81226
With elastic/elasticsearch#79670, you can only include system indices in a snapshot using feature states. This updates some references to taking a snapshots of the `.kibana*` system indices. Relates to elastic/elasticsearch#81226
With elastic/elasticsearch#79670, you can only include system indices in a snapshot using feature states. This updates some references to taking a snapshots of the `.kibana*` system indices. Relates to elastic/elasticsearch#81226 Co-authored-by: James Rodewig <james.rodewig@elastic.co>
With elastic/elasticsearch#79670, you can only include system indices in a snapshot using feature states. This updates some references to taking a snapshots of the `.kibana*` system indices. Relates to elastic/elasticsearch#81226
This PR removes the logic used to ensure backwards-compatible behavior
in the Snapshot and Restore APIs and updates the tests to check the new
logic. This is technically a breaking change, but significantly improves
the usability of snapshots in the presence of system indices.
The new behavior is as follows:
indices
field in the request. System indices are included or excludedusing the
include_global_state
orfeature_states
fields, defaultingto snapshotting all system indices.
the
indices
field in the request. System indices are included orexcluded using the
include_global_state
orfeature_states
fields,defaulting to restoring no system indices.
Fixes #78320
It's worth noting that this is a breaking change, but we deprecated the behavior that won't work anymore a while ago, and I don't think anyone likes the current behavior - it's a mess because of shenanigans we had to pull to maintain BWC.