Remove unnecessary reload of the configuration.
This commit is contained in:
parent
3747eb59ea
commit
5327ce543b
2 changed files with 16 additions and 8 deletions
|
@ -7,7 +7,6 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -21,6 +20,7 @@ import (
|
||||||
"github.com/containous/traefik/v2/pkg/safe"
|
"github.com/containous/traefik/v2/pkg/safe"
|
||||||
"github.com/containous/traefik/v2/pkg/tls"
|
"github.com/containous/traefik/v2/pkg/tls"
|
||||||
"github.com/containous/traefik/v2/pkg/types"
|
"github.com/containous/traefik/v2/pkg/types"
|
||||||
|
"github.com/mitchellh/hashstructure"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
)
|
)
|
||||||
|
@ -127,10 +127,14 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
|
||||||
// track more information about the dropped events.
|
// track more information about the dropped events.
|
||||||
conf := p.loadConfigurationFromCRD(ctxLog, k8sClient)
|
conf := p.loadConfigurationFromCRD(ctxLog, k8sClient)
|
||||||
|
|
||||||
if reflect.DeepEqual(p.lastConfiguration.Get(), conf) {
|
confHash, err := hashstructure.Hash(conf, nil)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
logger.Error("Unable to hash the configuration")
|
||||||
|
case p.lastConfiguration.Get() == confHash:
|
||||||
logger.Debugf("Skipping Kubernetes event kind %T", event)
|
logger.Debugf("Skipping Kubernetes event kind %T", event)
|
||||||
} else {
|
default:
|
||||||
p.lastConfiguration.Set(conf)
|
p.lastConfiguration.Set(confHash)
|
||||||
configurationChan <- dynamic.Message{
|
configurationChan <- dynamic.Message{
|
||||||
ProviderName: "kubernetescrd",
|
ProviderName: "kubernetescrd",
|
||||||
Configuration: conf,
|
Configuration: conf,
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -20,6 +19,7 @@ import (
|
||||||
"github.com/containous/traefik/v2/pkg/safe"
|
"github.com/containous/traefik/v2/pkg/safe"
|
||||||
"github.com/containous/traefik/v2/pkg/tls"
|
"github.com/containous/traefik/v2/pkg/tls"
|
||||||
"github.com/containous/traefik/v2/pkg/types"
|
"github.com/containous/traefik/v2/pkg/types"
|
||||||
|
"github.com/mitchellh/hashstructure"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/api/extensions/v1beta1"
|
"k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
@ -139,10 +139,14 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
|
||||||
// track more information about the dropped events.
|
// track more information about the dropped events.
|
||||||
conf := p.loadConfigurationFromIngresses(ctxLog, k8sClient)
|
conf := p.loadConfigurationFromIngresses(ctxLog, k8sClient)
|
||||||
|
|
||||||
if reflect.DeepEqual(p.lastConfiguration.Get(), conf) {
|
confHash, err := hashstructure.Hash(conf, nil)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
logger.Error("Unable to hash the configuration")
|
||||||
|
case p.lastConfiguration.Get() == confHash:
|
||||||
logger.Debugf("Skipping Kubernetes event kind %T", event)
|
logger.Debugf("Skipping Kubernetes event kind %T", event)
|
||||||
} else {
|
default:
|
||||||
p.lastConfiguration.Set(conf)
|
p.lastConfiguration.Set(confHash)
|
||||||
configurationChan <- dynamic.Message{
|
configurationChan <- dynamic.Message{
|
||||||
ProviderName: "kubernetes",
|
ProviderName: "kubernetes",
|
||||||
Configuration: conf,
|
Configuration: conf,
|
||||||
|
|
Loading…
Reference in a new issue