fix: Use localStorage path to check disk cap (#30944)

See also #30943

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-03-01 10:17:01 +08:00 committed by GitHub
parent a5a4ca8459
commit 36d78e3dd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)
}