-
Notifications
You must be signed in to change notification settings - Fork 118
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
Making snapshot name to scripted input in template #77
Conversation
Is there something that is holding this up? This feature would be greatly appreciated |
…ed from the index or any runtime attributes instead of being constant Signed-off-by: Ravi Thaluru <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #77 +/- ##
============================================
- Coverage 75.88% 75.81% -0.07%
- Complexity 1922 1924 +2
============================================
Files 260 260
Lines 10992 11002 +10
Branches 1720 1723 +3
============================================
Hits 8341 8341
- Misses 1699 1710 +11
+ Partials 952 951 -1
Continue to review full report at Codecov.
|
...lin/org/opensearch/indexmanagement/indexstatemanagement/step/snapshot/AttemptSnapshotStep.kt
Outdated
Show resolved
Hide resolved
@@ -159,6 +173,7 @@ class AttemptSnapshotStep( | |||
} | |||
|
|||
companion object { | |||
val validTopContextFields = setOf("index", "indexUuid") |
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.
Just to confirm is this all users have asked for? (Access to index/indexUuid in the snapshot 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.
the users only asked for indexName in the issue, I have added indexUuid too since its readily available
.format(DateTimeFormatter.ofPattern("uuuu.MM.dd-HH:mm:ss.SSS", Locale.ROOT)) | ||
) | ||
val snapshotScript = Script(ScriptType.INLINE, Script.DEFAULT_TEMPLATE_LANG, config.snapshot, mapOf()) | ||
snapshotName = compileTemplate(snapshotScript, managedIndexMetaData, indexName).plus(snapshotNamePrefix) |
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.
Any behavior differences for users w/ existing snapshot actions or they should continue to work (and behave) as before this fix?
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.e. their snapshot names should not change somehow because of this change if they are not using the ctx variable and are just using a string.
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.
They should work the same way, the mustache template compiler will return the same string value if there is no placeholder fields
val compiledValue = scriptService.compile(template, TemplateScript.CONTEXT) | ||
.newInstance(template.params + mapOf("ctx" to contextMap)) | ||
.execute() | ||
return if (compiledValue.isBlank()) defaultValue else compiledValue |
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.
When does compiledValue.isBlank() occur?
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.
if someone puts in a template with just a replaceable field and that is not valid e.g. {{ctx.name}}
or {{ctx.anything_not_allowed}}
this will be empty string
If someone specifies the template as {{ctx.anything_not_allowed}}_snapshot
then the compiled value is just _snapshot
If someone specifies the template as {ctx.anything_not_allowed}
since this is not a valid template placeholder it will be compiled as {ctx.anything_not_allowed}
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.
Hmm can someone specify an empty string as the snapshot name currently or do we block that?
i.e. if currently sameone has "" and it's allowed then instead of "" + the postfix stuff it'll change to $indexName + postfix stuff (since it looks like we add the index name as the default to use if this returns blank)
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.
good point, there is no check for it being non empty at the moment the field needs to be present in the policy but it can be empty string.
I can update the default value to empty string in that case - i.e if the original name is empty string
Signed-off-by: Ravi Thaluru <[email protected]>
* Add integTest script to the repo (#94) Signed-off-by: Peter Zhu <[email protected]> * Removing Usages of Action Get Call and using listeners (#100) Signed-off-by: Aditya Jindal <[email protected]> * Enhance ISM template (#105) Signed-off-by: bowenlan-amzn <[email protected]> * Explain response still use old opendistro policy id (#109) * Explain response still use old opendistro policy id * Use hardcoded policyid setting in tests for explain response * Trying to fix flaky tests * Storing user information as part of the job when security plugin is installed (#113) Signed-off-by: Ravi Thaluru <[email protected]> * ISM/Notification channel support (#117) * Updates NAME of transport actions * Upgrades Kotlin version, updates dependencies on other OS plugins, adds notification plugin as a test resource and includes it in test clusters * Adds support for Channels in error notifications and notification actions * Adds support for sending notifications to channels * Adds support for publishing notifications to the legacy destinations through the Notification plugin and some cleanup * Removes notification alerting jar dependency * Adds compile only dep on commons codec for digest utils sha1 method in ism rollup * Updates Error Notification to make channel/destination nullable, and adds helper methods for publish calls * Constructs URL for legacy custom webhook Signed-off-by: Drew Baugher <[email protected]> * Fixes Feature enum and dep Signed-off-by: Drew Baugher <[email protected]> * Trying something else Signed-off-by: Drew Baugher <[email protected]> * Addresses comments Signed-off-by: Drew Baugher <[email protected]> * Storing user object in all APIs and enabling filter of response based on user (#115) Signed-off-by: Ravi Thaluru <[email protected]> * Upgrade dependencies to 1.1 and build snapshot by default. (#121) Signed-off-by: dblock <[email protected]> * Security improvements (#126) Signed-off-by: Ravi Thaluru <[email protected]> * Removes support for notification plugin (#136) Signed-off-by: Drew Baugher <[email protected]> * Updating security filtering logic (#137) Signed-off-by: Ravi Thaluru <[email protected]> * Release note for 1.1.0.0 release. (#139) * Release note for 1.1.0.0 release. Signed-off-by: bowenlan-amzn <[email protected]> * Correct copyright notices * Uses published daily snapshot dependencies (#141) Signed-off-by: Drew Baugher <[email protected]> * License header check (#142) * Provide default copyright header using IDE feature Signed-off-by: bowenlan-amzn <[email protected]> * Address #103 history write index is rolled over even if the history indices are disabled * Removed integtest.sh. (#148) Signed-off-by: dblock <[email protected]> * Adds mavenLocal back to repositories (#158) Signed-off-by: Drew Baugher <[email protected]> * Making snapshot name to scripted input in template (#77) Signed-off-by: Ravi Thaluru <[email protected]> * Fix issues with security changes in rollup runnner (#161) * Updates index management version to 1.2 (#157) * Updates index management version to 1.2 * Updates job scheduler snapshot to 1.2 in test resources Signed-off-by: Robert Downs <[email protected]> * Adds setting to search all rollup jobs on a target index (#165) * Adds cluster setting to search all rollup jobs Signed-off-by: Clay Downs <[email protected]> * Adds implementation for the delay feature in rollup jobs (#147) * Adds delay implementation for rollup jobs * Removes non-continuous delay implementation * Adds additional rollup delay tests Signed-off-by: Clay Downs <[email protected]> * Updates testCompile mockito version, adds AwaitsFix annotation to MetadataRegressionIT tests (#168) * Updates testCompile mockito version to match OpenSearch changes * AwaitsFix on the failing MetadataRegressionIT tests Signed-off-by: Robert Downs <[email protected]> * Adds cluster setting to configure index state management jitter (#153) * Adds jitter cluster setting, sets jitter to 0 for ISM tests Signed-off-by: Clay Downs <[email protected]> * Allows out of band rollovers on an index without causing ISM to fail (#180) * Allows out of band rollovers on an index without causing ISM to fail Signed-off-by: Drew Baugher <[email protected]> * Fixes detekt issue Signed-off-by: Drew Baugher <[email protected]> * Remove policy API on read only indices (#182) * In explain API not showing the total count to all users (#185) Co-authored-by: Peter Zhu <[email protected]> Co-authored-by: Aditya Jindal <[email protected]> Co-authored-by: Bowen Lan <[email protected]> Co-authored-by: Ravi <[email protected]> Co-authored-by: Drew Baugher <[email protected]> Co-authored-by: Daniel Doubrovkine (dB.) <[email protected]>
…t#77) Signed-off-by: Ravi Thaluru <[email protected]>
Signed-off-by: Ravi Thaluru [email protected]
Issue #, if available:
https://discuss.opendistrocommunity.dev/t/universal-snapshot-policy-for-all-indexes/4815
Description of changes:
Processing snapshot field as a script instead of string so snapshot name can be derived from run time context - the two attributes supported during runtime are index and indexuuid
CheckList:
[X] Commits are signed per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.