Skip to content

Commit

Permalink
Merge pull request #2480 from libopenstorage/sradhakrishnan/PWX-38876
Browse files Browse the repository at this point in the history
Improve logging for better debugging of attach/mount and unmount
  • Loading branch information
sradhakrishnan-px authored Sep 11, 2024
2 parents bc42ffa + eca856f commit daa14e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/server/sdk/volume_node_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/libopenstorage/openstorage/api"
mountattachoptions "github.com/libopenstorage/openstorage/pkg/options"
"github.com/libopenstorage/openstorage/volume"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -76,6 +77,7 @@ func (s *VolumeServer) Attach(
}

s.auditLog(ctx, "mountattach.attach", "Volume %s attached", req.GetVolumeId())
logrus.Infof("Volume %s attached on node", req.GetVolumeId())
return &api.SdkVolumeAttachResponse{DevicePath: devPath}, nil
}

Expand Down Expand Up @@ -119,6 +121,7 @@ func (s *VolumeServer) Detach(
}

s.auditLog(ctx, "mountattach.detach", "Volume %s detached", req.GetVolumeId())
logrus.Infof("Volume %s detached on node", req.GetVolumeId())
return &api.SdkVolumeDetachResponse{}, nil
}

Expand Down Expand Up @@ -154,6 +157,7 @@ func (s *VolumeServer) Mount(
err.Error())
}
s.auditLog(ctx, "mountattach.mount", "Volume %s mounted", req.GetVolumeId())
logrus.Infof("Volume %s mounted on node", req.GetVolumeId())
return &api.SdkVolumeMountResponse{}, err
}

Expand Down Expand Up @@ -202,5 +206,6 @@ func (s *VolumeServer) Unmount(
}

s.auditLog(ctx, "mountattach.unmount", "Volume %s mounted", req.GetVolumeId())
logrus.Infof("Volume %s unmounted on node", req.GetVolumeId())
return &api.SdkVolumeUnmountResponse{}, nil
}
5 changes: 5 additions & 0 deletions api/server/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,14 @@ func (vd *volAPI) volumeSet(w http.ResponseWriter, r *http.Request) {
Options: attachOptions,
DriverOptions: req.GetOptions(),
})
vd.logRequest(method, volumeID).Infof("Attachment completed for volume")
} else if req.Action.IsDetach() {
_, err = mountAttachClient.Detach(ctx, &api.SdkVolumeDetachRequest{
VolumeId: volumeID,
Options: detachOptions,
DriverOptions: req.GetOptions(),
})
vd.logRequest(method, volumeID).Infof("Detachment completed for volume")
}

if err == nil {
Expand All @@ -455,6 +457,7 @@ func (vd *volAPI) volumeSet(w http.ResponseWriter, r *http.Request) {
MountPath: req.Action.MountPath,
DriverOptions: req.GetOptions(),
})
vd.logRequest(method, volumeID).Infof("Mount completed for volume on path %s", req.Action.MountPath)
}
} else if req.Action.IsUnMount() {
_, err = mountAttachClient.Unmount(ctx, &api.SdkVolumeUnmountRequest{
Expand All @@ -463,6 +466,7 @@ func (vd *volAPI) volumeSet(w http.ResponseWriter, r *http.Request) {
Options: unmountOptions,
DriverOptions: req.GetOptions(),
})
vd.logRequest(method, volumeID).Infof("Unmount completed for volume on path %s", req.Action.MountPath)
}
}
}
Expand All @@ -483,6 +487,7 @@ func (vd *volAPI) volumeSet(w http.ResponseWriter, r *http.Request) {
} else {
resp.Volume = resVol.GetVolume()
}
vd.logRequest(method, volumeID).Infof("Inspect completed for volume")
// Do not clear inspect err for attach
if err != nil {
resp.VolumeResponse = &api.VolumeResponse{
Expand Down

0 comments on commit daa14e0

Please sign in to comment.