From b322579c9ee5ef67b880053bece571d2503bd56c Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Wed, 15 Jan 2020 11:11:45 -0700 Subject: [PATCH 1/3] Restore support for mysqlctl_mycnf_template Regression of #5654 Signed-off-by: Morgan Tocker --- go/vt/mysqlctl/mysqld.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index afc40ae5268..4a526a326b2 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -72,7 +72,8 @@ var ( poolDynamicHostnameResolution = flag.Duration("pool_hostname_resolve_interval", 0, "if set force an update to all hostnames and reconnect if changed, defaults to 0 (disabled)") - socketFile = flag.String("mysqlctl_socket", "", "socket file to use for remote mysqlctl actions (empty for local actions)") + mycnfTemplateFile = flag.String("mysqlctl_mycnf_template", "", "template file to use for generating the my.cnf file during server init") + socketFile = flag.String("mysqlctl_socket", "", "socket file to use for remote mysqlctl actions (empty for local actions)") // masterConnectRetry is used in 'SET MASTER' commands masterConnectRetry = flag.Duration("master_connect_retry", 10*time.Second, "how long to wait in between slave -> connection attempts. Only precise to the second.") @@ -793,7 +794,14 @@ func (mysqld *Mysqld) initConfig(cnf *Mycnf, outFile string) error { } func (mysqld *Mysqld) getMycnfTemplate() string { - + if *mycnfTemplateFile != "" { + data, err := ioutil.ReadFile(*mycnfTemplateFile) + if err != nil { + log.Warningf("template file could not be read, using default template instead: %v", *mycnfTemplateFile) // continue to default + } else { + return string(data) // use only specified template + } + } myTemplateSource := new(bytes.Buffer) myTemplateSource.WriteString("[mysqld]\n") From 89e396d3c02cffdb16595203830037b336516ac0 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Wed, 15 Jan 2020 11:44:39 -0700 Subject: [PATCH 2/3] Change from warning to fatal Signed-off-by: Morgan Tocker --- go/vt/mysqlctl/mysqld.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index 4a526a326b2..e6ae3ab1365 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -797,10 +797,9 @@ func (mysqld *Mysqld) getMycnfTemplate() string { if *mycnfTemplateFile != "" { data, err := ioutil.ReadFile(*mycnfTemplateFile) if err != nil { - log.Warningf("template file could not be read, using default template instead: %v", *mycnfTemplateFile) // continue to default - } else { - return string(data) // use only specified template + log.Fatalf("mycnf template file could not be read: %v", *mycnfTemplateFile) } + return string(data) // use only specified template } myTemplateSource := new(bytes.Buffer) myTemplateSource.WriteString("[mysqld]\n") From 22217bb44d023450c6ac065c74a4425e987d0eaf Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Mon, 20 Jan 2020 11:59:32 -0700 Subject: [PATCH 3/3] Slightly improve error message Mention config var which is causing the failure. Signed-off-by: Morgan Tocker --- go/vt/mysqlctl/mysqld.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index e6ae3ab1365..ce6cca8f570 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -797,7 +797,7 @@ func (mysqld *Mysqld) getMycnfTemplate() string { if *mycnfTemplateFile != "" { data, err := ioutil.ReadFile(*mycnfTemplateFile) if err != nil { - log.Fatalf("mycnf template file could not be read: %v", *mycnfTemplateFile) + log.Fatalf("template file specified by -mysqlctl_mycnf_template could not be read: %v", *mycnfTemplateFile) } return string(data) // use only specified template }