Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement method SnapshotCreateWaitForCompletion for AdStorage type #2494

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions pkg/blockstorage/azure/azuredisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,15 @@ func (s *AdStorage) SnapshotCreate(ctx context.Context, volume blockstorage.Volu
}

func (s *AdStorage) SnapshotCreateWaitForCompletion(ctx context.Context, snap *blockstorage.Snapshot) error {
return nil
err := poll.Wait(ctx, func(ctx context.Context) (bool, error) {
snapshot, err := s.SnapshotGet(ctx, snap.ID)
if err == nil && snapshot.ProvisioningState == string(azcompute.ProvisioningStateSucceeded) {
return true, nil
}

return false, nil
})
return err
}

const (
Expand Down Expand Up @@ -440,14 +448,15 @@ func (s *AdStorage) snapshotParse(ctx context.Context, snap azcompute.Snapshot)
tags = azto.StringMap(snap.Tags)
}
return &blockstorage.Snapshot{
Encrypted: encrypted,
ID: azto.String(snap.ID),
Region: azto.String(snap.Location),
SizeInBytes: azto.Int64(snap.SnapshotProperties.DiskSizeBytes),
Tags: blockstorage.MapToKeyValue(tags),
Type: s.Type(),
Volume: vol,
CreationTime: blockstorage.TimeStamp(snapCreationTime.ToTime()),
Encrypted: encrypted,
ID: azto.String(snap.ID),
Region: azto.String(snap.Location),
SizeInBytes: azto.Int64(snap.SnapshotProperties.DiskSizeBytes),
Tags: blockstorage.MapToKeyValue(tags),
Type: s.Type(),
Volume: vol,
CreationTime: blockstorage.TimeStamp(snapCreationTime.ToTime()),
ProvisioningState: *snap.ProvisioningState,
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/blockstorage/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type Snapshot struct {

// volume
Volume *Volume

// ProvisioningState is snapshot's provisioning state.
ProvisioningState string
}

// TimeStamp Time stamp for an event related to an object, for example when the object was created.
Expand Down