From 0dc9a875d59d02c5e22ba53d13ed3ebaf75ffd88 Mon Sep 17 00:00:00 2001 From: Abhishek Agarwal Date: Thu, 30 Jun 2022 12:37:40 +0530 Subject: [PATCH] chore(logs): Add logs for volume unstage request (#172) Signed-off-by: Abhishek Agarwal --- pkg/driver/node.go | 4 ++++ pkg/driver/utils.go | 2 ++ pkg/utils/utils.go | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/pkg/driver/node.go b/pkg/driver/node.go index e51a292d3..9ddbc22e5 100644 --- a/pkg/driver/node.go +++ b/pkg/driver/node.go @@ -254,6 +254,8 @@ func (ns *node) NodeUnstageVolume( } defer removeVolumeFromTransitionList(volumeID) + logrus.Infof("Volume with ID: %v after uninitialising is in '%v' state", volumeID, utils.TransitionVolList[volumeID]) + if vol, err = utils.GetCStorVolumeAttachment(volumeID + "-" + utils.NodeIDENV); err != nil { if k8serror.IsNotFound(err) { logrus.Infof("cva for %s has already been deleted", volumeID) @@ -281,6 +283,7 @@ func (ns *node) NodeUnstageVolume( // so all the cases are handled utils.TransitionVolListLock.Lock() utils.TransitionVolList[volumeID] = apis.CStorVolumeAttachmentStatusUnmountUnderProgress + logrus.Infof("Volume with ID: %v after starting unmount is in '%v' state", volumeID, utils.TransitionVolList[volumeID]) utils.TransitionVolListLock.Unlock() if err = iscsiutils.UnmountAndDetachDisk(vol, stagingTargetPath); err != nil { @@ -289,6 +292,7 @@ func (ns *node) NodeUnstageVolume( utils.TransitionVolListLock.Lock() utils.TransitionVolList[volumeID] = apis.CStorVolumeAttachmentStatusUnmounted + logrus.Infof("Volume with ID: %v after successful unmount is in '%v' state", volumeID, utils.TransitionVolList[volumeID]) utils.TransitionVolListLock.Unlock() vol.Finalizers = nil diff --git a/pkg/driver/utils.go b/pkg/driver/utils.go index cbdc7e3b6..3c1070b46 100644 --- a/pkg/driver/utils.go +++ b/pkg/driver/utils.go @@ -18,6 +18,7 @@ package driver import ( "fmt" + "github.com/sirupsen/logrus" "github.com/container-storage-interface/spec/lib/go/csi" apisv1 "github.com/openebs/api/v3/pkg/apis/cstor/v1" @@ -88,6 +89,7 @@ func removeVolumeFromTransitionList(volumeID string) { utils.TransitionVolListLock.Lock() defer utils.TransitionVolListLock.Unlock() delete(utils.TransitionVolList, volumeID) + logrus.Infof("Volume with ID: %v has been successfully removed from the transition volume list: %v", volumeID, utils.TransitionVolList) } func addVolumeToTransitionList(volumeID string, status apisv1.CStorVolumeAttachmentStatus) error { diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 5e1a47ac0..886c5ce02 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -272,6 +272,7 @@ func MonitorMounts() { for _, vol := range csivolList.Items { // ignore monitoring for volumes with deletion timestamp set if vol.DeletionTimestamp != nil { + logrus.Infof("CVA: %v for volume: %v has been marked for cleanup activity", vol.Name, vol.Spec.Volume.Name) cleanupRequired = true continue } @@ -372,6 +373,8 @@ func Cleanup() (err error) { } vol := Vol TransitionVolList[vol.Spec.Volume.Name] = apis.CStorVolumeAttachmentStatusUnmountUnderProgress + + logrus.Infof("Volume: %v marked as %v as part of cleanup activity", vol.Spec.Volume.Name, TransitionVolList[vol.Spec.Volume.Name]) // This is being run in a go routine so that if unmount and detach // commands take time, the startup is not delayed go func(vol *apis.CStorVolumeAttachment) { @@ -388,6 +391,7 @@ func Cleanup() (err error) { TransitionVolListLock.Lock() delete(TransitionVolList, vol.Spec.Volume.Name) + logrus.Infof("Volume: %v has been successfully removed from the transition volume list after cleanup: %v", vol.Spec.Volume.Name, TransitionVolList) TransitionVolListLock.Unlock() }(&vol) }