Skip to content

Commit 9f9c7a8

Browse files
committed
chore: provide a driver flag to print volume stats call with log level 2
1 parent 44a7d82 commit 9f9c7a8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

pkg/azurefile/azurefile.go

+3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ type DriverOptions struct {
202202
AppendNoShareSockOption bool
203203
SkipMatchingTagCacheExpireInMinutes int
204204
VolStatsCacheExpireInMinutes int
205+
PrintVolumeStatsCallLogs bool
205206
}
206207

207208
// Driver implements all interfaces of CSI drivers
@@ -222,6 +223,7 @@ type Driver struct {
222223
kubeAPIQPS float64
223224
kubeAPIBurst int
224225
appendNoShareSockOption bool
226+
printVolumeStatsCallLogs bool
225227
fileClient *azureFileClient
226228
mounter *mount.SafeFormatAndMount
227229
// lock per volume attach (only for vhd disk feature)
@@ -272,6 +274,7 @@ func NewDriver(options *DriverOptions) *Driver {
272274
driver.kubeAPIQPS = options.KubeAPIQPS
273275
driver.kubeAPIBurst = options.KubeAPIBurst
274276
driver.appendNoShareSockOption = options.AppendNoShareSockOption
277+
driver.printVolumeStatsCallLogs = options.PrintVolumeStatsCallLogs
275278
driver.volLockMap = newLockMap()
276279
driver.subnetLockMap = newLockMap()
277280
driver.volumeLocks = newVolumeLocks()

pkg/azurefile/nodeserver.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,11 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS
468468
return nil, status.Errorf(codes.Internal, "failed to stat file %s: %v", req.VolumePath, err)
469469
}
470470

471-
klog.V(6).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath)
471+
if d.printVolumeStatsCallLogs {
472+
klog.V(2).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath)
473+
} else {
474+
klog.V(6).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath)
475+
}
472476

473477
volumeMetrics, err := volume.NewMetricsStatFS(req.VolumePath).GetMetrics()
474478
if err != nil {
@@ -518,7 +522,11 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS
518522
},
519523
}
520524

521-
klog.V(6).Infof("NodeGetVolumeStats: volume stats for volume %s path %s is %v", req.VolumeId, req.VolumePath, resp)
525+
if d.printVolumeStatsCallLogs {
526+
klog.V(2).Infof("NodeGetVolumeStats: volume stats for volume %s path %s is %v", req.VolumeId, req.VolumePath, resp)
527+
} else {
528+
klog.V(6).Infof("NodeGetVolumeStats: volume stats for volume %s path %s is %v", req.VolumeId, req.VolumePath, resp)
529+
}
522530
// cache the volume stats per volume
523531
d.volStatsCache.Set(req.VolumeId, *resp)
524532
if newVolID != "" {

pkg/azurefileplugin/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var (
5858
appendNoShareSockOption = flag.Bool("append-nosharesock-option", true, "Whether appending nosharesock option to smb mount command")
5959
skipMatchingTagCacheExpireInMinutes = flag.Int("skip-matching-tag-cache-expire-in-minutes", 30, "The cache expire time in minutes for skipMatchingTagCache")
6060
volStatsCacheExpireInMinutes = flag.Int("vol-stats-cache-expire-in-minutes", 10, "The cache expire time in minutes for volume stats cache")
61+
printVolumeStatsCallLogs = flag.Bool("print-volume-stats-call-logs", false, "Whether to print volume statfs call logs with log level 2")
6162
)
6263

6364
func main() {
@@ -101,6 +102,7 @@ func handle() {
101102
AppendNoShareSockOption: *appendNoShareSockOption,
102103
SkipMatchingTagCacheExpireInMinutes: *skipMatchingTagCacheExpireInMinutes,
103104
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
105+
PrintVolumeStatsCallLogs: *printVolumeStatsCallLogs,
104106
}
105107
driver := azurefile.NewDriver(&driverOptions)
106108
if driver == nil {

0 commit comments

Comments
 (0)