mirror of
https://github.com/minio/minio.git
synced 2025-04-09 06:00:12 -04:00
Always check for root disks unless MINIO_CI_CD is set (#14232)
The current code considers a pool with all root disks to be as part of a testing environment even if there are other pools with mounted disks. This will result to illegitimate writing in root disks. Fix this by simplifing the logic: require MINIO_CI_CD in order to skip root disk check.
This commit is contained in:
parent
f71b114a84
commit
1f92fc3fc0
@ -30,6 +30,7 @@ function start_minio_16drive() {
|
|||||||
export MC_HOST_minio="http://minio:minio123@127.0.0.1:${start_port}/"
|
export MC_HOST_minio="http://minio:minio123@127.0.0.1:${start_port}/"
|
||||||
unset MINIO_KMS_AUTO_ENCRYPTION # do not auto-encrypt objects
|
unset MINIO_KMS_AUTO_ENCRYPTION # do not auto-encrypt objects
|
||||||
export _MINIO_SHARD_DISKTIME_DELTA="5s" # do not change this as its needed for tests
|
export _MINIO_SHARD_DISKTIME_DELTA="5s" # do not change this as its needed for tests
|
||||||
|
export MINIO_CI_CD=1
|
||||||
|
|
||||||
MC_BUILD_DIR="mc-$RANDOM"
|
MC_BUILD_DIR="mc-$RANDOM"
|
||||||
if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then
|
if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then
|
||||||
|
@ -22,6 +22,8 @@ export GO111MODULE=on
|
|||||||
export GOGC=25
|
export GOGC=25
|
||||||
export ENABLE_ADMIN=1
|
export ENABLE_ADMIN=1
|
||||||
|
|
||||||
|
export MINIO_CI_CD=1
|
||||||
|
|
||||||
MINIO_CONFIG_DIR="$WORK_DIR/.minio"
|
MINIO_CONFIG_DIR="$WORK_DIR/.minio"
|
||||||
MINIO=( "$PWD/minio" --config-dir "$MINIO_CONFIG_DIR" )
|
MINIO=( "$PWD/minio" --config-dir "$MINIO_CONFIG_DIR" )
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ function start_minio_3_node() {
|
|||||||
export MINIO_ROOT_USER=minio
|
export MINIO_ROOT_USER=minio
|
||||||
export MINIO_ROOT_PASSWORD=minio123
|
export MINIO_ROOT_PASSWORD=minio123
|
||||||
export MINIO_ERASURE_SET_DRIVE_COUNT=6
|
export MINIO_ERASURE_SET_DRIVE_COUNT=6
|
||||||
|
export MINIO_CI_CD=1
|
||||||
|
|
||||||
start_port=$2
|
start_port=$2
|
||||||
args=""
|
args=""
|
||||||
|
@ -1226,24 +1226,6 @@ func formatsToDrivesInfo(endpoints Endpoints, formats []*formatErasureV3, sErrs
|
|||||||
return beforeDrives
|
return beforeDrives
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is a single node Erasure and all disks are root disks, it is most likely a test setup, else it is a production setup.
|
|
||||||
// On a test setup we allow creation of format.json on root disks to help with dev/testing.
|
|
||||||
func isTestSetup(infos []DiskInfo, errs []error) bool {
|
|
||||||
if globalIsCICD {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
rootDiskCount := 0
|
|
||||||
for i := range errs {
|
|
||||||
if errs[i] == nil || errs[i] == errUnformattedDisk {
|
|
||||||
if infos[i].RootDisk {
|
|
||||||
rootDiskCount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// It is a test setup if all disks are root disks in quorum.
|
|
||||||
return rootDiskCount >= len(infos)/2+1
|
|
||||||
}
|
|
||||||
|
|
||||||
func getHealDiskInfos(storageDisks []StorageAPI, errs []error) ([]DiskInfo, []error) {
|
func getHealDiskInfos(storageDisks []StorageAPI, errs []error) ([]DiskInfo, []error) {
|
||||||
infos := make([]DiskInfo, len(storageDisks))
|
infos := make([]DiskInfo, len(storageDisks))
|
||||||
g := errgroup.WithNErrs(len(storageDisks))
|
g := errgroup.WithNErrs(len(storageDisks))
|
||||||
@ -1267,20 +1249,18 @@ func getHealDiskInfos(storageDisks []StorageAPI, errs []error) ([]DiskInfo, []er
|
|||||||
// Mark root disks as down so as not to heal them.
|
// Mark root disks as down so as not to heal them.
|
||||||
func markRootDisksAsDown(storageDisks []StorageAPI, errs []error) {
|
func markRootDisksAsDown(storageDisks []StorageAPI, errs []error) {
|
||||||
if globalIsCICD {
|
if globalIsCICD {
|
||||||
|
// Do nothing
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var infos []DiskInfo
|
infos, _ := getHealDiskInfos(storageDisks, errs)
|
||||||
infos, errs = getHealDiskInfos(storageDisks, errs)
|
for i := range storageDisks {
|
||||||
if !isTestSetup(infos, errs) {
|
if storageDisks[i] != nil && infos[i].RootDisk {
|
||||||
for i := range storageDisks {
|
// We should not heal on root disk. i.e in a situation where the minio-administrator has unmounted a
|
||||||
if storageDisks[i] != nil && infos[i].RootDisk {
|
// defective drive we should not heal a path on the root disk.
|
||||||
// We should not heal on root disk. i.e in a situation where the minio-administrator has unmounted a
|
logger.Info("Disk `%s` the same as the system root disk.\n"+
|
||||||
// defective drive we should not heal a path on the root disk.
|
"Disk will not be used. Please supply a separate disk and restart the server.",
|
||||||
logger.Info("Disk `%s` the same as the system root disk.\n"+
|
storageDisks[i].String())
|
||||||
"Disk will not be used. Please supply a separate disk and restart the server.",
|
storageDisks[i] = nil
|
||||||
storageDisks[i].String())
|
|
||||||
storageDisks[i] = nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ func TestMain(m *testing.M) {
|
|||||||
|
|
||||||
resetTestGlobals()
|
resetTestGlobals()
|
||||||
|
|
||||||
os.Setenv("MINIO_CI_CD", "ci")
|
globalIsCICD = true
|
||||||
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
@ -91,10 +91,11 @@ func TestReleaseTagToNFromTimeConversion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDownloadURL(t *testing.T) {
|
func TestDownloadURL(t *testing.T) {
|
||||||
sci := os.Getenv("MINIO_CI_CD")
|
sci := globalIsCICD
|
||||||
|
globalIsCICD = false
|
||||||
os.Setenv("MINIO_CI_CD", "")
|
defer func() {
|
||||||
defer os.Setenv("MINIO_CI_CD", sci)
|
globalIsCICD = sci
|
||||||
|
}()
|
||||||
|
|
||||||
minioVersion1 := releaseTimeToReleaseTag(UTCNow())
|
minioVersion1 := releaseTimeToReleaseTag(UTCNow())
|
||||||
durl := getDownloadURL(minioVersion1)
|
durl := getDownloadURL(minioVersion1)
|
||||||
@ -158,8 +159,8 @@ func TestUserAgent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
sci := os.Getenv("MINIO_CI_CD")
|
sci := globalIsCICD
|
||||||
os.Setenv("MINIO_CI_CD", "")
|
globalIsCICD = false
|
||||||
|
|
||||||
os.Setenv(testCase.envName, testCase.envValue)
|
os.Setenv(testCase.envName, testCase.envValue)
|
||||||
if testCase.envName == "MESOS_CONTAINER_NAME" {
|
if testCase.envName == "MESOS_CONTAINER_NAME" {
|
||||||
@ -173,7 +174,7 @@ func TestUserAgent(t *testing.T) {
|
|||||||
if str != expectedStr {
|
if str != expectedStr {
|
||||||
t.Errorf("Test %d: expected: %s, got: %s", i+1, expectedStr, str)
|
t.Errorf("Test %d: expected: %s, got: %s", i+1, expectedStr, str)
|
||||||
}
|
}
|
||||||
os.Setenv("MINIO_CI_CD", sci)
|
globalIsCICD = sci
|
||||||
os.Unsetenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION")
|
os.Unsetenv("MARATHON_APP_LABEL_DCOS_PACKAGE_VERSION")
|
||||||
os.Unsetenv(testCase.envName)
|
os.Unsetenv(testCase.envName)
|
||||||
}
|
}
|
||||||
@ -181,9 +182,11 @@ func TestUserAgent(t *testing.T) {
|
|||||||
|
|
||||||
// Tests if the environment we are running is in DCOS.
|
// Tests if the environment we are running is in DCOS.
|
||||||
func TestIsDCOS(t *testing.T) {
|
func TestIsDCOS(t *testing.T) {
|
||||||
sci := os.Getenv("MINIO_CI_CD")
|
sci := globalIsCICD
|
||||||
os.Setenv("MINIO_CI_CD", "")
|
globalIsCICD = false
|
||||||
defer os.Setenv("MINIO_CI_CD", sci)
|
defer func() {
|
||||||
|
globalIsCICD = sci
|
||||||
|
}()
|
||||||
|
|
||||||
os.Setenv("MESOS_CONTAINER_NAME", "mesos-1111")
|
os.Setenv("MESOS_CONTAINER_NAME", "mesos-1111")
|
||||||
dcos := IsDCOS()
|
dcos := IsDCOS()
|
||||||
@ -200,9 +203,11 @@ func TestIsDCOS(t *testing.T) {
|
|||||||
|
|
||||||
// Tests if the environment we are running is in kubernetes.
|
// Tests if the environment we are running is in kubernetes.
|
||||||
func TestIsKubernetes(t *testing.T) {
|
func TestIsKubernetes(t *testing.T) {
|
||||||
sci := os.Getenv("MINIO_CI_CD")
|
sci := globalIsCICD
|
||||||
os.Setenv("MINIO_CI_CD", "")
|
globalIsCICD = false
|
||||||
defer os.Setenv("MINIO_CI_CD", sci)
|
defer func() {
|
||||||
|
globalIsCICD = sci
|
||||||
|
}()
|
||||||
|
|
||||||
os.Setenv("KUBERNETES_SERVICE_HOST", "10.11.148.5")
|
os.Setenv("KUBERNETES_SERVICE_HOST", "10.11.148.5")
|
||||||
kubernetes := IsKubernetes()
|
kubernetes := IsKubernetes()
|
||||||
|
@ -213,29 +213,21 @@ func newXLStorage(ep Endpoint) (s *xlStorage, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rootDisk bool
|
var rootDisk bool
|
||||||
if globalIsCICD {
|
if globalRootDiskThreshold > 0 {
|
||||||
rootDisk = true
|
// Use MINIO_ROOTDISK_THRESHOLD_SIZE to figure out if
|
||||||
} else {
|
// this disk is a root disk.
|
||||||
if globalRootDiskThreshold > 0 {
|
info, err := disk.GetInfo(path)
|
||||||
// When you do not want rely on automatic verification
|
if err != nil {
|
||||||
// of rejecting root disks, we need to add this threshold
|
return nil, err
|
||||||
// to ensure that root disks are ignored properly.
|
}
|
||||||
info, err := disk.GetInfo(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// treat those disks with size less than or equal to the
|
// treat those disks with size less than or equal to the
|
||||||
// threshold as rootDisks.
|
// threshold as rootDisks.
|
||||||
rootDisk = info.Total <= globalRootDiskThreshold
|
rootDisk = info.Total <= globalRootDiskThreshold
|
||||||
} else {
|
} else {
|
||||||
// When root disk threshold is not set, we rely
|
rootDisk, err = disk.IsRootDisk(path, SlashSeparator)
|
||||||
// on automatic detection - does not work in
|
if err != nil {
|
||||||
// container environments.
|
return nil, err
|
||||||
rootDisk, err = disk.IsRootDisk(path, SlashSeparator)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ catch() {
|
|||||||
catch
|
catch
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
export MINIO_CI_CD=1
|
||||||
export MINIO_BROWSER=off
|
export MINIO_BROWSER=off
|
||||||
export MINIO_ROOT_USER="minio"
|
export MINIO_ROOT_USER="minio"
|
||||||
export MINIO_ROOT_PASSWORD="minio123"
|
export MINIO_ROOT_PASSWORD="minio123"
|
||||||
|
@ -20,6 +20,7 @@ unset MINIO_KMS_KES_KEY_FILE
|
|||||||
unset MINIO_KMS_KES_ENDPOINT
|
unset MINIO_KMS_KES_ENDPOINT
|
||||||
unset MINIO_KMS_KES_KEY_NAME
|
unset MINIO_KMS_KES_KEY_NAME
|
||||||
|
|
||||||
|
export MINIO_CI_CD=1
|
||||||
export MINIO_BROWSER=off
|
export MINIO_BROWSER=off
|
||||||
export MINIO_ROOT_USER="minio"
|
export MINIO_ROOT_USER="minio"
|
||||||
export MINIO_ROOT_PASSWORD="minio123"
|
export MINIO_ROOT_PASSWORD="minio123"
|
||||||
|
@ -20,6 +20,7 @@ unset MINIO_KMS_KES_KEY_FILE
|
|||||||
unset MINIO_KMS_KES_ENDPOINT
|
unset MINIO_KMS_KES_ENDPOINT
|
||||||
unset MINIO_KMS_KES_KEY_NAME
|
unset MINIO_KMS_KES_KEY_NAME
|
||||||
|
|
||||||
|
export MINIO_CI_CD=1
|
||||||
export MINIO_BROWSER=off
|
export MINIO_BROWSER=off
|
||||||
export MINIO_ROOT_USER="minio"
|
export MINIO_ROOT_USER="minio"
|
||||||
export MINIO_ROOT_PASSWORD="minio123"
|
export MINIO_ROOT_PASSWORD="minio123"
|
||||||
|
@ -20,6 +20,7 @@ unset MINIO_KMS_KES_KEY_FILE
|
|||||||
unset MINIO_KMS_KES_ENDPOINT
|
unset MINIO_KMS_KES_ENDPOINT
|
||||||
unset MINIO_KMS_KES_KEY_NAME
|
unset MINIO_KMS_KES_KEY_NAME
|
||||||
|
|
||||||
|
export MINIO_CI_CD=1
|
||||||
export MINIO_BROWSER=off
|
export MINIO_BROWSER=off
|
||||||
export MINIO_ROOT_USER="minio"
|
export MINIO_ROOT_USER="minio"
|
||||||
export MINIO_ROOT_PASSWORD="minio123"
|
export MINIO_ROOT_PASSWORD="minio123"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user