Report "available" space rather than "free" space in volume stats

These two numbers may differ, and having the wrong number may result in
a volume having no useable space, while the metrics suggest it does.
This commit is contained in:
Mehran Kholdi 2021-06-26 03:42:41 +04:30
parent 1cd4ca3d1f
commit 87e78705b1
2 changed files with 6 additions and 6 deletions

View File

@ -124,15 +124,15 @@ class Bd2FsNodeServicer(csi_pb2_grpc.NodeServicer):
return csi_pb2.NodeGetVolumeStatsResponse(
usage=[
csi_pb2.VolumeUsage(
available=stats["fs_free"],
available=stats["fs_avail"],
total=stats["fs_size"],
used=stats["fs_size"] - stats["fs_free"],
used=stats["fs_size"] - stats["fs_avail"],
unit=csi_pb2.VolumeUsage.Unit.BYTES,
),
csi_pb2.VolumeUsage(
available=stats["fs_files_free"],
available=stats["fs_files_avail"],
total=stats["fs_files"],
used=stats["fs_files"] - stats["fs_files_free"],
used=stats["fs_files"] - stats["fs_files_avail"],
unit=csi_pb2.VolumeUsage.Unit.INODES,
),
]

View File

@ -10,9 +10,9 @@ def path_stats(path):
fs_stat = os.statvfs(path)
return {
"fs_size": fs_stat.f_frsize * fs_stat.f_blocks,
"fs_free": fs_stat.f_frsize * fs_stat.f_bfree,
"fs_avail": fs_stat.f_frsize * fs_stat.f_bavail,
"fs_files": fs_stat.f_files,
"fs_files_free": fs_stat.f_ffree,
"fs_files_avail": fs_stat.f_favail,
}