Adds the replication type index setting, alongside a formal notion of feature flags#3037
Conversation
|
❌ Gradle Check failure 3fdfd117578a5d053ae6e3a389b2cdd35b1f663f |
nknize
left a comment
There was a problem hiding this comment.
🎉 🎉 Love to see the progress toward feature flags!!! Thinking we could maybe add a FeatureFlag utility class as a home for future flags?
There was a problem hiding this comment.
Maybe we can create a new FeatureFlag utility class?
|
This is odd!!! I sure hope the maven repo endpoint is still accessible and someone didn't blow it away! /cc @mch2 |
|
start gradle check |
|
❌ Gradle Check failure 3fdfd117578a5d053ae6e3a389b2cdd35b1f663f |
|
Maybe try adding to code-coverage.gradle? This was recently changed so I don't know if it ever picked up the snapshot repository? /cc @reta can you verify? |
|
@nknize for some reasons |
Signed-off-by: Kartik Ganesh <gkart@amazon.com>
3fdfd11 to
ae9fcfd
Compare
|
@kartg I just rebased w/ latest updates to main. 🤞 it passes lucene library retrieval |
In addition to centralizing the feature flag definitions and logic, this also allows us to centralize the checking of feature flags and corresponding addition of feature-flagged index settings into IndexScopedSettings. Signed-off-by: Kartik Ganesh <gkart@amazon.com>
|
Still a WIP:
|
Also incorporates PR feedback about the feature flag scope and naming Signed-off-by: Kartik Ganesh <gkart@amazon.com>
I forgot that valueOf parses the name of the enum and not its value. Signed-off-by: Kartik Ganesh <gkart@amazon.com>
Signed-off-by: Kartik Ganesh <gkart@amazon.com>
| * is ready for production release, the feature flag can be removed, and the | ||
| * setting should be moved to {@link #BUILT_IN_INDEX_SETTINGS}. | ||
| */ | ||
| public static final Map<String, Setting> FEATURE_FLAGGED_INDEX_SETTINGS = Map.of( |
There was a problem hiding this comment.
Note - Map.of is only available from Java 9+
There was a problem hiding this comment.
This shouldn't be an issue since we have to remain 11+ due to lucene 9.
isSegRepEnabled is now computed on the fly by testing the stored ReplicationType value Signed-off-by: Kartik Ganesh <gkart@amazon.com>
|
|
||
| import org.opensearch.test.OpenSearchTestCase; | ||
|
|
||
| public class FeatureFlagTests extends OpenSearchTestCase { |
There was a problem hiding this comment.
I realize that these unit tests are rudimentary and don't actually test the isEnabled == true code path for FeatureFlags. I wasn't able to use System.setProperty - it gets flagged as a forbidden API. I would appreciate suggestions on how I could achieve better test coverage.
There was a problem hiding this comment.
I pushed a commit that grants write permissions on opensearch.experimental.feature.* so we can test the flags accordingly.
| * Returns true if segment replication is enabled on the index. | ||
| */ | ||
| public boolean isSegrepEnabled() { | ||
| return Boolean.TRUE.equals(isSegRepEnabled); |
There was a problem hiding this comment.
I think this can just be return isSegRepEnabled? Also probably make 'R' uppercase in the method name to be consistent.
There was a problem hiding this comment.
sorry, I'll stop commenting until you move this out of draft :)
There was a problem hiding this comment.
The logic in this method has changed with the latest commit - IndexSettings now stores the replication type itself rather than storing a boolean.
That said, I do like SegRep better than Segrep so i'll change the method name 😏
Also, feel free to leave early comments - I think this change is just about finalized anyway
Signed-off-by: Kartik Ganesh <gkart@amazon.com>
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
nknize
left a comment
There was a problem hiding this comment.
This first version looks good to me! Added a commit to correctly test the feature flags.
| * and false otherwise. | ||
| */ | ||
| public static boolean isEnabled(String featureFlagName) { | ||
| return "true".equalsIgnoreCase(System.getProperty(featureFlagName)); |
There was a problem hiding this comment.
| return "true".equalsIgnoreCase(System.getProperty(featureFlagName)); | |
| return "true".equalsIgnoreCase(System.getProperty(featureFlagName)) || Build.CURRENT.isSnapshot(); |
It might be nice to auto enable for snapshot builds? Doing this, though, will most certainly fail the FeatureFlag tests the way they are currently written.
|
|
||
| import org.opensearch.test.OpenSearchTestCase; | ||
|
|
||
| public class FeatureFlagTests extends OpenSearchTestCase { |
There was a problem hiding this comment.
I pushed a commit that grants write permissions on opensearch.experimental.feature.* so we can test the flags accordingly.
|
Another #1703 |
|
start gradle check |
|
This is great! I like where this PR is at as an incremental step. Especially since it introduces the feature flag mechanism. That will be huge for avoiding those long running feature branches and living in merge hell. I think we should consider enabling all feature flags as the default for snapshot builds but that can be done in a follow up PR after a discussion on if / how we want to do that. Since this is out of WIP status I think it's ready for your final review @andrross. |
I'd prefer to do this in a follow-up PR, after a discussion. Given that we're currently using the feature flag to hide seg-rep as we slowly merge in changes, I'm nervous about having the setting visible by default in snapshot builds, and users assuming the feature is functional. That said, I recognize that the |
… feature flags (#3037) * This change formalizes the notion of feature flags, and adds a "replication type" setting that will differentiate between document and segment replication, gated by a feature flag. Since seg-rep is currently an incomplete implementation, the feature flag ensures that the setting is not visible to users without explicitly setting a system property. We can then continue to merge seg-rep related changes from the feature branch to `main` safely hidden behind the feature flag gate. Signed-off-by: Kartik Ganesh <gkart@amazon.com> * Update security policy for testing feature flags Signed-off-by: Nicholas Walter Knize <nknize@apache.org> Co-authored-by: Nicholas Walter Knize <nknize@apache.org> (cherry picked from commit ee7b731)
… feature flags (#3037) (#3071) * This change formalizes the notion of feature flags, and adds a "replication type" setting that will differentiate between document and segment replication, gated by a feature flag. Since seg-rep is currently an incomplete implementation, the feature flag ensures that the setting is not visible to users without explicitly setting a system property. We can then continue to merge seg-rep related changes from the feature branch to `main` safely hidden behind the feature flag gate. Signed-off-by: Kartik Ganesh <gkart@amazon.com> * Update security policy for testing feature flags Signed-off-by: Nicholas Walter Knize <nknize@apache.org> Co-authored-by: Nicholas Walter Knize <nknize@apache.org> (cherry picked from commit ee7b731) Co-authored-by: Kartik Ganesh <gkart@amazon.com>
Signed-off-by: Kartik Ganesh gkart@amazon.com
Description
This change formalizes the notion of feature flags, and adds a "replication type" setting that will differentiate between document and segment replication, gated by a feature flag.
Since seg-rep is currently an incomplete implementation, the feature flag ensures that the setting is not visible to users without explicitly setting a system property. We can then continue to merge seg-rep related changes from the feature branch to
mainsafely hidden behind the feature flag gate.The ReplicationType setting is represented as an enum. Its default value is
DOCUMENT.Issues Resolved
[List any issues this PR will resolve]
Check List
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.