-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add support for partial searchable snapshots to ILM #68714
Add support for partial searchable snapshots to ILM #68714
Conversation
This commit adds support for the recently introduced partial searchable snapshot (elastic#68509) to ILM. Searchable snapshot ILM actions may now be specified with a `storage` option, specifying either `full_copy` or `shared_cache` (similar to the "mount" API) to mount either a full or partial searchable snapshot: ```json PUT _ilm/policy/my_policy { "policy": { "phases": { "cold": { "actions": { "searchable_snapshot" : { "snapshot_repository" : "backing_repo", "storage": "shared_cache" } } } } } } ``` Internally, If more than one searchable snapshot action is specified (for example, a full searchable snapshot in the "cold" phase and a partial searchable snapshot in the "frozen" phase) ILM will re-use the existing snapshot when doing the second mount since a second snapshot is not required. Currently this is allowed for actions that use the same repository, however, multiple `searchable_snapshot` actions for the same index that use different repositories is not allowed (the ERROR state is entered). We plan to allow this in the future in subsequent work. If the `storage` option is not specified in the `searchable_snapshot` action, the mount type defaults to "shared_cache" in the frozen phase and "full_copy" in all other phases. Relates to elastic#68605
Pinging @elastic/es-core-features (Team:Core/Features) |
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 looks great @dakrone! Thanks for adding support for the partial searchable snapshots, this is an awesome feature.
I left only a few minor/cosmetic comments.
// This index had its searchable snapshot created prior to a version where we captured | ||
// the original index name, so make our best guess at the name | ||
indexName = bestEffortIndexNameResolution(indexName); | ||
logger.debug("index [{}] using policy [{}] does not have a stored snapshot index name, " + |
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.
should we log on warn
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.
I don't think so, since this will be a pretty common occurrence for anyone upgrading, and it's not anything a user needs to be concerned about (they can't change it anyway)
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SearchableSnapshotAction.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SearchableSnapshotAction.java
Outdated
Show resolved
Hide resolved
/** | ||
* Resolves the prefix to be used for the mounted index depending on the provided key | ||
*/ | ||
String getRestoredIndexPrefix(StepKey currentKey) { |
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 could be static
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.
These make use of the storageType
instance variable, while we could passed it in, I think that would make the code unnecessarily verbose where these methods are called. I think I'd prefer to keep it as non-static if that's okay with you.
} | ||
|
||
// Resolves the storage type from a Nullable to non-Nullable type | ||
MountSearchableSnapshotRequest.Storage getConcreteStorageType(StepKey currentKey) { |
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 could be static
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.
These make use of the storageType
instance variable, while we could passed it in, I think that would make the code unnecessarily verbose where these methods are called. I think I'd prefer to keep it as non-static if that's okay with you.
@@ -234,6 +234,22 @@ public String toString() { | |||
FULL_COPY, | |||
SHARED_CACHE; | |||
|
|||
public static Storage fromString(String type) { | |||
if ("full_copy".equals(type)) { |
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.
should we equalsIgnoreCase
in these branches? Or is case important?
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.
It's not really that important, but since equalsIgnoreCase
doesn't take a locale so we can't pass it in, I figure it's safer to keep it as-is and be strict (we can always loosen the restrictions if we decide we need to at a later time)
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MountSnapshotStepTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/MountSnapshotStepTests.java
Show resolved
Hide resolved
if (this.snapshotRepository.equals(lifecycleExecutionState.getSnapshotRepository()) == false) { | ||
// A different repository is being used | ||
// TODO: allow this behavior instead of throwing an exception | ||
throw new IllegalArgumentException("searchable snapshot indices may be converted only within the same repository"); |
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.
shall we prevent this at policy validation time for now?
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.
Not yet I think, I'm going to try to get it done this week, and if I don't have time, I'll add the policy validation at the end of the week (trying to avoid adding the policy validation and then immediately removing it)
@elasticmachine update branch |
This commit adds support for the recently introduced partial searchable snapshot (elastic#68509) to ILM. Searchable snapshot ILM actions may now be specified with a `storage` option, specifying either `full_copy` or `shared_cache` (similar to the "mount" API) to mount either a full or partial searchable snapshot: ```json PUT _ilm/policy/my_policy { "policy": { "phases": { "cold": { "actions": { "searchable_snapshot" : { "snapshot_repository" : "backing_repo", "storage": "shared_cache" } } } } } } ``` Internally, If more than one searchable snapshot action is specified (for example, a full searchable snapshot in the "cold" phase and a partial searchable snapshot in the "frozen" phase) ILM will re-use the existing snapshot when doing the second mount since a second snapshot is not required. Currently this is allowed for actions that use the same repository, however, multiple `searchable_snapshot` actions for the same index that use different repositories is not allowed (the ERROR state is entered). We plan to allow this in the future in subsequent work. If the `storage` option is not specified in the `searchable_snapshot` action, the mount type defaults to "shared_cache" in the frozen phase and "full_copy" in all other phases. Relates to elastic#68605
Relates to backporting elastic#68714
…68762) This commit adds support for the recently introduced partial searchable snapshot (#68509) to ILM. Searchable snapshot ILM actions may now be specified with a `storage` option, specifying either `full_copy` or `shared_cache` (similar to the "mount" API) to mount either a full or partial searchable snapshot: `json PUT _ilm/policy/my_policy { "policy": { "phases": { "cold": { "actions": { "searchable_snapshot" : { "snapshot_repository" : "backing_repo", "storage": "shared_cache" } } } } } } ` Internally, If more than one searchable snapshot action is specified (for example, a full searchable snapshot in the "cold" phase and a partial searchable snapshot in the "frozen" phase) ILM will re-use the existing snapshot when doing the second mount since a second snapshot is not required. Currently this is allowed for actions that use the same repository, however, multiple `searchable_snapshot` actions for the same index that use different repositories is not allowed (the ERROR state is entered). We plan to allow this in the future in subsequent work. If the `storage` option is not specified in the `searchable_snapshot` action, the mount type defaults to "shared_cache" in the frozen phase and "full_copy" in all other phases. Relates to #68605
This commit adds validation when updating or creating an ILM policy that mulitple searchable snapshot actions all use the same repository. We currently do not have the infrastructure to support switching a searchable snapshot from one repository to another, so until we have that we will disallow this (edge case) when creating a policy. Relates to elastic#68714
…ies (#68856) This commit adds validation when updating or creating an ILM policy that mulitple searchable snapshot actions all use the same repository. We currently do not have the infrastructure to support switching a searchable snapshot from one repository to another, so until we have that we will disallow this (edge case) when creating a policy. Relates to #68714
…ies (elastic#68856) This commit adds validation when updating or creating an ILM policy that mulitple searchable snapshot actions all use the same repository. We currently do not have the infrastructure to support switching a searchable snapshot from one repository to another, so until we have that we will disallow this (edge case) when creating a policy. Relates to elastic#68714
…ositories (#68856) (#68866) This commit adds validation when updating or creating an ILM policy that mulitple searchable snapshot actions all use the same repository. We currently do not have the infrastructure to support switching a searchable snapshot from one repository to another, so until we have that we will disallow this (edge case) when creating a policy. Relates to #68714
This commit adds support for the recently introduced partial searchable snapshot (#68509) to ILM.
Searchable snapshot ILM actions may now be specified with a
storage
option, specifying eitherfull_copy
orshared_cache
(similar to the "mount" API) to mount either a full or partialsearchable snapshot:
Internally, If more than one searchable snapshot action is specified (for example, a full searchable
snapshot in the "cold" phase and a partial searchable snapshot in the "frozen" phase) ILM will
re-use the existing snapshot when doing the second mount since a second snapshot is not required.
Currently this is allowed for actions that use the same repository, however, multiple
searchable_snapshot
actions for the same index that use different repositories is not allowed (theERROR state is entered). We plan to allow this in the future in subsequent work.
If the
storage
option is not specified in thesearchable_snapshot
action, the mount typedefaults to "shared_cache" in the frozen phase and "full_copy" in all other phases.
Relates to #68605