-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: use fsnotify to do config file reload #191
Conversation
Signed-off-by: xhe <xw897002528@gmail.com>
rootCmd.SetOutput(os.Stdout) | ||
rootCmd.SetErr(os.Stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cobra all output defaults to stderr
.
configFile := rootCmd.PersistentFlags().String("config", "", "proxy config file path") | ||
logEncoder := rootCmd.PersistentFlags().String("log_encoder", "tidb", "log in format of tidb, console, or json") | ||
logLevel := rootCmd.PersistentFlags().String("log_level", "", "log level") | ||
_ = rootCmd.PersistentFlags().String("cluster_name", "tiproxy", "default cluster name, used to generate node name and differential clusters in dns discovery") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove useless cluster options.
logger := logger.CreateLoggerForTest(t) | ||
|
||
etcd_cfg := embed.NewConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless
}) | ||
|
||
t.Cleanup(cancel) | ||
|
||
return cfgmgr, ctx | ||
} | ||
|
||
func TestBase(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to namespace_test.go
, no modification.
) | ||
|
||
func (e *ConfigManager) get(ctx context.Context, ns, key string) (KVValue, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from manager.go
select { | ||
case <-ctx.Done(): | ||
return | ||
case ach := <-cfgch: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listener.Accept()
will block receiving changes from config channel, causing it blocking. Thus we do it in separate goroutines.
return | ||
} | ||
// setup config manager | ||
if err = srv.ConfigManager.Init(ctx, lg.Named("config"), sctx.ConfigFile, &sctx.Overlay); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfgmgr is inited much earlier to read the config file
Co-authored-by: djshow832 <zhangming@pingcap.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe xw897002528@gmail.com
What problem does this PR solve?
Issue Number: close #190
Problem Summary: The best online reload solution for tidb-operator. No more PR for tidb-operator after this adaption. It works forever.
What is changed: Mostly refactors in
manager/config
fmt.Printf
at logger in the previous PRTestBase/TestConcurrency
tonamespace_test.go
e.get/set/list
tonamespace.go
config/set
accepts toml returns json.config/get
just returns toml.cmd/tiproxy
but responsible bymanager/config
workdir
to$PWD/work
TestWatch
is replaced byTestConfig
Check List
Tests
Notable changes
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.