From 552bd8f1801e951b8564d371caa20a1cfbb10502 Mon Sep 17 00:00:00 2001 From: Bmagic Date: Wed, 6 Nov 2024 11:58:04 +0100 Subject: [PATCH] Add AbortOnPluginFailure option to abort startup on plugin load failure --- cmd/traefik/traefik.go | 3 +++ docs/content/reference/static-configuration/cli-ref.md | 3 +++ docs/content/reference/static-configuration/env-ref.md | 3 +++ docs/content/reference/static-configuration/file.toml | 1 + docs/content/reference/static-configuration/file.yaml | 1 + pkg/config/static/experimental.go | 5 +++-- 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index 78edf38cb..5914d73e4 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -238,6 +238,9 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err } pluginBuilder, err := createPluginBuilder(staticConfiguration) + if err != nil && staticConfiguration.Experimental != nil && staticConfiguration.Experimental.AbortOnPluginFailure { + return nil, fmt.Errorf("plugin: failed to create plugin builder: %w", err) + } if err != nil { pluginLogger.Err(err).Msg("Plugins are disabled because an error has occurred.") } else if hasPlugins { diff --git a/docs/content/reference/static-configuration/cli-ref.md b/docs/content/reference/static-configuration/cli-ref.md index a4264b017..7e18a9b8b 100644 --- a/docs/content/reference/static-configuration/cli-ref.md +++ b/docs/content/reference/static-configuration/cli-ref.md @@ -228,6 +228,9 @@ WriteTimeout is the maximum duration before timing out writes of the response. I `--entrypoints..udp.timeout`: Timeout defines how long to wait on an idle session before releasing the related resources. (Default: ```3```) +`--experimental.abortonpluginfailure`: +Defines whether all plugins must be loaded successfully for Traefik to start. (Default: ```false```) + `--experimental.fastproxy`: Enable the FastProxy implementation. (Default: ```false```) diff --git a/docs/content/reference/static-configuration/env-ref.md b/docs/content/reference/static-configuration/env-ref.md index e835cfa83..61f0a28b0 100644 --- a/docs/content/reference/static-configuration/env-ref.md +++ b/docs/content/reference/static-configuration/env-ref.md @@ -228,6 +228,9 @@ WriteTimeout is the maximum duration before timing out writes of the response. I `TRAEFIK_ENTRYPOINTS__UDP_TIMEOUT`: Timeout defines how long to wait on an idle session before releasing the related resources. (Default: ```3```) +`TRAEFIK_EXPERIMENTAL_ABORTONPLUGINFAILURE`: +Defines whether all plugins must be loaded successfully for Traefik to start. (Default: ```false```) + `TRAEFIK_EXPERIMENTAL_FASTPROXY`: Enable the FastProxy implementation. (Default: ```false```) diff --git a/docs/content/reference/static-configuration/file.toml b/docs/content/reference/static-configuration/file.toml index d5ad0411e..9bfa02e1e 100644 --- a/docs/content/reference/static-configuration/file.toml +++ b/docs/content/reference/static-configuration/file.toml @@ -488,6 +488,7 @@ [certificatesResolvers.CertificateResolver1.tailscale] [experimental] + abortOnPluginFailure = true kubernetesGateway = true [experimental.plugins] [experimental.plugins.Descriptor0] diff --git a/docs/content/reference/static-configuration/file.yaml b/docs/content/reference/static-configuration/file.yaml index 8823bb754..1fb8a7f30 100644 --- a/docs/content/reference/static-configuration/file.yaml +++ b/docs/content/reference/static-configuration/file.yaml @@ -576,6 +576,7 @@ experimental: mounts: - foobar - foobar + abortOnPluginFailure: true fastProxy: debug: true kubernetesGateway: true diff --git a/pkg/config/static/experimental.go b/pkg/config/static/experimental.go index 47b2989f8..099b97f6d 100644 --- a/pkg/config/static/experimental.go +++ b/pkg/config/static/experimental.go @@ -4,8 +4,9 @@ import "github.com/traefik/traefik/v3/pkg/plugins" // Experimental experimental Traefik features. type Experimental struct { - Plugins map[string]plugins.Descriptor `description:"Plugins configuration." json:"plugins,omitempty" toml:"plugins,omitempty" yaml:"plugins,omitempty" export:"true"` - LocalPlugins map[string]plugins.LocalDescriptor `description:"Local plugins configuration." json:"localPlugins,omitempty" toml:"localPlugins,omitempty" yaml:"localPlugins,omitempty" export:"true"` + Plugins map[string]plugins.Descriptor `description:"Plugins configuration." json:"plugins,omitempty" toml:"plugins,omitempty" yaml:"plugins,omitempty" export:"true"` + LocalPlugins map[string]plugins.LocalDescriptor `description:"Local plugins configuration." json:"localPlugins,omitempty" toml:"localPlugins,omitempty" yaml:"localPlugins,omitempty" export:"true"` + AbortOnPluginFailure bool `description:"Defines whether all plugins must be loaded successfully for Traefik to start." json:"abortOnPluginFailure,omitempty" toml:"abortOnPluginFailure,omitempty" yaml:"abortOnPluginFailure,omitempty" export:"true"` FastProxy *FastProxyConfig `description:"Enable the FastProxy implementation." json:"fastProxy,omitempty" toml:"fastProxy,omitempty" yaml:"fastProxy,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"`