From 36d78e3dd06a57db2fe0411369055cda92cd8b13 Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 1 Mar 2024 10:17:01 +0800 Subject: [PATCH] fix: Use localStorage path to check disk cap (#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 ed9c256ec9..63c92abc84 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -2267,9 +2267,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) }