Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 8 additions & 6 deletions examples/demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ func runCluster() {
}
env, err := vttest.NewLocalTestEnv(12345)
if err != nil {
log.Exitf("Error: %v", err)
log.Error(fmt.Sprintf("Error: %v", err))
os.Exit(1)
}
cluster.Env = env
err = cluster.Setup()
if err != nil {
cluster.TearDown()
log.Exitf("Error: %v", err)
log.Error(fmt.Sprintf("Error: %v", err))
os.Exit(1)
}
}

Expand Down Expand Up @@ -189,7 +191,7 @@ func execQuery(conn *mysql.Conn, key, query, keyspace, shard string, response ma
"title": title,
"error": err.Error(),
}
log.Errorf("error: %v", err)
log.Error(fmt.Sprintf("error: %v", err))
return
}
response[key] = resultToMap(title, qr)
Expand All @@ -207,7 +209,7 @@ func resultToMap(title string, qr *sqltypes.Result) map[string]any {
if value.Type() == sqltypes.VarBinary {
bytes, err := value.ToBytes()
if err != nil {
log.Errorf("Error converting value to bytes: %v", err)
log.Error(fmt.Sprintf("Error converting value to bytes: %v", err))
return nil
}
srow = append(srow, hex.EncodeToString(bytes))
Expand All @@ -230,7 +232,7 @@ func streamQuerylog(port int) (<-chan string, error) {
request := fmt.Sprintf("http://localhost:%d/debug/querylog", port)
resp, err := http.Get(request)
if err != nil {
log.Errorf("Error reading stream: %v: %v", request, err)
log.Error(fmt.Sprintf("Error reading stream: %v: %v", request, err))
return nil, err
}
ch := make(chan string, 100)
Expand All @@ -239,7 +241,7 @@ func streamQuerylog(port int) (<-chan string, error) {
for {
str, err := buffered.ReadString('\n')
if err != nil {
log.Errorf("Error reading stream: %v: %v", request, err)
log.Error(fmt.Sprintf("Error reading stream: %v: %v", request, err))
close(ch)
resp.Body.Close()
return
Expand Down
6 changes: 4 additions & 2 deletions go/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ package acl
import (
"fmt"
"net/http"
"os"
"sync"

"github.com/spf13/pflag"
Expand Down Expand Up @@ -80,7 +81,8 @@ func RegisterFlags(fs *pflag.FlagSet) {
// functions when needed.
func RegisterPolicy(name string, policy Policy) {
if _, ok := policies[name]; ok {
log.Fatalf("policy %s is already registered", name)
log.Error(fmt.Sprintf("policy %s is already registered", name))
os.Exit(1)
}
policies[name] = policy
}
Expand All @@ -95,7 +97,7 @@ func savePolicy() {
currentPolicy = policy
return
}
log.Warningf("security-policy %q not found; using fallback policy (deny-all)", securityPolicy)
log.Warn(fmt.Sprintf("security-policy %q not found; using fallback policy (deny-all)", securityPolicy))
currentPolicy = denyAllPolicy{}
}

Expand Down
6 changes: 5 additions & 1 deletion go/cmd/mysqlctl/mysqlctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ limitations under the License.
package main

import (
"fmt"
"os"

"vitess.io/vitess/go/cmd/mysqlctl/command"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
Expand All @@ -27,6 +30,7 @@ func main() {
command.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

if err := command.Root.Execute(); err != nil {
log.Exit(err)
log.Error(fmt.Sprint(err))
os.Exit(1)
}
}
14 changes: 7 additions & 7 deletions go/cmd/mysqlctld/cli/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func run(cmd *cobra.Command, args []string) error {
mycnfFile := mysqlctl.MycnfFile(tabletUID)
if _, statErr := os.Stat(mycnfFile); os.IsNotExist(statErr) {
// Generate my.cnf from scratch and use it to find mysqld.
log.Infof("mycnf file (%s) doesn't exist, initializing", mycnfFile)
log.Info(fmt.Sprintf("mycnf file (%s) doesn't exist, initializing", mycnfFile))

var err error
mysqld, cnf, err = mysqlctl.CreateMysqldAndMycnf(tabletUID, mysqlSocket, mysqlPort, collationEnv)
Expand All @@ -135,7 +135,7 @@ func run(cmd *cobra.Command, args []string) error {
}
} else {
// There ought to be an existing my.cnf, so use it to find mysqld.
log.Infof("mycnf file (%s) already exists, starting without init", mycnfFile)
log.Info(fmt.Sprintf("mycnf file (%s) already exists, starting without init", mycnfFile))

var err error
mysqld, cnf, err = mysqlctl.OpenMysqldAndMycnf(tabletUID, collationEnv)
Expand All @@ -158,7 +158,7 @@ func run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to start mysqld: %w", err)
}
} else {
log.Infof("found interrupted restore, not starting mysqld")
log.Info("found interrupted restore, not starting mysqld")
}
}
cancel()
Expand All @@ -167,11 +167,11 @@ func run(cmd *cobra.Command, args []string) error {

// Take mysqld down with us on SIGTERM before entering lame duck.
servenv.OnTermSync(func() {
log.Infof("mysqlctl received SIGTERM, shutting down mysqld first")
log.Info("mysqlctl received SIGTERM, shutting down mysqld first")
ctx, cancel := context.WithTimeout(cmd.Context(), shutdownWaitTime+10*time.Second)
defer cancel()
if err := mysqld.Shutdown(ctx, cnf, true, shutdownWaitTime); err != nil {
log.Errorf("failed to shutdown mysqld: %v", err)
log.Error(fmt.Sprintf("failed to shutdown mysqld: %v", err))
}
})

Expand All @@ -184,9 +184,9 @@ func run(cmd *cobra.Command, args []string) error {

select {
case <-mysqldTerminated:
log.Infof("mysqld shut down on its own, exiting mysqlctld")
log.Info("mysqld shut down on its own, exiting mysqlctld")
case <-mysqlctldTerminated:
log.Infof("mysqlctld shut down gracefully")
log.Info("mysqlctld shut down gracefully")
}

return nil
Expand Down
6 changes: 5 additions & 1 deletion go/cmd/mysqlctld/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ limitations under the License.
package main

import (
"fmt"
"os"

"vitess.io/vitess/go/cmd/mysqlctld/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
Expand All @@ -29,6 +32,7 @@ func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

if err := cli.Main.Execute(); err != nil {
log.Exit(err)
log.Error(fmt.Sprint(err))
os.Exit(1)
}
}
6 changes: 5 additions & 1 deletion go/cmd/topo2topo/topo2topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ limitations under the License.
package main

import (
"fmt"
"os"

"vitess.io/vitess/go/cmd/topo2topo/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
Expand All @@ -28,6 +31,7 @@ func main() {

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exitf("%s", err)
log.Error(fmt.Sprintf("%s", err))
os.Exit(1)
}
}
14 changes: 9 additions & 5 deletions go/cmd/vtadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package main

import (
"flag"
"fmt"
"io"
"os"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -78,20 +80,21 @@ var (
// a log.Fatal call with the given args.
func fatal(args ...any) {
trace.LogErrorsWhenClosing(traceCloser)
log.Fatal(args...)
log.Error(fmt.Sprint(args...))
os.Exit(1)
}

// startTracing checks the value of --tracer and then starts tracing, populating
// the private global traceCloser
func startTracing(cmd *cobra.Command) {
tracer, err := cmd.Flags().GetString("tracer")
if err != nil {
log.Warningf("not starting tracer; err: %s", err)
log.Warn(fmt.Sprintf("not starting tracer; err: %s", err))
return
}

if tracer == "" || tracer == "noop" {
log.Warningf("starting tracing with noop tracer")
log.Warn("starting tracing with noop tracer")
}

traceCloser = trace.StartTracing("vtadmin")
Expand Down Expand Up @@ -136,7 +139,7 @@ func run(cmd *cobra.Command, args []string) {
}

if cacheRefreshKey == "" {
log.Warningf("no cache-refresh-key set; forcing cache refreshes will not be possible")
log.Warn("no cache-refresh-key set; forcing cache refreshes will not be possible")
}
cache.SetCacheRefreshKey(cacheRefreshKey)

Expand Down Expand Up @@ -228,7 +231,8 @@ func main() {

rootCmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
log.Error(fmt.Sprint(err))
os.Exit(1)
}
}

Expand Down
Loading
Loading