diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 70a4dcfdae9..97781c967bb 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -191,6 +191,7 @@ Experimental features might be changed or removed without prior notice. | `databaseReadReplica` | Use a read replica for some database queries. | | `alertingApiServer` | Register Alerting APIs with the K8s API server | | `dashboardRestoreUI` | Enables the frontend to be able to restore a recently deleted dashboard | +| `backgroundPluginInstaller` | Enable background plugin installer | | `dataplaneAggregator` | Enable grafana dataplane aggregator | | `adhocFilterOneOf` | Exposes a new 'one of' operator for ad-hoc filters. This operator allows users to filter by multiple values in a single filter. | diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index ec4c39521c1..20a0390eeb4 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -200,6 +200,7 @@ export interface FeatureToggles { bodyScrolling?: boolean; cloudwatchMetricInsightsCrossAccount?: boolean; prometheusAzureOverrideAudience?: boolean; + backgroundPluginInstaller?: boolean; dataplaneAggregator?: boolean; adhocFilterOneOf?: boolean; } diff --git a/pkg/registry/backgroundsvcs/background_services.go b/pkg/registry/backgroundsvcs/background_services.go index 4333bfebd04..fe193b09d7f 100644 --- a/pkg/registry/backgroundsvcs/background_services.go +++ b/pkg/registry/backgroundsvcs/background_services.go @@ -29,6 +29,7 @@ import ( "github.com/grafana/grafana/pkg/services/pluginsintegration/angulardetectorsprovider" "github.com/grafana/grafana/pkg/services/pluginsintegration/keyretriever/dynamic" "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginexternal" + "github.com/grafana/grafana/pkg/services/pluginsintegration/plugininstaller" pluginStore "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore" "github.com/grafana/grafana/pkg/services/provisioning" publicdashboardsmetric "github.com/grafana/grafana/pkg/services/publicdashboards/metric" @@ -63,6 +64,7 @@ func ProvideBackgroundServiceRegistry( anon *anonimpl.AnonDeviceService, ssoSettings *ssosettingsimpl.Service, pluginExternal *pluginexternal.Service, + pluginInstaller *plugininstaller.Service, // Need to make sure these are initialized, is there a better place to put them? _ dashboardsnapshots.Service, _ serviceaccounts.Service, _ *guardian.Provider, @@ -105,6 +107,7 @@ func ProvideBackgroundServiceRegistry( anon, ssoSettings, pluginExternal, + pluginInstaller, ) } diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 9690b54ba1f..942bbe4a61a 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -1379,6 +1379,13 @@ var ( Owner: grafanaPartnerPluginsSquad, Expression: "true", // Enabled by default for now }, + { + Name: "backgroundPluginInstaller", + Description: "Enable background plugin installer", + Stage: FeatureStageExperimental, + Owner: grafanaPluginsPlatformSquad, + RequiresRestart: true, + }, { Name: "dataplaneAggregator", Description: "Enable grafana dataplane aggregator", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index f866c897069..415fdd789ca 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -181,5 +181,6 @@ cloudWatchRoundUpEndTime,GA,@grafana/aws-datasources,false,false,false bodyScrolling,preview,@grafana/grafana-frontend-platform,false,false,true cloudwatchMetricInsightsCrossAccount,preview,@grafana/aws-datasources,false,false,true prometheusAzureOverrideAudience,deprecated,@grafana/partner-datasources,false,false,false +backgroundPluginInstaller,experimental,@grafana/plugins-platform-backend,false,true,false dataplaneAggregator,experimental,@grafana/grafana-app-platform-squad,false,true,false adhocFilterOneOf,experimental,@grafana/dashboards-squad,false,false,false diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 1aa69d2517b..ac06c13d7e2 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -735,6 +735,10 @@ const ( // Deprecated. Allow override default AAD audience for Azure Prometheus endpoint. Enabled by default. This feature should no longer be used and will be removed in the future. FlagPrometheusAzureOverrideAudience = "prometheusAzureOverrideAudience" + // FlagBackgroundPluginInstaller + // Enable background plugin installer + FlagBackgroundPluginInstaller = "backgroundPluginInstaller" + // FlagDataplaneAggregator // Enable grafana dataplane aggregator FlagDataplaneAggregator = "dataplaneAggregator" diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index e4be36069f0..ede7702b5a5 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -529,6 +529,19 @@ "codeowner": "@grafana/partner-datasources" } }, + { + "metadata": { + "name": "backgroundPluginInstaller", + "resourceVersion": "1723202510081", + "creationTimestamp": "2024-08-09T11:21:50Z" + }, + "spec": { + "description": "Enable background plugin installer", + "stage": "experimental", + "codeowner": "@grafana/plugins-platform-backend", + "requiresRestart": true + } + }, { "metadata": { "name": "bodyScrolling", diff --git a/pkg/services/pluginsintegration/plugininstaller/service.go b/pkg/services/pluginsintegration/plugininstaller/service.go new file mode 100644 index 00000000000..31d9127eb36 --- /dev/null +++ b/pkg/services/pluginsintegration/plugininstaller/service.go @@ -0,0 +1,32 @@ +package plugininstaller + +import ( + "context" + + "github.com/grafana/grafana/pkg/infra/log" + "github.com/grafana/grafana/pkg/services/featuremgmt" + "github.com/grafana/grafana/pkg/setting" +) + +type Service struct { + features featuremgmt.FeatureToggles + log log.Logger +} + +func ProvideService(cfg *setting.Cfg, features featuremgmt.FeatureToggles) *Service { + s := &Service{ + features: features, + log: log.New("plugin.installer"), + } + return s +} + +// IsDisabled disables background installation of plugins. +func (s *Service) IsDisabled() bool { + return !s.features.IsEnabled(context.Background(), featuremgmt.FlagBackgroundPluginInstaller) +} + +func (s *Service) Run(ctx context.Context) error { + s.log.Debug("PluginInstaller.Run not implemented") + return nil +} diff --git a/pkg/services/pluginsintegration/plugininstaller/service_test.go b/pkg/services/pluginsintegration/plugininstaller/service_test.go new file mode 100644 index 00000000000..09ad3dfdfa6 --- /dev/null +++ b/pkg/services/pluginsintegration/plugininstaller/service_test.go @@ -0,0 +1,20 @@ +package plugininstaller + +import ( + "testing" + + "github.com/grafana/grafana/pkg/services/featuremgmt" +) + +// Test if the service is disabled +func TestService_IsDisabled(t *testing.T) { + // Create a new service + s := &Service{ + features: featuremgmt.WithFeatures(featuremgmt.FlagBackgroundPluginInstaller), + } + + // Check if the service is disabled + if s.IsDisabled() { + t.Error("Service should be enabled") + } +} diff --git a/pkg/services/pluginsintegration/pluginsintegration.go b/pkg/services/pluginsintegration/pluginsintegration.go index 64262eecede..bf0e7705fc0 100644 --- a/pkg/services/pluginsintegration/pluginsintegration.go +++ b/pkg/services/pluginsintegration/pluginsintegration.go @@ -47,6 +47,7 @@ import ( "github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext" "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs" "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginexternal" + "github.com/grafana/grafana/pkg/services/pluginsintegration/plugininstaller" "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings" pluginSettings "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings/service" "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore" @@ -124,6 +125,7 @@ var WireSet = wire.NewSet( pluginexternal.ProvideService, plugincontext.ProvideBaseService, wire.Bind(new(plugincontext.BasePluginContextProvider), new(*plugincontext.BaseProvider)), + plugininstaller.ProvideService, ) // WireExtensionSet provides a wire.ProviderSet of plugin providers that can be