Don't check source PV when restoring from snapshot
The original PV could have been deleted.
Issue
@@ -47,21 +47,6 @@ func newSnapshotProvisioner(
var _ controller.Provisioner = &snapshotProvisioner{}
-func (p *snapshotProvisioner) getPVFromVolumeSnapshotDataSpec(snapshotDataSpec *crdv1.VolumeSnapshotDataSpec) (*v1.PersistentVolume, error) {
- if snapshotDataSpec.PersistentVolumeRef == nil {
- return nil, fmt.Errorf("VolumeSnapshotDataSpec is not bound to any PV")
- }
- pvName := snapshotDataSpec.PersistentVolumeRef.Name
- if pvName == "" {
- return nil, fmt.Errorf("The PV name is not specified in snapshotdata %#v", *snapshotDataSpec)
- }
- pv, err := p.client.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
- if err != nil {
- return nil, fmt.Errorf("Failed to retrieve PV %s from the API server: %q", pvName, err)
- }
- return pv, nil
-}
-
func (p *snapshotProvisioner) snapshotRestore(
snapshotName string,
snapshotData crdv1.VolumeSnapshotData,
@@ -69,13 +54,9 @@ func (p *snapshotProvisioner) snapshotRestore(
) (*v1.PersistentVolumeSource, map[string]string, error) {
// validate the PV supports snapshot and restore
spec := &snapshotData.Spec
- pv, err := p.getPVFromVolumeSnapshotDataSpec(spec)
- if err != nil {
- return nil, nil, err
- }
- volumeType := crdv1.GetSupportedVolumeFromPVSpec(&pv.Spec)
+ volumeType := crdv1.GetSupportedVolumeFromSnapshotDataSpec(spec)
if len(volumeType) == 0 {
- return nil, nil, fmt.Errorf("unsupported volume type found in PV %#v", *spec)
+ return nil, nil, fmt.Errorf("unsupported volume type found in SnapshotData %#v", *spec)
}
plugin, ok := p.volumePlugins[volumeType]
if !ok {
