fix: allow starting Traefik even if plugin services have an issue
This commit is contained in:
parent
d3e4d56a0d
commit
d9589878fb
3 changed files with 16 additions and 10 deletions
|
@ -223,12 +223,16 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err
|
||||||
|
|
||||||
pluginBuilder, err := createPluginBuilder(staticConfiguration)
|
pluginBuilder, err := createPluginBuilder(staticConfiguration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
log.WithoutContext().WithError(err).Error("Plugins are disabled because an error has occurred.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Providers plugins
|
// Providers plugins
|
||||||
|
|
||||||
for name, conf := range staticConfiguration.Providers.Plugin {
|
for name, conf := range staticConfiguration.Providers.Plugin {
|
||||||
|
if pluginBuilder == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
p, err := pluginBuilder.BuildProvider(name, conf)
|
p, err := pluginBuilder.BuildProvider(name, conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("plugin: failed to build provider: %w", err)
|
return nil, fmt.Errorf("plugin: failed to build provider: %w", err)
|
||||||
|
|
|
@ -164,7 +164,12 @@ func (c *Client) Download(ctx context.Context, pName, pVersion string) (string,
|
||||||
|
|
||||||
defer func() { _ = resp.Body.Close() }()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusOK {
|
switch resp.StatusCode {
|
||||||
|
case http.StatusNotModified:
|
||||||
|
// noop
|
||||||
|
return hash, nil
|
||||||
|
|
||||||
|
case http.StatusOK:
|
||||||
err = os.MkdirAll(filepath.Dir(filename), 0o755)
|
err = os.MkdirAll(filepath.Dir(filename), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to create directory: %w", err)
|
return "", fmt.Errorf("failed to create directory: %w", err)
|
||||||
|
@ -189,15 +194,11 @@ func (c *Client) Download(ctx context.Context, pName, pVersion string) (string,
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash, nil
|
return hash, nil
|
||||||
}
|
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusNotModified {
|
default:
|
||||||
// noop
|
data, _ := io.ReadAll(resp.Body)
|
||||||
return hash, nil
|
return "", fmt.Errorf("error: %d: %s", resp.StatusCode, string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
data, _ := io.ReadAll(resp.Body)
|
|
||||||
return "", fmt.Errorf("error: %d: %s", resp.StatusCode, string(data))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check checks the plugin archive integrity.
|
// Check checks the plugin archive integrity.
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containous/alice"
|
"github.com/containous/alice"
|
||||||
|
@ -340,7 +341,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin
|
// Plugin
|
||||||
if config.Plugin != nil {
|
if config.Plugin != nil && !reflect.ValueOf(b.pluginBuilder).IsNil() { // Using "reflect" because "b.pluginBuilder" is an interface.
|
||||||
if middleware != nil {
|
if middleware != nil {
|
||||||
return nil, badConf
|
return nil, badConf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue