cephfs: replace klog.Error with util.ErrorLog in ControllerExpand

replace klog.Error with util.ErrorLog in ControllerExpand
for context based logging.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-08-11 16:54:15 +05:30 committed by mergify[bot]
parent 7ed5dfe81a
commit 81b52b311d

View File

@ -380,7 +380,7 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
// ControllerExpandVolume expands CephFS Volumes on demand based on resizer request. // ControllerExpandVolume expands CephFS Volumes on demand based on resizer request.
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) { func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
if err := cs.validateExpandVolumeRequest(req); err != nil { if err := cs.validateExpandVolumeRequest(req); err != nil {
klog.Errorf(util.Log(ctx, "ControllerExpandVolumeRequest validation failed: %v"), err) util.ErrorLog(ctx, "ControllerExpandVolumeRequest validation failed: %v", err)
return nil, err return nil, err
} }
@ -389,14 +389,14 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
// lock out parallel delete operations // lock out parallel delete operations
if acquired := cs.VolumeLocks.TryAcquire(volID); !acquired { if acquired := cs.VolumeLocks.TryAcquire(volID); !acquired {
klog.Errorf(util.Log(ctx, util.VolumeOperationAlreadyExistsFmt), volID) util.ErrorLog(ctx, util.VolumeOperationAlreadyExistsFmt, volID)
return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volID) return nil, status.Errorf(codes.Aborted, util.VolumeOperationAlreadyExistsFmt, volID)
} }
defer cs.VolumeLocks.Release(volID) defer cs.VolumeLocks.Release(volID)
// lock out volumeID for clone and delete operation // lock out volumeID for clone and delete operation
if err := cs.OperationLocks.GetExpandLock(volID); err != nil { if err := cs.OperationLocks.GetExpandLock(volID); err != nil {
klog.Error(util.Log(ctx, err.Error())) util.ErrorLog(ctx, err.Error())
return nil, status.Error(codes.Aborted, err.Error()) return nil, status.Error(codes.Aborted, err.Error())
} }
defer cs.OperationLocks.ReleaseExpandLock(volID) defer cs.OperationLocks.ReleaseExpandLock(volID)
@ -410,14 +410,14 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
volOptions, volIdentifier, err := newVolumeOptionsFromVolID(ctx, volID, nil, secret) volOptions, volIdentifier, err := newVolumeOptionsFromVolID(ctx, volID, nil, secret)
if err != nil { if err != nil {
klog.Errorf(util.Log(ctx, "validation and extraction of volume options failed: %v"), err) util.ErrorLog(ctx, "validation and extraction of volume options failed: %v", err)
return nil, status.Error(codes.InvalidArgument, err.Error()) return nil, status.Error(codes.InvalidArgument, err.Error())
} }
RoundOffSize := util.RoundOffBytes(req.GetCapacityRange().GetRequiredBytes()) RoundOffSize := util.RoundOffBytes(req.GetCapacityRange().GetRequiredBytes())
if err = resizeVolume(ctx, volOptions, cr, volumeID(volIdentifier.FsSubvolName), RoundOffSize); err != nil { if err = resizeVolume(ctx, volOptions, cr, volumeID(volIdentifier.FsSubvolName), RoundOffSize); err != nil {
klog.Errorf(util.Log(ctx, "failed to expand volume %s: %v"), volumeID(volIdentifier.FsSubvolName), err) util.ErrorLog(ctx, "failed to expand volume %s: %v", volumeID(volIdentifier.FsSubvolName), err)
return nil, status.Error(codes.Internal, err.Error()) return nil, status.Error(codes.Internal, err.Error())
} }