Skip to content

Commit

Permalink
cleanup: incorrect fuserecovery logging
Browse files Browse the repository at this point in the history
Signed-off-by: Praveen M <[email protected]>
  • Loading branch information
iPraveenParihar committed May 6, 2024
1 parent 6db7138 commit 29d2faa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
36 changes: 26 additions & 10 deletions internal/cephfs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ func (ns *NodeServer) NodeStageVolume(

// Check if the volume is already mounted

if err = ns.tryRestoreFuseMountInNodeStage(ctx, mnt, stagingTargetPath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to try to restore FUSE mounts: %v", err)
if _, ok := mnt.(*mounter.FuseMounter); ok {
if err = ns.tryRestoreFuseMountInNodeStage(ctx, mnt, stagingTargetPath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to try to restore FUSE mounts: %v", err)
}
}

isMnt, err := util.IsMountPoint(ns.Mounter, stagingTargetPath)
Expand Down Expand Up @@ -446,6 +448,18 @@ func (ns *NodeServer) NodePublishVolume(
targetPath := req.GetTargetPath()
volID := fsutil.VolumeID(req.GetVolumeId())

volOptions := &store.VolumeOptions{}
defer volOptions.Destroy()

if err := store.ExtractMounter(&volOptions.Mounter, req.GetVolumeContext()); err != nil {
return nil, err
}

volMounter, err := mounter.New(volOptions)
if err != nil {
return nil, err
}

// Considering kubelet make sure the stage and publish operations
// are serialized, we dont need any extra locking in nodePublish

Expand All @@ -455,14 +469,16 @@ func (ns *NodeServer) NodePublishVolume(
return nil, status.Error(codes.Internal, err.Error())
}

if err := ns.tryRestoreFuseMountsInNodePublish(
ctx,
volID,
stagingTargetPath,
targetPath,
req.GetVolumeContext(),
); err != nil {
return nil, status.Errorf(codes.Internal, "failed to try to restore FUSE mounts: %v", err)
if _, ok := volMounter.(*mounter.FuseMounter); ok {
if err := ns.tryRestoreFuseMountsInNodePublish(
ctx,
volID,
stagingTargetPath,
targetPath,
req.GetVolumeContext(),
); err != nil {
return nil, status.Errorf(codes.Internal, "failed to try to restore FUSE mounts: %v", err)
}
}

if req.GetReadonly() {
Expand Down
10 changes: 5 additions & 5 deletions internal/cephfs/store/volumeoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func validateMounter(m string) error {
return nil
}

func extractMounter(dest *string, options map[string]string) error {
func ExtractMounter(dest *string, options map[string]string) error {
if err := extractOptionalOption(dest, "mounter", options); err != nil {
return err
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func NewVolumeOptions(
return nil, err
}

if err = extractMounter(&opts.Mounter, volOptions); err != nil {
if err = ExtractMounter(&opts.Mounter, volOptions); err != nil {
return nil, err
}

Expand Down Expand Up @@ -463,7 +463,7 @@ func NewVolumeOptionsFromVolID(
return nil, nil, err
}

if err = extractMounter(&volOptions.Mounter, volOpt); err != nil {
if err = ExtractMounter(&volOptions.Mounter, volOpt); err != nil {
return nil, nil, err
}

Expand Down Expand Up @@ -644,7 +644,7 @@ func NewVolumeOptionsFromMonitorList(
return nil, nil, err
}

if err = extractMounter(&opts.Mounter, options); err != nil {
if err = ExtractMounter(&opts.Mounter, options); err != nil {
return nil, nil, err
}

Expand Down Expand Up @@ -728,7 +728,7 @@ func NewVolumeOptionsFromStaticVolume(
return nil, nil, err
}

if err = extractMounter(&opts.Mounter, options); err != nil {
if err = ExtractMounter(&opts.Mounter, options); err != nil {
return nil, nil, err
}

Expand Down

0 comments on commit 29d2faa

Please sign in to comment.