From da93dab828c5f78714209d84906d820c4d176a1b Mon Sep 17 00:00:00 2001 From: mpl Date: Fri, 9 Dec 2022 09:48:04 +0100 Subject: [PATCH] make file provider more resilient wrt first configuration Co-authored-by: Romain Co-authored-by: Tom Moulard --- pkg/provider/file/file.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/provider/file/file.go b/pkg/provider/file/file.go index 08ee0896d..548f0cbc4 100644 --- a/pkg/provider/file/file.go +++ b/pkg/provider/file/file.go @@ -46,11 +46,6 @@ func (p *Provider) Init() error { // Provide allows the file provider to provide configurations to traefik // using the given configuration channel. func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error { - configuration, err := p.BuildConfiguration() - if err != nil { - return err - } - if p.Watch { var watchItem string @@ -68,6 +63,15 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe. } } + configuration, err := p.BuildConfiguration() + if err != nil { + if p.Watch { + log.WithoutContext().WithField(log.ProviderName, providerName).Errorf("Error while building configuration (for the first time): %v", err) + return nil + } + return err + } + sendConfigToChannel(configurationChan, configuration) return nil }