mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
13703de67e
commit
eee3a75b8b
@ -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,
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user