Provisioning: Ensure that enterprise provisioning runs [10.1.x] (#76686)

revert https://github.com/grafana/grafana/pull/72608

(cherry picked from commit bb3e422365d95aa44a468bc71adfffa423bec65e)
This commit is contained in:
Ieva
2023-10-17 14:50:28 +01:00
committed by GitHub
parent 9835ffafb1
commit 2358ab0a85
7 changed files with 31 additions and 47 deletions
+24 -17
View File
@@ -19,6 +19,7 @@ import (
moduleRegistry "github.com/grafana/grafana/pkg/modules/registry"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/provisioning"
"github.com/grafana/grafana/pkg/setting"
)
@@ -33,13 +34,13 @@ type Options struct {
}
// New returns a new instance of Server.
func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry, provisioningService provisioning.ProvisioningService,
usageStatsProvidersRegistry registry.UsageStatsProvidersRegistry, statsCollectorService *statscollector.Service,
moduleService modules.Engine,
_ moduleRegistry.Registry, // imported to invoke initialization via Wire
) (*Server, error) {
statsCollectorService.RegisterProviders(usageStatsProvidersRegistry.GetServices())
s, err := newServer(opts, cfg, httpServer, roleRegistry, moduleService)
s, err := newServer(opts, cfg, httpServer, roleRegistry, provisioningService, moduleService)
if err != nil {
return nil, err
}
@@ -52,18 +53,19 @@ func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistr
}
func newServer(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
moduleService modules.Engine) (*Server, error) {
provisioningService provisioning.ProvisioningService, moduleService modules.Engine) (*Server, error) {
return &Server{
HTTPServer: httpServer,
roleRegistry: roleRegistry,
shutdownFinished: make(chan struct{}),
log: log.New("server"),
cfg: cfg,
pidFile: opts.PidFile,
version: opts.Version,
commit: opts.Commit,
buildBranch: opts.BuildBranch,
moduleService: moduleService,
HTTPServer: httpServer,
provisioningService: provisioningService,
roleRegistry: roleRegistry,
shutdownFinished: make(chan struct{}),
log: log.New("server"),
cfg: cfg,
pidFile: opts.PidFile,
version: opts.Version,
commit: opts.Commit,
buildBranch: opts.BuildBranch,
moduleService: moduleService,
}, nil
}
@@ -81,9 +83,10 @@ type Server struct {
commit string
buildBranch string
HTTPServer *api.HTTPServer
roleRegistry accesscontrol.RoleRegistry
moduleService modules.Engine
HTTPServer *api.HTTPServer
roleRegistry accesscontrol.RoleRegistry
provisioningService provisioning.ProvisioningService
moduleService modules.Engine
}
// init initializes the server and its services.
@@ -109,7 +112,11 @@ func (s *Server) init(ctx context.Context) error {
return err
}
return s.roleRegistry.RegisterFixedRoles(ctx)
if err := s.roleRegistry.RegisterFixedRoles(ctx); err != nil {
return err
}
return s.provisioningService.RunInitProvisioners(ctx)
}
// AwaitHealthy waits for the server to become healthy.
+1 -1
View File
@@ -15,7 +15,7 @@ import (
func testServer(t *testing.T, m *modules.MockModuleEngine) *Server {
t.Helper()
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, m)
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, nil, m)
require.NoError(t, err)
// Required to skip configuration initialization that causes
// DI errors in this test.