CloudMigrations: Misc cleanup before codefreeze (#91725)

* fix retry logic

* slight adjustments

* fix disconnect and connect events

* Update pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>

---------

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
This commit is contained in:
Michael Mandrus 2024-08-09 10:38:08 -04:00 committed by GitHub
parent 13703de67e
commit eee3a75b8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 5 deletions

View File

@ -391,7 +391,7 @@ func (s *Service) CreateSession(ctx context.Context, cmd cloudmigration.CloudMig
return nil, fmt.Errorf("error creating migration: %w", err) return nil, fmt.Errorf("error creating migration: %w", err)
} }
s.report(ctx, cm, gmsclient.EventConnect, 0, nil) s.report(ctx, &migration, gmsclient.EventConnect, 0, nil)
return &cloudmigration.CloudMigrationSessionResponse{ return &cloudmigration.CloudMigrationSessionResponse{
UID: cm.UID, UID: cm.UID,

View File

@ -355,10 +355,19 @@ func (s *Service) uploadUsingPresignedURL(ctx context.Context, uploadURL, key st
} }
func (s *Service) updateSnapshotWithRetries(ctx context.Context, cmd cloudmigration.UpdateSnapshotCmd) (err error) { func (s *Service) updateSnapshotWithRetries(ctx context.Context, cmd cloudmigration.UpdateSnapshotCmd) (err error) {
maxRetries := 10
retries := 0
if err := retryer.Retry(func() (retryer.RetrySignal, error) { if err := retryer.Retry(func() (retryer.RetrySignal, error) {
err := s.store.UpdateSnapshot(ctx, cmd) if err := s.store.UpdateSnapshot(ctx, cmd); err != nil {
return retryer.FuncComplete, err s.log.Error("updating snapshot in retry loop", "error", err.Error())
}, 10, time.Millisecond*100, time.Second*10); err != nil { retries++
if retries > maxRetries {
return retryer.FuncError, err
}
return retryer.FuncFailure, nil
}
return retryer.FuncComplete, nil
}, maxRetries, time.Millisecond*10, time.Second*5); err != nil {
s.log.Error("failed to update snapshot status", "snapshotUid", cmd.UID, "status", cmd.Status, "num_resources", len(cmd.Resources), "error", err.Error()) s.log.Error("failed to update snapshot status", "snapshotUid", cmd.UID, "status", cmd.Status, "num_resources", len(cmd.Resources), "error", err.Error())
return fmt.Errorf("failed to update snapshot status: %w", err) return fmt.Errorf("failed to update snapshot status: %w", err)
} }

View File

@ -164,10 +164,14 @@ func (ss *sqlStore) DeleteMigrationSessionByUID(ctx context.Context, uid string)
} }
return nil return nil
}) })
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
if err := ss.decryptToken(ctx, &c); err != nil {
return &c, snapshots, err
}
return &c, snapshots, nil return &c, snapshots, nil
} }