-
Notifications
You must be signed in to change notification settings - Fork 1.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
Adds the replication type index setting, alongside a formal notion of feature flags #3037
Adds the replication type index setting, alongside a formal notion of feature flags #3037
Conversation
❌ Gradle Check failure 3fdfd117578a5d053ae6e3a389b2cdd35b1f663f |
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.
🎉 🎉 Love to see the progress toward feature flags!!! Thinking we could maybe add a FeatureFlag utility class as a home for future flags?
* Feature flag to gate the visibility of the index setting that enables segment replication. | ||
* Once the feature is ready for production release, this feature flag can be removed. | ||
*/ | ||
public static final boolean SEGREP_FEATURE_FLAG_ENABLED = "true".equals( |
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.
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 <[email protected]>
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 <[email protected]>
Still a WIP:
|
server/src/main/java/org/opensearch/common/util/FeatureFlags.java
Outdated
Show resolved
Hide resolved
Also incorporates PR feedback about the feature flag scope and naming Signed-off-by: Kartik Ganesh <[email protected]>
I forgot that valueOf parses the name of the enum and not its value. Signed-off-by: Kartik Ganesh <[email protected]>
Signed-off-by: Kartik Ganesh <[email protected]>
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note - Map.of
is only available from Java 9+
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 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 <[email protected]>
|
||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
public class FeatureFlagTests extends OpenSearchTestCase { |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I'll stop commenting until you move this out of draft :)
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 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 <[email protected]>
Signed-off-by: Nicholas Walter Knize <[email protected]>
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> * Update security policy for testing feature flags Signed-off-by: Nicholas Walter Knize <[email protected]> Co-authored-by: Nicholas Walter Knize <[email protected]> (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 <[email protected]> * Update security policy for testing feature flags Signed-off-by: Nicholas Walter Knize <[email protected]> Co-authored-by: Nicholas Walter Knize <[email protected]> (cherry picked from commit ee7b731) Co-authored-by: Kartik Ganesh <[email protected]>
Signed-off-by: Kartik Ganesh [email protected]
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
main
safely 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.