From 9906a0e05a1a08fcbba92c12687de7fee2653bcc Mon Sep 17 00:00:00 2001 From: Jordan Moldow Date: Sat, 23 Jan 2021 15:44:03 -0800 Subject: [PATCH] vtctl: Add missing err checks for VReplication v2 Return error immediately if the target keyspace is unknown. Do the same for the source keyspace. Currently, the code will attempt to continue with a bad keyspace name. Signed-off-by: Jordan Moldow --- go/vt/vtctl/vtctl.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 127f6783fcf..d85abc6bab0 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -2001,6 +2001,7 @@ func commandVRWorkflow(ctx context.Context, wr *wrangler.Wrangler, subFlags *fla _, err = wr.TopoServer().GetKeyspace(ctx, target) if err != nil { wr.Logger().Errorf("keyspace %s not found", target) + return err } vrwp := &wrangler.VReplicationWorkflowParams{ @@ -2057,6 +2058,11 @@ func commandVRWorkflow(ctx context.Context, wr *wrangler.Wrangler, subFlags *fla if *sourceKeyspace == "" { return fmt.Errorf("source keyspace is not specified") } + _, err := wr.TopoServer().GetKeyspace(ctx, *sourceKeyspace) + if err != nil { + wr.Logger().Errorf("keyspace %s not found", *sourceKeyspace) + return err + } if !*allTables && *tables == "" { return fmt.Errorf("no tables specified to move") }