Skip to content

Commit

Permalink
Merge pull request #320 from jacobwolfaws/master
Browse files Browse the repository at this point in the history
Update log functions
  • Loading branch information
k8s-ci-robot committed May 26, 2023
2 parents 76115d5 + 35e5340 commit df9352b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (c *cloud) WaitForFileSystemAvailable(ctx context.Context, fileSystemId str
if err != nil {
return true, err
}
klog.V(2).Infof("WaitForFileSystemAvailable filesystem %q status is: %q", fileSystemId, *fs.Lifecycle)
klog.V(2).InfoS("WaitForFileSystemAvailable", "filesystem", fileSystemId, "status", *fs.Lifecycle)
switch *fs.Lifecycle {
case "AVAILABLE":
return true, nil
Expand All @@ -361,7 +361,7 @@ func (c *cloud) WaitForFileSystemResize(ctx context.Context, fileSystemId string
return true, err
}

klog.V(2).Infof("WaitForFileSystemResize filesystem %q update status is: %q", fileSystemId, *updateAction.Status)
klog.V(2).InfoS("WaitForFileSystemResize", "filesystem", fileSystemId, "update status", *updateAction.Status)
switch *updateAction.Status {
case "PENDING", "IN_PROGRESS":
// The resizing workflow has not completed
Expand Down
18 changes: 9 additions & 9 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func newControllerService(driverOptions *DriverOptions) controllerService {
}
}
func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
klog.V(4).Infof("CreateVolume: called with args %#v", req)
klog.V(4).InfoS("CreateVolume: called", "args", *req)
volName := req.GetName()
if len(volName) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume name not provided")
Expand Down Expand Up @@ -237,7 +237,7 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
}

func (d *controllerService) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
klog.V(4).Infof("DeleteVolume: called with args: %#v", req)
klog.V(4).InfoS("DeleteVolume: called", "args", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand All @@ -252,7 +252,7 @@ func (d *controllerService) DeleteVolume(ctx context.Context, req *csi.DeleteVol

if err := d.cloud.DeleteFileSystem(ctx, volumeID); err != nil {
if err == cloud.ErrNotFound {
klog.V(4).Infof("DeleteVolume: volume not found, returning with success")
klog.V(4).InfoS("DeleteVolume: volume not found, returning with success")
return &csi.DeleteVolumeResponse{}, nil
}
return nil, status.Errorf(codes.Internal, "Could not delete volume ID %q: %v", volumeID, err)
Expand All @@ -269,7 +269,7 @@ func (d *controllerService) ControllerUnpublishVolume(ctx context.Context, req *
}

func (d *controllerService) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
klog.V(4).Infof("ControllerGetCapabilities: called with args %#v", req)
klog.V(4).InfoS("ControllerGetCapabilities: called", "args", *req)
var caps []*csi.ControllerServiceCapability
for _, cap := range controllerCaps {
c := &csi.ControllerServiceCapability{
Expand All @@ -285,17 +285,17 @@ func (d *controllerService) ControllerGetCapabilities(ctx context.Context, req *
}

func (d *controllerService) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
klog.V(4).Infof("GetCapacity: called with args %#v", req)
klog.V(4).InfoS("GetCapacity: called", "args", *req)
return nil, status.Error(codes.Unimplemented, "")
}

func (d *controllerService) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) {
klog.V(4).Infof("ListVolumes: called with args %#v", req)
klog.V(4).InfoS("ListVolumes: called", "args", *req)
return nil, status.Error(codes.Unimplemented, "")
}

func (d *controllerService) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
klog.V(4).Infof("ValidateVolumeCapabilities: called with args %#v", req)
klog.V(4).InfoS("ValidateVolumeCapabilities: called", "args", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand Down Expand Up @@ -361,7 +361,7 @@ func (d *controllerService) ListSnapshots(ctx context.Context, req *csi.ListSnap
}

func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
klog.V(4).Infof("ControllerExpandVolume: called with args %+v", *req)
klog.V(4).InfoS("ControllerExpandVolume: called", "args", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand Down Expand Up @@ -389,7 +389,7 @@ func (d *controllerService) ControllerExpandVolume(ctx context.Context, req *csi
}
if newSizeGiB <= fs.CapacityGiB {
// Current capacity is sufficient to satisfy the request
klog.V(4).Infof("ControllerExpandVolume: current filesystem capacity of %d GiB matches or exceeds requested storage capacity of %d GiB, returning with success", fs.CapacityGiB, newSizeGiB)
klog.V(4).InfoS("ControllerExpandVolume: current filesystem capacity matches or exceeds requested storage capacity, returning with success", "current capacity", fs.CapacityGiB, "requested capacity", newSizeGiB)
return &csi.ControllerExpandVolumeResponse{
CapacityBytes: util.GiBToBytes(fs.CapacityGiB),
NodeExpansionRequired: false,
Expand Down
6 changes: 3 additions & 3 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (d *Driver) Run() error {
logErr := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
resp, err := handler(ctx, req)
if err != nil {
klog.Errorf("GRPC error: %v", err)
klog.ErrorS(err, "GRPC error")
}
return resp, err
}
Expand All @@ -123,12 +123,12 @@ func (d *Driver) Run() error {
return fmt.Errorf("unknown mode: %s", d.options.mode)
}

klog.Infof("Listening for connections on address: %#v", listener.Addr())
klog.V(4).InfoS("Listening for connections", "address", listener.Addr())
return d.srv.Serve(listener)
}

func (d *Driver) Stop() {
klog.Infof("Stopping server")
klog.InfoS("Stopping server")
d.srv.Stop()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/internal/inflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ func (db *InFlight) Delete(key string) {
defer db.mux.Unlock()

delete(db.inFlight, key)
klog.V(4).InfoS("Node Service: volume operation finished", "key", key)
klog.V(4).InfoS("Volume operation finished", "key", key)
}
26 changes: 13 additions & 13 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (d *nodeService) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
}

func (d *nodeService) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
klog.V(4).Infof("NodePublishVolume: called with args %+v", req)
klog.V(4).InfoS("NodePublishVolume: called with", "args", *req)

volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
Expand Down Expand Up @@ -137,7 +137,7 @@ func (d *nodeService) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}
}
}
klog.V(5).Infof("NodePublishVolume: creating dir %s", target)
klog.V(5).InfoS("NodePublishVolume: creating", "dir", target)
if err := d.mounter.MakeDir(target); err != nil {
return nil, status.Errorf(codes.Internal, "Could not create dir %q: %v", target, err)
}
Expand All @@ -148,19 +148,19 @@ func (d *nodeService) NodePublishVolume(ctx context.Context, req *csi.NodePublis
return nil, status.Errorf(codes.Internal, "Could not check if %q is mounted: %v", target, err)
}
if !mounted {
klog.V(5).Infof("NodePublishVolume: mounting %s at %s with options %v", source, target, mountOptions)
klog.V(4).InfoS("NodePublishVolume: mounting", "source", source, "target", target, "mountOptions", mountOptions)
if err := d.mounter.Mount(source, target, "lustre", mountOptions); err != nil {
os.Remove(target)
return nil, status.Errorf(codes.Internal, "Could not mount %q at %q: %v", source, target, err)
}
klog.V(5).Infof("NodePublishVolume: %s was mounted", target)
klog.V(5).InfoS("NodePublishVolume: was mounted", "target", target)
}

return &csi.NodePublishVolumeResponse{}, nil
}

func (d *nodeService) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
klog.V(4).Infof("NodeUnpublishVolume: called with args %+v", req)
klog.V(4).InfoS("NodeUnpublishVolume: called", "args", *req)

volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
Expand All @@ -174,11 +174,11 @@ func (d *nodeService) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
// Check if the target is mounted before unmounting
notMnt, _ := d.mounter.IsLikelyNotMountPoint(target)
if notMnt {
klog.V(5).Infof("NodeUnpublishVolume: target path %s not mounted, skipping unmount", target)
klog.V(5).InfoS("NodeUnpublishVolume: target path not mounted, skipping unmount", "target", target)
return &csi.NodeUnpublishVolumeResponse{}, nil
}

klog.V(5).Infof("NodeUnpublishVolume: unmounting %s", target)
klog.V(5).InfoS("NodeUnpublishVolume: unmounting", "target", target)
err := d.mounter.Unmount(target)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not unmount %q: %v", target, err)
Expand All @@ -196,7 +196,7 @@ func (d *nodeService) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV
}

func (d *nodeService) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
klog.V(4).Infof("NodeGetCapabilities: called with args %+v", req)
klog.V(4).InfoS("NodeGetCapabilities: called", "args", *req)
var caps []*csi.NodeServiceCapability
for _, cap := range nodeCaps {
c := &csi.NodeServiceCapability{
Expand All @@ -212,7 +212,7 @@ func (d *nodeService) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
}

func (d *nodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
klog.V(4).Infof("NodeGetInfo: called with args %+v", req)
klog.V(4).InfoS("NodeGetInfo: called", "args", *req)

return &csi.NodeGetInfoResponse{
NodeId: d.metadata.GetInstanceID(),
Expand All @@ -228,13 +228,13 @@ func (d *nodeService) isMounted(source string, target string) (bool, error) {
2. false, nil when the path is already mounted with a device.
3. true, nil when the path is not mounted with any device.
*/
klog.V(4).Infoln(target)
klog.V(4).InfoS(target)
notMnt, err := d.mounter.IsLikelyNotMountPoint(target)
if err != nil && !os.IsNotExist(err) {
//Checking if the path exists and error is related to Corrupted Mount, in that case, the system could unmount and mount.
_, pathErr := d.mounter.PathExists(target)
if pathErr != nil && d.mounter.IsCorruptedMnt(pathErr) {
klog.V(4).Infof("NodePublishVolume: Target path %q is a corrupted mount. Trying to unmount.", target)
klog.V(4).InfoS("NodePublishVolume: Target path is a corrupted mount. Trying to unmount.", "target", target)
if mntErr := d.mounter.Unmount(target); mntErr != nil {
return false, status.Errorf(codes.Internal, "Unable to unmount the target %q : %v", target, mntErr)
}
Expand All @@ -251,12 +251,12 @@ func (d *nodeService) isMounted(source string, target string) (bool, error) {
// and in others it is an error (in Linux, the target mount directory must
// exist before mount is called on it)
if err != nil && os.IsNotExist(err) {
klog.V(5).Infof("[Debug] NodePublishVolume: Target path %q does not exist", target)
klog.V(5).InfoS("[Debug] NodePublishVolume: Target path does not exist", "target", target)
return false, nil
}

if !notMnt {
klog.V(4).Infof("NodePublishVolume: Target path %q is already mounted", target)
klog.V(4).InfoS("NodePublishVolume: Target path is already mounted", "target", target)
}

return !notMnt, nil
Expand Down

0 comments on commit df9352b

Please sign in to comment.