mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Deprecate root disk for disk caching (#14527)
This PR modifies #14513 to issue a deprecation warning rather than reject settings on startup.
This commit is contained in:
parent
91d419ee6c
commit
75b925c326
@ -31,6 +31,7 @@ import (
|
|||||||
objectlock "github.com/minio/minio/internal/bucket/object/lock"
|
objectlock "github.com/minio/minio/internal/bucket/object/lock"
|
||||||
"github.com/minio/minio/internal/color"
|
"github.com/minio/minio/internal/color"
|
||||||
"github.com/minio/minio/internal/config/cache"
|
"github.com/minio/minio/internal/config/cache"
|
||||||
|
"github.com/minio/minio/internal/disk"
|
||||||
"github.com/minio/minio/internal/hash"
|
"github.com/minio/minio/internal/hash"
|
||||||
xhttp "github.com/minio/minio/internal/http"
|
xhttp "github.com/minio/minio/internal/http"
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
@ -594,12 +595,23 @@ func newCache(config cache.Config) ([]*diskCache, bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
var warningMsg string
|
||||||
for i, dir := range config.Drives {
|
for i, dir := range config.Drives {
|
||||||
// skip diskCache creation for cache drives missing a format.json
|
// skip diskCache creation for cache drives missing a format.json
|
||||||
if formats[i] == nil {
|
if formats[i] == nil {
|
||||||
caches = append(caches, nil)
|
caches = append(caches, nil)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if !globalIsCICD && len(warningMsg) == 0 {
|
||||||
|
rootDsk, err := disk.IsRootDisk(dir, "/")
|
||||||
|
if err != nil {
|
||||||
|
warningMsg = fmt.Sprintf("Invalid cache dir %s err : %s", dir, err.Error())
|
||||||
|
}
|
||||||
|
if rootDsk {
|
||||||
|
warningMsg = fmt.Sprintf("cache dir cannot be part of root disk: %s", dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := checkAtimeSupport(dir); err != nil {
|
if err := checkAtimeSupport(dir); err != nil {
|
||||||
return nil, false, fmt.Errorf("Atime support required for disk caching, atime check failed with %w", err)
|
return nil, false, fmt.Errorf("Atime support required for disk caching, atime check failed with %w", err)
|
||||||
}
|
}
|
||||||
@ -610,6 +622,9 @@ func newCache(config cache.Config) ([]*diskCache, bool, error) {
|
|||||||
}
|
}
|
||||||
caches = append(caches, cache)
|
caches = append(caches, cache)
|
||||||
}
|
}
|
||||||
|
if warningMsg != "" {
|
||||||
|
logger.Info(color.Yellow(fmt.Sprintf("WARNING: Usage of root disk for disk caching is deprecated: %s", warningMsg)))
|
||||||
|
}
|
||||||
return caches, migrating, nil
|
return caches, migrating, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
internal/config/cache/config.go
vendored
12
internal/config/cache/config.go
vendored
@ -20,12 +20,10 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/minio/minio/internal/config"
|
"github.com/minio/minio/internal/config"
|
||||||
"github.com/minio/minio/internal/disk"
|
|
||||||
"github.com/minio/pkg/ellipses"
|
"github.com/minio/pkg/ellipses"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -117,20 +115,10 @@ func parseCacheDrives(drives string) ([]string, error) {
|
|||||||
endpoints = append(endpoints, d)
|
endpoints = append(endpoints, d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isCICD := os.Getenv("MINIO_CI_CD") != "" || os.Getenv("CI") != ""
|
|
||||||
for _, d := range endpoints {
|
for _, d := range endpoints {
|
||||||
if !filepath.IsAbs(d) {
|
if !filepath.IsAbs(d) {
|
||||||
return nil, config.ErrInvalidCacheDrivesValue(nil).Msg("cache dir should be absolute path: %s", d)
|
return nil, config.ErrInvalidCacheDrivesValue(nil).Msg("cache dir should be absolute path: %s", d)
|
||||||
}
|
}
|
||||||
if !isCICD {
|
|
||||||
rootDsk, err := disk.IsRootDisk(d, "/")
|
|
||||||
if err != nil {
|
|
||||||
return nil, config.ErrInvalidCacheDrivesValue(nil).Msg("Invalid cache dir %s err : %s", d, err.Error())
|
|
||||||
}
|
|
||||||
if rootDsk {
|
|
||||||
return nil, config.ErrInvalidCacheDrivesValue(nil).Msg("cache dir cannot be part of root disk: %s", d)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return endpoints, nil
|
return endpoints, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user