Skip to content

Commit

Permalink
make snapshot delete idempotent (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
bathina2 committed Sep 23, 2021
1 parent e123505 commit 822a6ef
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/blockstorage/vmware/vmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,16 @@ func (p *FcdProvider) SnapshotDelete(ctx context.Context, snapshot *blockstorage
log.Debug().Print("SnapshotDelete", field.M{"VolumeID": volID, "SnapshotID": snapshotID})
task, lerr := p.Gom.DeleteSnapshot(ctx, vimID(volID), vimID(snapshotID))
if lerr != nil {
return false, errors.Wrap(lerr, "Failed to delete snapshot")
if soap.IsSoapFault(lerr) {
soapFault := soap.ToSoapFault(lerr)
receivedFault := soapFault.Detail.Fault
_, ok := receivedFault.(types.NotFound)
if ok {
log.Debug().Print("The FCD id was not found in VC during deletion, assuming success", field.M{"err": lerr, "VolumeID": volID, "SnapshotID": snapshotID})
return true, nil
}
}
return false, errors.Wrap(lerr, "Failed to create a task for the DeleteSnapshot invocation on an IVD Protected Entity")
}
log.Debug().Print("Started SnapshotDelete task", field.M{"VolumeID": volID, "SnapshotID": snapshotID})
_, lerr = task.Wait(ctx, vmWareTimeout)
Expand Down

0 comments on commit 822a6ef

Please sign in to comment.