mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Removed feature toggle pluginsDynamicAngularDetectionPatterns (#85956)
* Plugins: Removed feature toggle pluginsDynamicAngularDetectionPatterns * re-generate feature toggles
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins/log"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/loader/angular/angulardetector"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/angularpatternsstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -31,10 +30,8 @@ var (
|
||||
// Dynamic is an angulardetector.DetectorsProvider that calls GCOM to get Angular detection patterns,
|
||||
// converts them to detectors and caches them for all future calls.
|
||||
// It also provides a background service that will periodically refresh the patterns from GCOM.
|
||||
// If the feature flag FlagPluginsDynamicAngularDetectionPatterns is disabled, the background service is disabled.
|
||||
type Dynamic struct {
|
||||
log log.Logger
|
||||
features featuremgmt.FeatureToggles
|
||||
log log.Logger
|
||||
|
||||
httpClient http.Client
|
||||
baseURL string
|
||||
@@ -53,7 +50,7 @@ type Dynamic struct {
|
||||
backgroundJobInterval time.Duration
|
||||
}
|
||||
|
||||
func ProvideDynamic(cfg *setting.Cfg, store angularpatternsstore.Service, features featuremgmt.FeatureToggles) (*Dynamic, error) {
|
||||
func ProvideDynamic(cfg *setting.Cfg, store angularpatternsstore.Service) (*Dynamic, error) {
|
||||
backgroundJobInterval := backgroundJobIntervalOnPrem
|
||||
if cfg.StackID != "" {
|
||||
// Use a shorter interval for cloud.
|
||||
@@ -63,16 +60,11 @@ func ProvideDynamic(cfg *setting.Cfg, store angularpatternsstore.Service, featur
|
||||
|
||||
d := &Dynamic{
|
||||
log: log.New("plugin.angulardetectorsprovider.dynamic"),
|
||||
features: features,
|
||||
store: store,
|
||||
httpClient: makeHttpClient(),
|
||||
baseURL: cfg.GrafanaComURL,
|
||||
backgroundJobInterval: backgroundJobInterval,
|
||||
}
|
||||
if d.IsDisabled() {
|
||||
// Do not attempt to restore if the background service is disabled (no feature flag)
|
||||
return d, nil
|
||||
}
|
||||
d.log.Debug("Providing dynamic angular detection patterns", "baseURL", d.baseURL, "interval", d.backgroundJobInterval)
|
||||
|
||||
// Perform the initial restore from db
|
||||
@@ -233,11 +225,6 @@ func (d *Dynamic) setDetectorsFromCache(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsDisabled returns true if FlagPluginsDynamicAngularDetectionPatterns is not enabled.
|
||||
func (d *Dynamic) IsDisabled() bool {
|
||||
return !d.features.IsEnabledGlobally(featuremgmt.FlagPluginsDynamicAngularDetectionPatterns)
|
||||
}
|
||||
|
||||
// randomSkew returns a random time.Duration between 0 and maxSkew.
|
||||
// This can be added to d.backgroundJobInterval to skew it by a random amount.
|
||||
func (d *Dynamic) randomSkew(maxSkew time.Duration) time.Duration {
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/kvstore"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/loader/angular/angulardetector"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/angularpatternsstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -343,18 +342,6 @@ func TestDynamicAngularDetectorsProviderBackgroundService(t *testing.T) {
|
||||
backgroundJobIntervalOnPrem = oldBackgroundJobInterval
|
||||
})
|
||||
|
||||
t.Run("is disabled if feature flag is not present", func(t *testing.T) {
|
||||
svc := provideDynamic(t, srv.URL)
|
||||
svc.features = featuremgmt.WithFeatures()
|
||||
require.True(t, svc.IsDisabled(), "background service should be disabled")
|
||||
})
|
||||
|
||||
t.Run("is enabled if feature flag is present", func(t *testing.T) {
|
||||
svc := provideDynamic(t, srv.URL)
|
||||
svc.features = featuremgmt.WithFeatures(featuremgmt.FlagPluginsDynamicAngularDetectionPatterns)
|
||||
require.False(t, svc.IsDisabled(), "background service should be enabled")
|
||||
})
|
||||
|
||||
t.Run("fetches value from gcom on start if too much time has passed", func(t *testing.T) {
|
||||
gcomCallback := make(chan struct{})
|
||||
gcom := newDefaultGCOMScenario(func(_ http.ResponseWriter, _ *http.Request) {
|
||||
@@ -594,11 +581,7 @@ func provideDynamic(t *testing.T, gcomURL string, opts ...provideDynamicOpts) *D
|
||||
opt.cfg = setting.NewCfg()
|
||||
}
|
||||
opt.cfg.GrafanaComURL = gcomURL
|
||||
d, err := ProvideDynamic(
|
||||
opt.cfg,
|
||||
opt.store,
|
||||
featuremgmt.WithFeatures(featuremgmt.FlagPluginsDynamicAngularDetectionPatterns),
|
||||
)
|
||||
d, err := ProvideDynamic(opt.cfg, opt.store)
|
||||
require.NoError(t, err)
|
||||
return d
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user