From 91bb0b92120d82e5efee4b79140177c136da7bef Mon Sep 17 00:00:00 2001 From: Rohit Nayak <57520317+rohit-nayak-ps@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:05:22 +0100 Subject: [PATCH] VReplication SwitchWrites: Properly return errors in SwitchWrites (#14800) Signed-off-by: Rohit Nayak --- go/vt/wrangler/traffic_switcher.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/vt/wrangler/traffic_switcher.go b/go/vt/wrangler/traffic_switcher.go index ba1309f0f8f..cb9e9193fc1 100644 --- a/go/vt/wrangler/traffic_switcher.go +++ b/go/vt/wrangler/traffic_switcher.go @@ -487,11 +487,11 @@ func (wr *Wrangler) SwitchWrites(ctx context.Context, targetKeyspace, workflowNa ts, ws, err := wr.getWorkflowState(ctx, targetKeyspace, workflowName) _ = ws if err != nil { - handleError("failed to get the current workflow state", err) + return handleError("failed to get the current workflow state", err) } if ts == nil { errorMsg := fmt.Sprintf("workflow %s not found in keyspace %s", workflowName, targetKeyspace) - handleError("failed to get the current workflow state", fmt.Errorf(errorMsg)) + return handleError("failed to get the current workflow state", fmt.Errorf(errorMsg)) } var sw iswitcher @@ -508,7 +508,7 @@ func (wr *Wrangler) SwitchWrites(ctx context.Context, targetKeyspace, workflowNa ts.Logger().Infof("Built switching metadata: %+v", ts) if err := ts.validate(ctx); err != nil { - handleError("workflow validation failed", err) + return handleError("workflow validation failed", err) } if reverseReplication { @@ -655,7 +655,7 @@ func (wr *Wrangler) SwitchWrites(ctx context.Context, targetKeyspace, workflowNa return handleError("failed to update the routing rules", err) } if err := sw.streamMigraterfinalize(ctx, ts, sourceWorkflows); err != nil { - handleError("failed to finalize the traffic switch", err) + return handleError("failed to finalize the traffic switch", err) } if reverseReplication { if err := sw.startReverseVReplication(ctx); err != nil {