Commit c8382ba4 by Augustin Husson Committed by Carl Bergquist

Provisioning: Support folder that doesn't exist yet in dashboard provisioning (#17407)

closes #17320
parent 87760d4f
...@@ -3,6 +3,7 @@ package dashboards ...@@ -3,6 +3,7 @@ package dashboards
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/util/errutil" "github.com/grafana/grafana/pkg/util/errutil"
...@@ -38,8 +39,13 @@ func NewDashboardProvisionerImpl(configDirectory string) (*DashboardProvisionerI ...@@ -38,8 +39,13 @@ func NewDashboardProvisionerImpl(configDirectory string) (*DashboardProvisionerI
func (provider *DashboardProvisionerImpl) Provision() error { func (provider *DashboardProvisionerImpl) Provision() error {
for _, reader := range provider.fileReaders { for _, reader := range provider.fileReaders {
err := reader.startWalkingDisk() if err := reader.startWalkingDisk(); err != nil {
if err != nil { if os.IsNotExist(err) {
// don't stop the provisioning service in case the folder is missing. The folder can appear after the startup
provider.log.Warn("Failed to provision config", "name", reader.Cfg.Name, "error", err)
return nil
}
return errutil.Wrapf(err, "Failed to provision config %v", reader.Cfg.Name) return errutil.Wrapf(err, "Failed to provision config %v", reader.Cfg.Name)
} }
} }
......
...@@ -72,10 +72,8 @@ func (fr *fileReader) startWalkingDisk() error { ...@@ -72,10 +72,8 @@ func (fr *fileReader) startWalkingDisk() error {
fr.log.Debug("Start walking disk", "path", fr.Path) fr.log.Debug("Start walking disk", "path", fr.Path)
resolvedPath := fr.resolvedPath() resolvedPath := fr.resolvedPath()
if _, err := os.Stat(resolvedPath); err != nil { if _, err := os.Stat(resolvedPath); err != nil {
if os.IsNotExist(err) {
return err return err
} }
}
folderId, err := getOrCreateFolderId(fr.Cfg, fr.dashboardProvisioningService) folderId, err := getOrCreateFolderId(fr.Cfg, fr.dashboardProvisioningService)
if err != nil && err != ErrFolderNameMissing { if err != nil && err != ErrFolderNameMissing {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment