From 430e10c8e2f4aa2c517e6f0813c84444db0f563d Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 1 Mar 2024 15:11:01 +0800 Subject: [PATCH] fix: [Cherry-pick] Use localStorage path to check disk cap (#30944) (#30966) Cherry-pick from master pr: #30944 See also #30943 --------- Signed-off-by: Congqi Xia --- pkg/util/paramtable/component_param.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/util/paramtable/component_param.go b/pkg/util/paramtable/component_param.go index a051d6c2a6..b3c21fa5f1 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -2088,9 +2088,15 @@ Max read concurrency must greater than or equal to 1, and less than or equal to Version: "2.2.0", Formatter: func(v string) string { if len(v) == 0 { - diskUsage, err := disk.Usage("/") + // use local storage path to check correct device + localStoragePath := base.Get("localStorage.path") + if _, err := os.Stat(localStoragePath); os.IsNotExist(err) { + os.MkdirAll(localStoragePath, os.ModePerm) + } + diskUsage, err := disk.Usage(localStoragePath) if err != nil { - panic(err) + // panic(err) + log.Fatal("failed to get disk usage", zap.String("localStoragePath", localStoragePath), zap.Error(err)) } return strconv.FormatUint(diskUsage.Total, 10) }