Skip to content
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

[release-21.0] Fix vtcombo parsing flags incorrectly (#17743) #17820

Merged
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions go/cmd/vtcombo/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ func init() {
// user know about this flag.
Main.Flags().MarkHidden("tablet_protocol")

var err error
env, err = vtenv.New(vtenv.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
log.Fatalf("unable to initialize env: %v", err)
}
srvTopoCounts = stats.NewCountersWithSingleLabel("ResilientSrvTopoServer", "Resilient srvtopo server operations", "type")
}

Expand Down Expand Up @@ -189,6 +180,15 @@ func run(cmd *cobra.Command, args []string) (err error) {
cmd.Flags().Set("log_dir", "$VTDATAROOT/tmp")
}

env, err = vtenv.New(vtenv.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
log.Fatalf("unable to initialize env: %v", err)
}

ctx, cancel := context.WithCancel(cmd.Context())
defer cancel()
if externalTopoServer {
Expand Down
21 changes: 10 additions & 11 deletions go/cmd/vtctldclient/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/trace"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/topo"
Expand Down Expand Up @@ -106,6 +105,15 @@ connect directly to the topo server(s).`, useInternalVtctld),
// We use PersistentPreRun to set up the tracer, grpc client, and
// command context for every command.
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
env, err = vtenv.New(vtenv.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
return fmt.Errorf("failed to initialize vtenv: %w", err)
}

logutil.PurgeLogs()
traceCloser = trace.StartTracing("vtctldclient")
client, err = getClientForCommand(cmd)
Expand All @@ -119,6 +127,7 @@ connect directly to the topo server(s).`, useInternalVtctld),
}
vreplcommon.SetClient(client)
vreplcommon.SetCommandCtx(commandCtx)

return err
},
// Similarly, PersistentPostRun cleans up the resources spawned by
Expand Down Expand Up @@ -229,14 +238,4 @@ func init() {
Root.PersistentFlags().StringSliceVar(&topoOptions.globalServerAddresses, "topo-global-server-address", topoOptions.globalServerAddresses, "the address of the global topology server(s)")
Root.PersistentFlags().StringVar(&topoOptions.globalRoot, "topo-global-root", topoOptions.globalRoot, "the path of the global topology data in the global topology server")
vreplcommon.RegisterCommands(Root)

var err error
env, err = vtenv.New(vtenv.Options{
MySQLServerVersion: servenv.MySQLServerVersion(),
TruncateUILen: servenv.TruncateUILen,
TruncateErrLen: servenv.TruncateErrLen,
})
if err != nil {
log.Fatalf("failed to initialize vtenv: %v", err)
}
}
Loading