Skip to content

chore: provide a driver flag to print volume stats call with log level 2 #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ type DriverOptions struct {
AppendNoShareSockOption bool
SkipMatchingTagCacheExpireInMinutes int
VolStatsCacheExpireInMinutes int
PrintVolumeStatsCallLogs bool
}

// Driver implements all interfaces of CSI drivers
Expand All @@ -231,6 +232,7 @@ type Driver struct {
enableWindowsHostProcess bool
appendClosetimeoOption bool
appendNoShareSockOption bool
printVolumeStatsCallLogs bool
fileClient *azureFileClient
mounter *mount.SafeFormatAndMount
// lock per volume attach (only for vhd disk feature)
Expand Down Expand Up @@ -284,6 +286,7 @@ func NewDriver(options *DriverOptions) *Driver {
driver.enableWindowsHostProcess = options.EnableWindowsHostProcess
driver.appendClosetimeoOption = options.AppendClosetimeoOption
driver.appendNoShareSockOption = options.AppendNoShareSockOption
driver.printVolumeStatsCallLogs = options.PrintVolumeStatsCallLogs
driver.volLockMap = newLockMap()
driver.subnetLockMap = newLockMap()
driver.volumeLocks = newVolumeLocks()
Expand Down
13 changes: 11 additions & 2 deletions pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,19 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS
return nil, status.Errorf(codes.Internal, "failed to stat file %s: %v", req.VolumePath, err)
}

klog.V(6).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath)
if d.printVolumeStatsCallLogs {
klog.V(2).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath)
} else {
klog.V(6).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath)
}

resp, err := GetVolumeStats(req.VolumePath, d.enableWindowsHostProcess)
if err == nil && resp != nil {
klog.V(6).Infof("NodeGetVolumeStats: volume stats for volume %s path %s is %v", req.VolumeId, req.VolumePath, resp)
if d.printVolumeStatsCallLogs {
klog.V(2).Infof("NodeGetVolumeStats: volume stats for volume %s path %s is %v", req.VolumeId, req.VolumePath, resp)
} else {
klog.V(6).Infof("NodeGetVolumeStats: volume stats for volume %s path %s is %v", req.VolumeId, req.VolumePath, resp)
}
// cache the volume stats per volume
d.volStatsCache.Set(req.VolumeId, *resp)
if newVolID != "" {
Expand Down
2 changes: 2 additions & 0 deletions pkg/azurefileplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var (
appendNoShareSockOption = flag.Bool("append-nosharesock-option", true, "Whether appending nosharesock option to smb mount command")
skipMatchingTagCacheExpireInMinutes = flag.Int("skip-matching-tag-cache-expire-in-minutes", 30, "The cache expire time in minutes for skipMatchingTagCache")
volStatsCacheExpireInMinutes = flag.Int("vol-stats-cache-expire-in-minutes", 10, "The cache expire time in minutes for volume stats cache")
printVolumeStatsCallLogs = flag.Bool("print-volume-stats-call-logs", false, "Whether to print volume statfs call logs with log level 2")
)

func main() {
Expand Down Expand Up @@ -107,6 +108,7 @@ func handle() {
AppendNoShareSockOption: *appendNoShareSockOption,
SkipMatchingTagCacheExpireInMinutes: *skipMatchingTagCacheExpireInMinutes,
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
PrintVolumeStatsCallLogs: *printVolumeStatsCallLogs,
}
driver := azurefile.NewDriver(&driverOptions)
if driver == nil {
Expand Down