Skip to content

Clarify autoscaling feature flag registration #54427

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

Conversation

jasontedor
Copy link
Member

@jasontedor jasontedor commented Mar 30, 2020

This commit clarifies the autoscaling feature flag registration system property. The intention is that this system property is:

  • unset in snapshot builds
  • unset, true, or false in release builds
  • in release builds, unset behaves the same as false
  • therefore, we only register the enabled flag if the build is a snapshot build, or the build is a release build and the system property is set to true

This commit clarifies that intention, and removed a confusion situation where the AUTOSCALING_FEATURE_FLAG_REGISTERED field would be set to false in a snapshot build, even though we were going to register the setting.

Relates #52088

This commit clarifies the autoscaling feature flag registration system
property. The intention is that this feature flag is:
 - unset in snapshot builds
 - unset, true, or false in release builds
 - in release builds, unset behaves the same as false
 - therefore, we only register the enabled flag if the build is a
   snapshot build, or the build is a release build and the system
   property is set to true

This commit clarifies that intention, and removed a confusion situation
where the AUTOSCALING_FEATURE_FLAG_REGISTERED field would be set to
false in a snapshot build, even though we were going to register the
setting.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Autoscaling)

@jasontedor jasontedor requested a review from DaveCTurner March 30, 2020 14:13
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a suggestion.

AUTOSCALING_FEATURE_FLAG_REGISTERED = false;
} else if (property == null) {
AUTOSCALING_FEATURE_FLAG_REGISTERED = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest leaving it as a non-nullable boolean and saying this here.

Suggested change
AUTOSCALING_FEATURE_FLAG_REGISTERED = null;
AUTOSCALING_FEATURE_FLAG_REGISTERED = Build.CURRENT.isSnapshot();

Then this flag exactly reflects whether the feature flag is registered or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two issues with that suggestion:

  • my intention is that the field is aligned with the value of the system property es.autoscaling_feature_flag_registered, it's merely a Boolean representation of the value of that system property
  • the intention of using Autoscaling#isSnapshot in determining whether or not to register the setting is so that it can be overridden in tests; if we tie whether or not to register the setting directly to Build#Current#isSnapshot as you suggest, we lose that ability

@@ -69,7 +71,7 @@ public Autoscaling(final Settings settings) {
*/
@Override
public List<Setting<?>> getSettings() {
if (isSnapshot() || AUTOSCALING_FEATURE_FLAG_REGISTERED) {
if (isSnapshot() || (AUTOSCALING_FEATURE_FLAG_REGISTERED != null && AUTOSCALING_FEATURE_FLAG_REGISTERED)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my previous suggestion, this simplifies to the following:

Suggested change
if (isSnapshot() || (AUTOSCALING_FEATURE_FLAG_REGISTERED != null && AUTOSCALING_FEATURE_FLAG_REGISTERED)) {
if (AUTOSCALING_FEATURE_FLAG_REGISTERED) {

@jasontedor jasontedor requested a review from DaveCTurner March 30, 2020 14:55
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, the penny drops. I had not spotted that isSnapshot() is overridden by tests. It all makes sense now.

LGTM

@jasontedor
Copy link
Member Author

@elasticmachine update branch

@jasontedor jasontedor merged commit 9600073 into elastic:master Mar 31, 2020
jasontedor added a commit that referenced this pull request Mar 31, 2020
This commit clarifies the autoscaling feature flag registration system
property. The intention is that this system property is:
 - unset in snapshot builds
 - unset, true, or false in release builds
 - in release builds, unset behaves the same as false
 - therefore, we only register the enabled flag if the build is a
   snapshot build, or the build is a release build and the system
   property is set to true

This commit clarifies that intention, and removed a confusion situation
where the AUTOSCALING_FEATURE_FLAG_REGISTERED field would be set to
false in a snapshot build, even though we were going to register the
setting.
@jasontedor jasontedor deleted the autoscaling-feature-flag-registration-clarification branch March 31, 2020 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants