Skip to content

Commit

Permalink
Merge branch 'master' into sc_name
Browse files Browse the repository at this point in the history
  • Loading branch information
pavannd1 committed Aug 14, 2019
2 parents 32d1e4c + 588e737 commit ee9988d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
10 changes: 6 additions & 4 deletions pkg/blockstorage/awsefs/awsefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ func (e *efs) SnapshotGet(ctx context.Context, id string) (*blockstorage.Snapsho
return nil, errors.Wrap(err, "Failed to get volume ID from recovery point ARN")
}
vol, err := e.VolumeGet(ctx, volID, "")
if err != nil {
return nil, errors.Wrap(err, "Failed to get originating volume")
if err != nil && !isVolumeNotFound(err) {
return nil, errors.Wrap(err, "Failed to get filesystem")
}
return snapshotFromRecoveryPoint(resp, vol, e.region)
}
Expand Down Expand Up @@ -459,9 +459,11 @@ func (e *efs) snapshotsFromRecoveryPoints(ctx context.Context, rps []*backup.Rec
if err != nil {
return nil, errors.Wrap(err, "Failed to get volume ID from recovery point ARN")
}
// VolumeGet might return error since originating filesystem might have
// been deleted.
vol, err := e.VolumeGet(ctx, volID, "")
if err != nil {
return nil, errors.Wrap(err, "Failed to get EFS volume")
if err != nil && !isVolumeNotFound(err) {
return nil, errors.Wrap(err, "Failed to get filesystem")
}
snap, err := snapshotFromRecoveryPointByVault(rp, vol, tags, e.region)
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions pkg/blockstorage/awsefs/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ func snapshotFromRecoveryPoint(rp *backup.DescribeRecoveryPointOutput, volume *b
if rp.RecoveryPointArn == nil {
return nil, errors.New("Recovery point has no RecoveryPointArn")
}
encrypted := false
if volume != nil {
encrypted = volume.Encrypted
}
return &blockstorage.Snapshot{
ID: *rp.RecoveryPointArn,
CreationTime: blockstorage.TimeStamp(*rp.CreationDate),
Size: bytesInGiB(*rp.BackupSizeInBytes),
Region: region,
Type: blockstorage.TypeEFS,
Volume: volume,
Encrypted: volume.Encrypted,
Encrypted: encrypted,
Tags: nil,
}, nil
}
Expand All @@ -90,8 +94,9 @@ func snapshotFromRecoveryPointByVault(rp *backup.RecoveryPointByBackupVault, vol
if rp.RecoveryPointArn == nil {
return nil, errors.New("Recovery point has no RecoveryPointArn")
}
if volume == nil {
return nil, errors.New("Nil volume as argument")
encrypted := false
if volume != nil {
encrypted = volume.Encrypted
}
return &blockstorage.Snapshot{
ID: *rp.RecoveryPointArn,
Expand All @@ -100,7 +105,7 @@ func snapshotFromRecoveryPointByVault(rp *backup.RecoveryPointByBackupVault, vol
Region: region,
Type: blockstorage.TypeEFS,
Volume: volume,
Encrypted: volume.Encrypted,
Encrypted: encrypted,
Tags: blockstorage.MapToKeyValue(tags),
}, nil
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/blockstorage/awsefs/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/backup"
awsefs "github.com/aws/aws-sdk-go/service/efs"
"github.com/pkg/errors"
)

func isVolumeNotFound(err error) bool {
if awsErr, ok := err.(awserr.Error); ok {
return awsErr.Code() == awsefs.ErrCodeFileSystemNotFound
switch errV := errors.Cause(err).(type) {
case awserr.Error:
return errV.Code() == awsefs.ErrCodeFileSystemNotFound
default:
return false
}
return false
}

func isBackupVaultAlreadyExists(err error) bool {
Expand Down

0 comments on commit ee9988d

Please sign in to comment.