From f8f296b3b3bbd6a1bb7d9420509d55f06f9e521e Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Fri, 14 Feb 2025 16:16:40 +0100 Subject: [PATCH] Add workflow name to all log messages Signed-off-by: Rohit Nayak --- go/vt/vtctl/workflow/traffic_switcher.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/go/vt/vtctl/workflow/traffic_switcher.go b/go/vt/vtctl/workflow/traffic_switcher.go index e11605fc04c..7e1df4a07ce 100644 --- a/go/vt/vtctl/workflow/traffic_switcher.go +++ b/go/vt/vtctl/workflow/traffic_switcher.go @@ -1154,7 +1154,7 @@ func (ts *trafficSwitcher) cancelMigration(ctx context.Context, sm *StreamMigrat if ctx.Err() != nil { // Even though we create a new context later on we still record any context error: // for forensics in case of failures. - ts.Logger().Infof("In Cancel migration: original context invalid: %s", ctx.Err()) + ts.Logger().Infof("cancelMigration (%v): original context invalid: %s", ts.WorkflowName(), ctx.Err()) } ts.Logger().Infof("cancelMigration (%v): starting", ts.WorkflowName()) // We create a new context while canceling the migration, so that we are independent of the original @@ -1169,10 +1169,10 @@ func (ts *trafficSwitcher) cancelMigration(ctx context.Context, sm *StreamMigrat if ts.MigrationType() == binlogdatapb.MigrationType_TABLES { if !ts.IsMultiTenantMigration() { - ts.Logger().Infof("cancelMigration (%v): switching denied tables to target", ts.WorkflowName()) + ts.Logger().Infof("cancelMigration (%v): adding denied tables to target", ts.WorkflowName()) err = ts.switchDeniedTables(cmCtx, true /* revert */) } else { - ts.Logger().Infof("cancelMigration (%v): multi-tenant, not switching denied tables to target", ts.WorkflowName()) + ts.Logger().Infof("cancelMigration (%v): multi-tenant, not adding denied tables to target", ts.WorkflowName()) } } else { ts.Logger().Infof("cancelMigration (%v): allowing writes on source shards", ts.WorkflowName()) @@ -1180,15 +1180,15 @@ func (ts *trafficSwitcher) cancelMigration(ctx context.Context, sm *StreamMigrat } if err != nil { cancelErrs.RecordError(fmt.Errorf("could not revert denied tables / shard access: %v", err)) - ts.Logger().Errorf("Cancel migration failed: could not revert denied tables / shard access: %v", err) + ts.Logger().Errorf("Cancel migration failed (%v): could not revert denied tables / shard access: %v", ts.WorkflowName(), err) } if err := sm.CancelStreamMigrations(cmCtx); err != nil { cancelErrs.RecordError(fmt.Errorf("could not cancel stream migrations: %v", err)) - ts.Logger().Errorf("Cancel migration failed: could not cancel stream migrations: %v", err) + ts.Logger().Errorf("Cancel migration failed (%v): could not cancel stream migrations: %v", ts.WorkflowName(), err) } - ts.Logger().Infof("cancelMigration (%s): restarting vreplication workflows", ts.WorkflowName()) + ts.Logger().Infof("cancelMigration (%v): restarting vreplication workflows", ts.WorkflowName()) err = ts.ForAllTargets(func(target *MigrationTarget) error { query := fmt.Sprintf("update _vt.vreplication set state='Running', message='' where db_name=%s and workflow=%s", encodeString(target.GetPrimary().DbName()), encodeString(ts.WorkflowName())) @@ -1197,13 +1197,13 @@ func (ts *trafficSwitcher) cancelMigration(ctx context.Context, sm *StreamMigrat }) if err != nil { cancelErrs.RecordError(fmt.Errorf("could not restart vreplication: %v", err)) - ts.Logger().Errorf("Cancel migration failed: could not restart vreplication: %v", err) + ts.Logger().Errorf("Cancel migration failed (%v): could not restart vreplication: %v", ts.WorkflowName(), err) } ts.Logger().Infof("cancelMigration (%v): deleting reverse vreplication workflows", ts.WorkflowName()) if err := ts.deleteReverseVReplication(cmCtx); err != nil { cancelErrs.RecordError(fmt.Errorf("could not delete reverse vreplication streams: %v", err)) - ts.Logger().Errorf("Cancel migration failed: could not delete reverse vreplication streams: %v", err) + ts.Logger().Errorf("Cancel migration failed (%v): could not delete reverse vreplication streams: %v", ts.WorkflowName(), err) } if cancelErrs.HasErrors() {