Backport "Same Configuration Check" from master

This commit is contained in:
Richard Kojedzinszky
2020-07-01 11:36:03 +02:00
committed by GitHub
parent c65277a6f0
commit 463e2285d6
2 changed files with 10 additions and 8 deletions
+6 -6
View File
@@ -309,7 +309,6 @@ func buildServerRoute(serverEntryPoint *serverEntryPoint, frontendName string, f
func (s *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
providersThrottleDuration := time.Duration(s.globalConfiguration.ProvidersThrottleDuration)
s.defaultConfigurationValues(configMsg.Configuration)
currentConfigurations := s.currentConfigurations.Get().(types.Configurations)
if log.GetLevel() == logrus.DebugLevel {
jsonConf, _ := json.Marshal(configMsg.Configuration)
@@ -321,11 +320,6 @@ func (s *Server) preLoadConfiguration(configMsg types.ConfigMessage) {
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]
if !ok {
providerConfigUpdateCh = make(chan types.ConfigMessage)
@@ -461,11 +455,17 @@ func (s *Server) throttleProviderConfigReload(throttle time.Duration, publish ch
}
})
var previousConfig types.ConfigMessage
for {
select {
case <-stop:
return
case nextConfig := <-in:
if reflect.DeepEqual(previousConfig, nextConfig) {
log.Infof("Skipping same configuration for provider %s", nextConfig.ProviderName)
continue
}
previousConfig = nextConfig
ring.In() <- nextConfig
}
}
+4 -2
View File
@@ -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++ {
providerConfig <- types.ConfigMessage{}
providerConfig <- types.ConfigMessage{
ProviderName: fmt.Sprintf("test-%d", i),
}
time.Sleep(10 * time.Millisecond)
}