Skip to content

fix(featuregate): make feature gate independent of controller#426

Merged
kmova merged 2 commits intoopenebs-archive:masterfrom
akhilerm:global-feature-gate
May 28, 2020
Merged

fix(featuregate): make feature gate independent of controller#426
kmova merged 2 commits intoopenebs-archive:masterfrom
akhilerm:global-feature-gate

Conversation

@akhilerm
Copy link
Copy Markdown
Contributor

@akhilerm akhilerm commented May 22, 2020

Signed-off-by: Akhil Mohan akhil.mohan@mayadata.io

Why is this PR required? What issue does it fix?:
The feature gate used to be a part of the daemon controller. This restricted its use to only code paths which had access to the controller pointer. This PR removes the dependency of feature gates on the daemon controller and can be used globally across the code base.

What this PR does?:

  • adds a new exporter variable FeatureGates in features package which holds the state of all features.
  • remove feature gate from daemon controller

Does this PR require any upgrade changes?:
No

If the changes in this PR are manually verified, list down the scenarios covered::

  • tested by providing a set of correct and incorrect feature gates.

Any additional information for your reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

  • Fixes #
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Has the change log section been updated?
  • Commit has unit tests
  • Commit has integration tests
  • (Optional) Are upgrade changes included in this PR? If not, mention the issue/PR to track:
  • (Optional) If documentation changes are required, which issue on https://github.com/openebs/openebs-docs is used to track them:

@akhilerm akhilerm added the pr/hold-review Needs rework. label May 22, 2020
@akhilerm akhilerm force-pushed the global-feature-gate branch from 42ea84e to 0a0e057 Compare May 22, 2020 11:04
make feature gate independent of controller. Now the feature gate can be accessed via
a global feature gate variable. This enables to use the feature in all code paths even
if it is independent of the controller.

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
@akhilerm akhilerm force-pushed the global-feature-gate branch from 0a0e057 to dd99228 Compare May 26, 2020 11:27
@akhilerm akhilerm removed the pr/hold-review Needs rework. label May 26, 2020
@akhilerm akhilerm requested a review from kmova May 26, 2020 11:46
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 26, 2020

Codecov Report

Merging #426 into master will decrease coverage by 0.44%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #426      +/-   ##
==========================================
- Coverage   44.35%   43.90%   -0.45%     
==========================================
  Files          60       60              
  Lines        2859     2906      +47     
==========================================
+ Hits         1268     1276       +8     
- Misses       1489     1526      +37     
- Partials      102      104       +2     
Impacted Files Coverage Δ
cmd/ndm_daemonset/controller/controller.go 20.56% <0.00%> (+2.20%) ⬆️
cmd/ndm_daemonset/probe/udevprobe.go 60.56% <0.00%> (-2.82%) ⬇️
cmd/ndm_daemonset/probe/eventhandler.go 10.82% <100.00%> (-1.55%) ⬇️
pkg/features/features.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e3ffc9...2213c64. Read the comment docs.

Comment thread pkg/features/features.go Outdated

// DefaultFeatureGate is the global feature gate that can be used to check if a feature is enabled
// or disabled
var DefaultFeatureGates = NewFeatureGate()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

n_: DefaultFeatureGates => FeatureGates or a generic name as it contains both default and those enabled via ENV etc,. right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FeatureGates was not used because there is already a FeatureGate type in the same package.

Do you have suggestion for any other generic names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FeatureGate will renamed to featureFlag, and DefaultFeatureGates to FeatureGates

- rename FeatureGate type to featureFlag
- rename DefaultFeatureGates to FeatureGates

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
@akhilerm akhilerm requested a review from kmova May 27, 2020 18:08
@kmova kmova merged commit 3562709 into openebs-archive:master May 28, 2020
@akhilerm akhilerm deleted the global-feature-gate branch December 13, 2021 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants