diff --git a/common/dynamicconfig/file_based_client.go b/common/dynamicconfig/file_based_client.go index 1b365b3ca58..3b28c21f581 100644 --- a/common/dynamicconfig/file_based_client.go +++ b/common/dynamicconfig/file_based_client.go @@ -367,8 +367,10 @@ func validateConfig(config *FileBasedClientConfig) error { if _, err := os.Stat(config.Filepath); err != nil { return fmt.Errorf("error checking dynamic config file at path %s, error: %v", config.Filepath, err) } + + // check if poll interval needs to be adjusted if config.PollInterval < minPollInterval { - return fmt.Errorf("poll interval should be at least %v", minPollInterval) + config.PollInterval = minPollInterval } return nil } diff --git a/common/dynamicconfig/file_based_client_test.go b/common/dynamicconfig/file_based_client_test.go index abb20a485fd..a0c5ad18103 100644 --- a/common/dynamicconfig/file_based_client_test.go +++ b/common/dynamicconfig/file_based_client_test.go @@ -226,11 +226,14 @@ func (s *fileBasedClientSuite) TestValidateConfig_FileNotExist() { } func (s *fileBasedClientSuite) TestValidateConfig_ShortPollInterval() { - _, err := NewFileBasedClient(&FileBasedClientConfig{ + cfg := &FileBasedClientConfig{ Filepath: "config/testConfig.yaml", PollInterval: time.Second, - }, nil, nil) - s.Error(err) + } + _, err := NewFileBasedClient(cfg, log.NewNoop(), nil) + s.NoError(err) + s.Equal(minPollInterval, cfg.PollInterval, "fallback to default poll interval") + } func (s *fileBasedClientSuite) TestMatch() {