diff --git a/go/vt/vtctl/workflow/server.go b/go/vt/vtctl/workflow/server.go index abbb0b770f7..ca273d862f1 100644 --- a/go/vt/vtctl/workflow/server.go +++ b/go/vt/vtctl/workflow/server.go @@ -3017,10 +3017,16 @@ func (s *Server) switchReads(ctx context.Context, req *vtctldatapb.WorkflowSwitc } defer unlock(&err) + var tabletTypes []topodatapb.TabletType + for _, tabletType := range req.TabletTypes { + if tabletType != topodatapb.TabletType_PRIMARY { + tabletTypes = append(tabletTypes, tabletType) + } + } if ts.MigrationType() == binlogdatapb.MigrationType_TABLES { if ts.isPartialMigration { ts.Logger().Infof("Partial migration, skipping switchTableReads as traffic is all or nothing per shard and overridden for reads AND writes in the ShardRoutingRule created when switching writes.") - } else if err := sw.switchTableReads(ctx, cells, req.TabletTypes, direction); err != nil { + } else if err := sw.switchTableReads(ctx, cells, tabletTypes, direction); err != nil { return handleError("failed to switch read traffic for the tables", err) } return sw.logs(), nil diff --git a/go/vt/vtctl/workflow/traffic_switcher.go b/go/vt/vtctl/workflow/traffic_switcher.go index d4fe77130ae..52a3de86f1d 100644 --- a/go/vt/vtctl/workflow/traffic_switcher.go +++ b/go/vt/vtctl/workflow/traffic_switcher.go @@ -587,6 +587,10 @@ func (ts *trafficSwitcher) switchTableReads(ctx context.Context, cells []string, // For forward migration, we add tablet type specific rules to redirect traffic to the target. // For backward, we redirect to source. for _, servedType := range servedTypes { + if servedType != topodatapb.TabletType_REPLICA && servedType != topodatapb.TabletType_RDONLY { + return fmt.Errorf("invalid tablet type specified for switchTableReads: %v", servedType) + } + tt := strings.ToLower(servedType.String()) for _, table := range ts.Tables() { if direction == DirectionForward {