mirror of
https://github.com/minio/minio
synced 2024-09-06 16:54:25 +00:00
add root_disk threshold detection (#12259)
as there is no automatic way to detect if there is a root disk mounted on / or /var for the container environments due to how the root disk information is masked inside overlay root inside container. this PR brings an environment variable to set root disk size threshold manually to detect the root disks in such situations.
This commit is contained in:
parent
ab6f0c0831
commit
4e6e8c47b5
|
@ -35,6 +35,8 @@ const (
|
|||
EnvArgs = "MINIO_ARGS"
|
||||
EnvDNSWebhook = "MINIO_DNS_WEBHOOK_ENDPOINT"
|
||||
|
||||
EnvRootDiskThresholdSize = "MINIO_ROOTDISK_THRESHOLD_SIZE"
|
||||
|
||||
EnvUpdate = "MINIO_UPDATE"
|
||||
|
||||
EnvEndpoints = "MINIO_ENDPOINTS" // legacy
|
||||
|
|
|
@ -260,6 +260,25 @@ func newXLStorage(ep Endpoint) (*xlStorage, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !rootDisk {
|
||||
// If for some reason we couldn't detect the
|
||||
// root disk use - MINIO_ROOTDISK_THRESHOLD_SIZE
|
||||
// to figure out if the disk is root disk or not.
|
||||
if rootDiskSize := env.Get(config.EnvRootDiskThresholdSize, ""); rootDiskSize != "" {
|
||||
info, err := disk.GetInfo(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
size, err := humanize.ParseBytes(rootDiskSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// size of the disk is less than the threshold or
|
||||
// equal to the size of the disk at path, treat
|
||||
// such disks as rootDisks and reject them.
|
||||
rootDisk = info.Total <= size
|
||||
}
|
||||
}
|
||||
|
||||
p := &xlStorage{
|
||||
diskPath: path,
|
||||
|
|
Loading…
Reference in a new issue