mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Provisioning: Revert "Allow startup when there are dashboard provisioning failures" (#92568)
Revert "Provisioning: Allow startup when there are dashboard provisioning failures (#92201)"
This reverts commit 927ce6c700
.
This commit is contained in:
parent
1eb49e1b0f
commit
c5b377f06e
@ -122,7 +122,6 @@ func newProvisioningServiceImpl(
|
|||||||
newDashboardProvisioner dashboards.DashboardProvisionerFactory,
|
newDashboardProvisioner dashboards.DashboardProvisionerFactory,
|
||||||
provisionDatasources func(context.Context, string, datasources.BaseDataSourceService, datasources.CorrelationsStore, org.Service) error,
|
provisionDatasources func(context.Context, string, datasources.BaseDataSourceService, datasources.CorrelationsStore, org.Service) error,
|
||||||
provisionPlugins func(context.Context, string, pluginstore.Store, pluginsettings.Service, org.Service) error,
|
provisionPlugins func(context.Context, string, pluginstore.Store, pluginsettings.Service, org.Service) error,
|
||||||
searchService searchV2.SearchService,
|
|
||||||
) *ProvisioningServiceImpl {
|
) *ProvisioningServiceImpl {
|
||||||
return &ProvisioningServiceImpl{
|
return &ProvisioningServiceImpl{
|
||||||
log: log.New("provisioning"),
|
log: log.New("provisioning"),
|
||||||
@ -130,7 +129,6 @@ func newProvisioningServiceImpl(
|
|||||||
provisionDatasources: provisionDatasources,
|
provisionDatasources: provisionDatasources,
|
||||||
provisionPlugins: provisionPlugins,
|
provisionPlugins: provisionPlugins,
|
||||||
Cfg: setting.NewCfg(),
|
Cfg: setting.NewCfg(),
|
||||||
searchService: searchService,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +185,7 @@ func (ps *ProvisioningServiceImpl) Run(ctx context.Context) error {
|
|||||||
err := ps.ProvisionDashboards(ctx)
|
err := ps.ProvisionDashboards(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ps.log.Error("Failed to provision dashboard", "error", err)
|
ps.log.Error("Failed to provision dashboard", "error", err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
if ps.dashboardProvisioner.HasDashboardSources() {
|
if ps.dashboardProvisioner.HasDashboardSources() {
|
||||||
ps.searchService.TriggerReIndex()
|
ps.searchService.TriggerReIndex()
|
||||||
|
@ -3,7 +3,6 @@ package provisioning
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/org"
|
"github.com/grafana/grafana/pkg/services/org"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
|
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning/utils"
|
"github.com/grafana/grafana/pkg/services/provisioning/utils"
|
||||||
"github.com/grafana/grafana/pkg/services/searchV2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProvisioningServiceImpl(t *testing.T) {
|
func TestProvisioningServiceImpl(t *testing.T) {
|
||||||
@ -68,27 +66,6 @@ func TestProvisioningServiceImpl(t *testing.T) {
|
|||||||
// Cancelling the root context and stopping the service
|
// Cancelling the root context and stopping the service
|
||||||
serviceTest.cancel()
|
serviceTest.cancel()
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Should not return run error when dashboard provisioning fails", func(t *testing.T) {
|
|
||||||
serviceTest := setup(t)
|
|
||||||
provisioningErr := errors.New("Test error")
|
|
||||||
serviceTest.mock.ProvisionFunc = func(ctx context.Context) error {
|
|
||||||
return provisioningErr
|
|
||||||
}
|
|
||||||
err := serviceTest.service.ProvisionDashboards(context.Background())
|
|
||||||
assert.NotNil(t, err)
|
|
||||||
serviceTest.startService()
|
|
||||||
|
|
||||||
serviceTest.waitForPollChanges()
|
|
||||||
assert.Equal(t, 1, len(serviceTest.mock.Calls.PollChanges), "PollChanges should have been called")
|
|
||||||
|
|
||||||
// Cancelling the root context and stopping the service
|
|
||||||
serviceTest.cancel()
|
|
||||||
serviceTest.waitForStop()
|
|
||||||
|
|
||||||
fmt.Println("serviceTest.serviceError", serviceTest.serviceError)
|
|
||||||
assert.Equal(t, context.Canceled, serviceTest.serviceError)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceTestStruct struct {
|
type serviceTestStruct struct {
|
||||||
@ -118,15 +95,12 @@ func setup(t *testing.T) *serviceTestStruct {
|
|||||||
pollChangesChannel <- ctx
|
pollChangesChannel <- ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
searchStub := searchV2.NewStubSearchService()
|
|
||||||
|
|
||||||
serviceTest.service = newProvisioningServiceImpl(
|
serviceTest.service = newProvisioningServiceImpl(
|
||||||
func(context.Context, string, dashboardstore.DashboardProvisioningService, org.Service, utils.DashboardStore, folder.Service) (dashboards.DashboardProvisioner, error) {
|
func(context.Context, string, dashboardstore.DashboardProvisioningService, org.Service, utils.DashboardStore, folder.Service) (dashboards.DashboardProvisioner, error) {
|
||||||
return serviceTest.mock, nil
|
return serviceTest.mock, nil
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
searchStub,
|
|
||||||
)
|
)
|
||||||
err := serviceTest.service.setDashboardProvisioner()
|
err := serviceTest.service.setDashboardProvisioner()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user