forked from Ivasoft/traefik
Backport "Same Configuration Check" from master
This commit is contained in:
committed by
GitHub
parent
c65277a6f0
commit
463e2285d6
@@ -309,7 +309,6 @@ func buildServerRoute(serverEntryPoint *serverEntryPoint, frontendName string, f
|
|||||||
func (s *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
|
func (s *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
|
||||||
providersThrottleDuration := time.Duration(s.globalConfiguration.ProvidersThrottleDuration)
|
providersThrottleDuration := time.Duration(s.globalConfiguration.ProvidersThrottleDuration)
|
||||||
s.defaultConfigurationValues(configMsg.Configuration)
|
s.defaultConfigurationValues(configMsg.Configuration)
|
||||||
currentConfigurations := s.currentConfigurations.Get().(types.Configurations)
|
|
||||||
|
|
||||||
if log.GetLevel() == logrus.DebugLevel {
|
if log.GetLevel() == logrus.DebugLevel {
|
||||||
jsonConf, _ := json.Marshal(configMsg.Configuration)
|
jsonConf, _ := json.Marshal(configMsg.Configuration)
|
||||||
@@ -321,11 +320,6 @@ func (s *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(currentConfigurations[configMsg.ProviderName], configMsg.Configuration) {
|
|
||||||
log.Infof("Skipping same configuration for provider %s", configMsg.ProviderName)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
providerConfigUpdateCh, ok := s.providerConfigUpdateMap[configMsg.ProviderName]
|
providerConfigUpdateCh, ok := s.providerConfigUpdateMap[configMsg.ProviderName]
|
||||||
if !ok {
|
if !ok {
|
||||||
providerConfigUpdateCh = make(chan types.ConfigMessage)
|
providerConfigUpdateCh = make(chan types.ConfigMessage)
|
||||||
@@ -461,11 +455,17 @@ func (s *Server) throttleProviderConfigReload(throttle time.Duration, publish ch
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var previousConfig types.ConfigMessage
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return
|
return
|
||||||
case nextConfig := <-in:
|
case nextConfig := <-in:
|
||||||
|
if reflect.DeepEqual(previousConfig, nextConfig) {
|
||||||
|
log.Infof("Skipping same configuration for provider %s", nextConfig.ProviderName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
previousConfig = nextConfig
|
||||||
ring.In() <- nextConfig
|
ring.In() <- nextConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,9 +304,11 @@ func TestThrottleProviderConfigReload(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// publish 5 new configs, one new config each 10 milliseconds
|
// publish 5 new and different configs, one new config each 10 milliseconds
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
providerConfig <- types.ConfigMessage{}
|
providerConfig <- types.ConfigMessage{
|
||||||
|
ProviderName: fmt.Sprintf("test-%d", i),
|
||||||
|
}
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user