Skip to content

Commit

Permalink
feat: inherit snapshot nfs server params from src vol
Browse files Browse the repository at this point in the history
  • Loading branch information
wozniakjan committed Mar 20, 2023
1 parent 9cad732 commit ba82cb4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/nfs/controllerserver.go
Expand Up @@ -289,7 +289,11 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
return nil, status.Error(codes.InvalidArgument, "CreateSnapshot name must be provided")
}

snapshot, err := newNFSSnapshot(req.GetName(), req.GetParameters())
srcVol, err := getNfsVolFromID(req.GetSourceVolumeId())
if err != nil {
return nil, status.Errorf(codes.NotFound, "failed to create source volume: %v", err)
}
snapshot, err := newNFSSnapshot(req.GetName(), req.GetParameters(), srcVol)
if err != nil {
return nil, status.Errorf(codes.NotFound, "failed to create nfsSnapshot: %v", err)
}
Expand All @@ -303,10 +307,6 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
}
}()

srcVol, err := getNfsVolFromID(req.GetSourceVolumeId())
if err != nil {
return nil, status.Errorf(codes.NotFound, "failed to create source volume: %v", err)
}
if err = cs.internalMount(ctx, srcVol, nil, nil); err != nil {
return nil, status.Errorf(codes.Internal, "failed to mount src nfs server: %v", err)
}
Expand Down Expand Up @@ -545,8 +545,9 @@ func (cs *ControllerServer) copyVolume(ctx context.Context, req *csi.CreateVolum
}

// newNFSSnapshot Convert VolumeSnapshot parameters to a nfsSnapshot
func newNFSSnapshot(name string, params map[string]string) (*nfsSnapshot, error) {
var server, baseDir string
func newNFSSnapshot(name string, params map[string]string, vol *nfsVolume) (*nfsSnapshot, error) {
server := vol.server
baseDir := vol.baseDir
for k, v := range params {
switch strings.ToLower(k) {
case paramServer:
Expand Down

0 comments on commit ba82cb4

Please sign in to comment.