Skip to content

Commit

Permalink
[csi] edit logs
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Ohrimenko <alexandr.ohrimenko@flant.com>
  • Loading branch information
dxavx authored and AleksZimin committed Feb 27, 2024
1 parent efd745b commit 08e098c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
26 changes: 13 additions & 13 deletions images/sds-lvm-csi/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (
func (d *Driver) CreateVolume(ctx context.Context, request *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
d.log.Info("method CreateVolume")

d.log.Info("========== CreateVolume ============")
d.log.Info(request.String())
d.log.Info("========== CreateVolume ============")
d.log.Trace("========== CreateVolume ============")
d.log.Trace(request.String())
d.log.Trace("========== CreateVolume ============")

if len(request.Name) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume Name cannot be empty")
Expand Down Expand Up @@ -102,7 +102,7 @@ func (d *Driver) CreateVolume(ctx context.Context, request *csi.CreateVolumeRequ
llvSpec := utils.GetLLVSpec(*d.log, selectedLVG, storageClassLVGParametersMap, preferredNode, LvmType, *llvSize)
d.log.Info(fmt.Sprintf("LVMLogicalVolumeSpec : %+v", llvSpec))

d.log.Info("------------ CreateLVMLogicalVolume ------------")
d.log.Trace("------------ CreateLVMLogicalVolume start ------------")
_, err = utils.CreateLVMLogicalVolume(ctx, d.cl, llvName, llvSpec)
if err != nil {
if kerrors.IsAlreadyExists(err) {
Expand All @@ -112,9 +112,9 @@ func (d *Driver) CreateVolume(ctx context.Context, request *csi.CreateVolumeRequ
return nil, err
}
}
d.log.Info("------------ CreateLVMLogicalVolume ------------")
d.log.Trace("------------ CreateLVMLogicalVolume end ------------")

d.log.Info("start wait CreateLVMLogicalVolume ")
d.log.Trace("start wait CreateLVMLogicalVolume ")
resizeDelta, err := resource.ParseQuantity(internal.ResizeDelta)
if err != nil {
d.log.Error(err, "error ParseQuantity for ResizeDelta")
Expand All @@ -125,7 +125,7 @@ func (d *Driver) CreateVolume(ctx context.Context, request *csi.CreateVolumeRequ
d.log.Error(err, "error WaitForStatusUpdate")
return nil, err
}
d.log.Info(fmt.Sprintf("stop waiting CreateLVMLogicalVolume, attempt сounter = %d ", attemptCounter))
d.log.Trace(fmt.Sprintf("stop waiting CreateLVMLogicalVolume, attempt сounter = %d ", attemptCounter))

volumeCtx := make(map[string]string, len(request.Parameters))
for k, v := range request.Parameters {
Expand Down Expand Up @@ -176,12 +176,12 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, request *csi.Con
}

func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, request *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
d.log.Info("method ValidateVolumeCapabilities")
d.log.Info("call method ValidateVolumeCapabilities")
return nil, nil
}

func (d *Driver) ListVolumes(ctx context.Context, request *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) {
d.log.Info("method ListVolumes")
d.log.Info("call method ListVolumes")
return nil, nil
}

Expand Down Expand Up @@ -241,11 +241,11 @@ func (d *Driver) ListSnapshots(ctx context.Context, request *csi.ListSnapshotsRe
}

func (d *Driver) ControllerExpandVolume(ctx context.Context, request *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
d.log.Info(" call method ControllerExpandVolume")
d.log.Info("method ControllerExpandVolume")

d.log.Info("========== ControllerExpandVolume ============")
d.log.Info(request.String())
d.log.Info("========== ControllerExpandVolume ============")
d.log.Trace("========== ControllerExpandVolume ============")
d.log.Trace(request.String())
d.log.Trace("========== ControllerExpandVolume ============")

volumeID := request.GetVolumeId()
if len(volumeID) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion images/sds-lvm-csi/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type Driver struct {

// NewDriver returns a CSI plugin that contains the necessary gRPC
// interfaces to interact with Kubernetes over unix domain sockets for
// managaing disks
// managing disks
func NewDriver(ep, driverName, address string, nodeName *string, log *logger.Logger, cl client.Client) (*Driver, error) {

if driverName == "" {
Expand Down
20 changes: 10 additions & 10 deletions images/sds-lvm-csi/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func (d *Driver) NodeUnstageVolume(ctx context.Context, request *csi.NodeUnstage

func (d *Driver) NodePublishVolume(ctx context.Context, request *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
d.log.Info("method NodePublishVolume")
d.log.Info("------------- NodePublishVolume --------------")
d.log.Info(request.String())
d.log.Info("------------- NodePublishVolume --------------")
d.log.Trace("------------- NodePublishVolume --------------")
d.log.Trace(request.String())
d.log.Trace("------------- NodePublishVolume --------------")

dev := fmt.Sprintf("/dev/%s/%s", request.GetVolumeContext()[internal.VGNameKey], request.VolumeId)

Expand Down Expand Up @@ -72,9 +72,9 @@ func (d *Driver) NodePublishVolume(ctx context.Context, request *csi.NodePublish

func (d *Driver) NodeUnpublishVolume(ctx context.Context, request *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
d.log.Info("method NodeUnpublishVolume")
fmt.Println("------------- NodeUnpublishVolume --------------")
fmt.Println(request.String())
fmt.Println("------------- NodeUnpublishVolume --------------")
d.log.Trace("------------- NodeUnpublishVolume --------------")
d.log.Trace(request.String())
d.log.Trace("------------- NodeUnpublishVolume --------------")

err := d.storeManager.Unmount(request.GetTargetPath())
if err != nil {
Expand All @@ -91,9 +91,9 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, request *csi.NodeGetVol
func (d *Driver) NodeExpandVolume(ctx context.Context, request *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
d.log.Info("Call method NodeExpandVolume")

d.log.Info("========== NodeExpandVolume ============")
d.log.Info(request.String())
d.log.Info("========== NodeExpandVolume ============")
d.log.Trace("========== NodeExpandVolume ============")
d.log.Trace(request.String())
d.log.Trace("========== NodeExpandVolume ============")

volumeID := request.GetVolumeId()
volumePath := request.GetVolumePath()
Expand All @@ -114,7 +114,7 @@ func (d *Driver) NodeExpandVolume(ctx context.Context, request *csi.NodeExpandVo
}

func (d *Driver) NodeGetCapabilities(ctx context.Context, request *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
d.log.Info("Call method NodeGetCapabilities")
d.log.Info("method NodeGetCapabilities")

capabilities := []csi.NodeServiceCapability_RPC_Type{
csi.NodeServiceCapability_RPC_GET_VOLUME_STATS,
Expand Down
48 changes: 24 additions & 24 deletions images/sds-lvm-csi/pkg/utils/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func NewStore(logger *logger.Logger) *Store {
func (s *Store) Mount(source, target string, isBlock bool, fsType string, readonly bool, mntOpts []string) error {
s.Log.Info(" ----== Node Mount ==---- ")

s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ Mount options ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Info(fmt.Sprintf("[mount] params source=%s target=%s fs=%s blockMode=%t mountOptions=%v", source, target, fsType, isBlock, mntOpts))
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ Mount options ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ Mount options ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace(fmt.Sprintf("[mount] params source=%s target=%s fs=%s blockMode=%t mountOptions=%v", source, target, fsType, isBlock, mntOpts))
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ Mount options ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")

info, err := os.Stat(source)
if err != nil {
Expand All @@ -64,49 +64,49 @@ func (s *Store) Mount(source, target string, isBlock bool, fsType string, readon
return fmt.Errorf("[NewMount] path %s is not a device", source)
}

s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ MODE SOURCE ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Info(info.Mode().String())
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ MODE SOURCE ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ MODE SOURCE ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace(info.Mode().String())
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ MODE SOURCE ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")

s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ isBlock ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Info(fmt.Sprintf("%t ", isBlock))
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ isBlock ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ isBlock ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace(fmt.Sprintf("%t ", isBlock))
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ isBlock ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")

if !isBlock {
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ FS MOUNT ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Info("-----------------== start MkdirAll ==-----------------")
s.Log.Info("mkdir create dir =" + target)
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ FS MOUNT ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("-----------------== start MkdirAll ==-----------------")
s.Log.Trace("mkdir create dir =" + target)
if err := os.MkdirAll(target, os.FileMode(0755)); err != nil {
return fmt.Errorf("[MkdirAll] could not create target directory %s, %v", target, err)
}
s.Log.Info("-----------------== stop MkdirAll ==-----------------")
s.Log.Trace("-----------------== stop MkdirAll ==-----------------")

needsMount, err := s.NodeStorage.IsMountPoint(target)
if err != nil {
return fmt.Errorf("[s.NodeStorage.IsMountPoint] unable to determine mount status of %s %v", target, err)
}

s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ needsMount ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Info(fmt.Sprintf("%t", needsMount))
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ needsMount ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ needsMount ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace(fmt.Sprintf("%t", needsMount))
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ needsMount ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")

//todo
//if !needsMount {
// return nil
//}

s.Log.Info("-----------------== start FormatAndMount ==---------------")
s.Log.Trace("-----------------== start FormatAndMount ==---------------")
err = s.NodeStorage.FormatAndMount(source, target, fsType, mntOpts)
if err != nil {
return fmt.Errorf("failed to FormatAndMount : %w", err)
}
s.Log.Info("-----------------== stop FormatAndMount ==---------------")
s.Log.Trace("-----------------== stop FormatAndMount ==---------------")
return nil
}

if isBlock {
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ BLOCK MOUNT ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Info("-----------------== start Create File ==---------------")
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ BLOCK MOUNT ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("-----------------== start Create File ==---------------")
f, err := os.OpenFile(target, os.O_CREATE, os.FileMode(0666))
if err != nil {
if !os.IsExist(err) {
Expand All @@ -115,15 +115,15 @@ func (s *Store) Mount(source, target string, isBlock bool, fsType string, readon
} else {
_ = f.Close()
}
s.Log.Info("-----------------== stop Create File ==---------------")
s.Log.Info("-----------------== start Mount ==---------------")
s.Log.Trace("-----------------== stop Create File ==---------------")
s.Log.Trace("-----------------== start Mount ==---------------")
err = s.NodeStorage.Mount(source, target, fsType, mntOpts)
if err != nil {
s.Log.Error(err, "block mount error :")
return err
}
s.Log.Info("-----------------== stop Mount ==---------------")
s.Log.Info("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ BLOCK MOUNT ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
s.Log.Trace("-----------------== stop Mount ==---------------")
s.Log.Trace("≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ BLOCK MOUNT ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
return nil
}
s.Log.Info("-----------------== Final ==---------------")
Expand Down

0 comments on commit 08e098c

Please sign in to comment.