Skip to content

Commit 0dc9a87

Browse files
author
Abhishek Agarwal
authored
chore(logs): Add logs for volume unstage request (#172)
Signed-off-by: Abhishek Agarwal <abhishek.agarwal@mayadata.io>
1 parent 2cf154a commit 0dc9a87

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

pkg/driver/node.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ func (ns *node) NodeUnstageVolume(
254254
}
255255
defer removeVolumeFromTransitionList(volumeID)
256256

257+
logrus.Infof("Volume with ID: %v after uninitialising is in '%v' state", volumeID, utils.TransitionVolList[volumeID])
258+
257259
if vol, err = utils.GetCStorVolumeAttachment(volumeID + "-" + utils.NodeIDENV); err != nil {
258260
if k8serror.IsNotFound(err) {
259261
logrus.Infof("cva for %s has already been deleted", volumeID)
@@ -281,6 +283,7 @@ func (ns *node) NodeUnstageVolume(
281283
// so all the cases are handled
282284
utils.TransitionVolListLock.Lock()
283285
utils.TransitionVolList[volumeID] = apis.CStorVolumeAttachmentStatusUnmountUnderProgress
286+
logrus.Infof("Volume with ID: %v after starting unmount is in '%v' state", volumeID, utils.TransitionVolList[volumeID])
284287
utils.TransitionVolListLock.Unlock()
285288

286289
if err = iscsiutils.UnmountAndDetachDisk(vol, stagingTargetPath); err != nil {
@@ -289,6 +292,7 @@ func (ns *node) NodeUnstageVolume(
289292

290293
utils.TransitionVolListLock.Lock()
291294
utils.TransitionVolList[volumeID] = apis.CStorVolumeAttachmentStatusUnmounted
295+
logrus.Infof("Volume with ID: %v after successful unmount is in '%v' state", volumeID, utils.TransitionVolList[volumeID])
292296
utils.TransitionVolListLock.Unlock()
293297

294298
vol.Finalizers = nil

pkg/driver/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package driver
1818

1919
import (
2020
"fmt"
21+
"github.com/sirupsen/logrus"
2122

2223
"github.com/container-storage-interface/spec/lib/go/csi"
2324
apisv1 "github.com/openebs/api/v3/pkg/apis/cstor/v1"
@@ -88,6 +89,7 @@ func removeVolumeFromTransitionList(volumeID string) {
8889
utils.TransitionVolListLock.Lock()
8990
defer utils.TransitionVolListLock.Unlock()
9091
delete(utils.TransitionVolList, volumeID)
92+
logrus.Infof("Volume with ID: %v has been successfully removed from the transition volume list: %v", volumeID, utils.TransitionVolList)
9193
}
9294

9395
func addVolumeToTransitionList(volumeID string, status apisv1.CStorVolumeAttachmentStatus) error {

pkg/utils/utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func MonitorMounts() {
272272
for _, vol := range csivolList.Items {
273273
// ignore monitoring for volumes with deletion timestamp set
274274
if vol.DeletionTimestamp != nil {
275+
logrus.Infof("CVA: %v for volume: %v has been marked for cleanup activity", vol.Name, vol.Spec.Volume.Name)
275276
cleanupRequired = true
276277
continue
277278
}
@@ -372,6 +373,8 @@ func Cleanup() (err error) {
372373
}
373374
vol := Vol
374375
TransitionVolList[vol.Spec.Volume.Name] = apis.CStorVolumeAttachmentStatusUnmountUnderProgress
376+
377+
logrus.Infof("Volume: %v marked as %v as part of cleanup activity", vol.Spec.Volume.Name, TransitionVolList[vol.Spec.Volume.Name])
375378
// This is being run in a go routine so that if unmount and detach
376379
// commands take time, the startup is not delayed
377380
go func(vol *apis.CStorVolumeAttachment) {
@@ -388,6 +391,7 @@ func Cleanup() (err error) {
388391

389392
TransitionVolListLock.Lock()
390393
delete(TransitionVolList, vol.Spec.Volume.Name)
394+
logrus.Infof("Volume: %v has been successfully removed from the transition volume list after cleanup: %v", vol.Spec.Volume.Name, TransitionVolList)
391395
TransitionVolListLock.Unlock()
392396
}(&vol)
393397
}

0 commit comments

Comments
 (0)