-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Allow date math for naming newly-created snapshots (#7939) #30479
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
Changes from 1 commit
4055c34
4b20260
b168ec8
256c3c7
117495f
ff244bd
4648145
04404d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; | ||
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.metadata.MetaData; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
@@ -176,4 +177,30 @@ public void testSnapshotStatusWithBlocks() { | |
setClusterReadOnly(false); | ||
} | ||
} | ||
|
||
public void testSnapshotWithDateMath() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what this is exactly testing. There are no assertions that check that the date math functionality has worked in a meaningful way. Also why is this testing blocks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it tests that it is possible to create snapshot with name Agree - it is worth to move test to |
||
// This test checks that the Snapshot Status operation is never blocked, even if the cluster is read only. | ||
try { | ||
setClusterReadOnly(true); | ||
|
||
final IndexNameExpressionResolver nameExpressionResolver = new IndexNameExpressionResolver(Settings.EMPTY); | ||
final String snapshotName = "<snapshot-{now/d}>"; | ||
final String expression = nameExpressionResolver.resolveDateMathExpression(snapshotName); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you revert this? |
||
CreateSnapshotResponse snapshotResponse = | ||
client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, snapshotName) | ||
.setIncludeGlobalState(true) | ||
.setWaitForCompletion(true) | ||
.execute().actionGet(); | ||
assertThat(snapshotResponse.status(), equalTo(RestStatus.OK)); | ||
|
||
SnapshotsStatusResponse response = client().admin().cluster().prepareSnapshotStatus(REPOSITORY_NAME) | ||
.setSnapshots(expression) | ||
.execute().actionGet(); | ||
assertThat(response.getSnapshots(), hasSize(1)); | ||
assertThat(response.getSnapshots().get(0).getState().completed(), equalTo(true)); | ||
} finally { | ||
setClusterReadOnly(false); | ||
} | ||
} | ||
} |
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 links to docs on using date math for index names. This can be confusing. I think you need to clarify here that the same date math expression that is used for indices can be used for snapshot names. I think it would be better to put this info into a separate paragraph, together with an example. I wonder if we need to support date math not only for snapshot creation, but also for other operations.