CloudMigrations: Query GMS for snapshot status with a results offset (#90453)

* query GMS for status with an offset

* remove unused state
This commit is contained in:
Michael Mandrus
2024-07-16 09:04:21 -04:00
committed by GitHub
parent f14ba32ea6
commit 6ff21726b7
8 changed files with 18 additions and 8 deletions
@@ -524,9 +524,11 @@ func (s *Service) GetSnapshot(ctx context.Context, query cloudmigration.GetSnaps
return nil, fmt.Errorf("fetching session for uid %s: %w", sessionUid, err)
}
// Ask GMS for snapshot status while the source of truth is in the cloud
if snapshot.ShouldQueryGMS() {
// ask GMS for status if it's in the cloud
snapshotMeta, err := s.gmsClient.GetSnapshotStatus(ctx, *session, *snapshot)
// Calculate offset based on how many results we currently have responses for
pending := snapshot.StatsRollup.CountsByStatus[cloudmigration.ItemStatusPending]
snapshotMeta, err := s.gmsClient.GetSnapshotStatus(ctx, *session, *snapshot, snapshot.StatsRollup.Total-pending)
if err != nil {
return snapshot, fmt.Errorf("error fetching snapshot status from GMS: sessionUid: %s, snapshotUid: %s", sessionUid, snapshotUid)
}