diff --git a/buildscripts/unaligned-healing.sh b/buildscripts/unaligned-healing.sh index 5eac87e2f..01a8d2482 100755 --- a/buildscripts/unaligned-healing.sh +++ b/buildscripts/unaligned-healing.sh @@ -30,6 +30,7 @@ function start_minio_16drive() { export MC_HOST_minio="http://minio:minio123@127.0.0.1:${start_port}/" 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_CI_CD=1 MC_BUILD_DIR="mc-$RANDOM" if ! git clone --quiet https://github.com/minio/mc "$MC_BUILD_DIR"; then diff --git a/buildscripts/verify-build.sh b/buildscripts/verify-build.sh index 7f93c19fb..ad76549b3 100755 --- a/buildscripts/verify-build.sh +++ b/buildscripts/verify-build.sh @@ -22,6 +22,8 @@ export GO111MODULE=on export GOGC=25 export ENABLE_ADMIN=1 +export MINIO_CI_CD=1 + MINIO_CONFIG_DIR="$WORK_DIR/.minio" MINIO=( "$PWD/minio" --config-dir "$MINIO_CONFIG_DIR" ) diff --git a/buildscripts/verify-healing.sh b/buildscripts/verify-healing.sh index ed9de73e0..498788c22 100755 --- a/buildscripts/verify-healing.sh +++ b/buildscripts/verify-healing.sh @@ -17,6 +17,7 @@ function start_minio_3_node() { export MINIO_ROOT_USER=minio export MINIO_ROOT_PASSWORD=minio123 export MINIO_ERASURE_SET_DRIVE_COUNT=6 + export MINIO_CI_CD=1 start_port=$2 args="" diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 54639d7cb..9a9aa66c2 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -1226,24 +1226,6 @@ func formatsToDrivesInfo(endpoints Endpoints, formats []*formatErasureV3, sErrs 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) { infos := make([]DiskInfo, 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. func markRootDisksAsDown(storageDisks []StorageAPI, errs []error) { if globalIsCICD { + // Do nothing return } - var infos []DiskInfo - infos, errs = getHealDiskInfos(storageDisks, errs) - if !isTestSetup(infos, errs) { - for i := range storageDisks { - if storageDisks[i] != nil && infos[i].RootDisk { - // We should not heal on root disk. i.e in a situation where the minio-administrator has unmounted a - // defective drive we should not heal a path on the root disk. - logger.Info("Disk `%s` the same as the system root disk.\n"+ - "Disk will not be used. Please supply a separate disk and restart the server.", - storageDisks[i].String()) - storageDisks[i] = nil - } + infos, _ := getHealDiskInfos(storageDisks, errs) + for i := range storageDisks { + if storageDisks[i] != nil && infos[i].RootDisk { + // We should not heal on root disk. i.e in a situation where the minio-administrator has unmounted a + // defective drive we should not heal a path on the root disk. + logger.Info("Disk `%s` the same as the system root disk.\n"+ + "Disk will not be used. Please supply a separate disk and restart the server.", + storageDisks[i].String()) + storageDisks[i] = nil } } } diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index 5d30a3849..fb34ec2c9 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -111,7 +111,7 @@ func TestMain(m *testing.M) { resetTestGlobals() - os.Setenv("MINIO_CI_CD", "ci") + globalIsCICD = true os.Exit(m.Run()) } diff --git a/cmd/update_test.go b/cmd/update_test.go index 86e853cbf..37fcbb583 100644 --- a/cmd/update_test.go +++ b/cmd/update_test.go @@ -91,10 +91,11 @@ func TestReleaseTagToNFromTimeConversion(t *testing.T) { } func TestDownloadURL(t *testing.T) { - sci := os.Getenv("MINIO_CI_CD") - - os.Setenv("MINIO_CI_CD", "") - defer os.Setenv("MINIO_CI_CD", sci) + sci := globalIsCICD + globalIsCICD = false + defer func() { + globalIsCICD = sci + }() minioVersion1 := releaseTimeToReleaseTag(UTCNow()) durl := getDownloadURL(minioVersion1) @@ -158,8 +159,8 @@ func TestUserAgent(t *testing.T) { } for i, testCase := range testCases { - sci := os.Getenv("MINIO_CI_CD") - os.Setenv("MINIO_CI_CD", "") + sci := globalIsCICD + globalIsCICD = false os.Setenv(testCase.envName, testCase.envValue) if testCase.envName == "MESOS_CONTAINER_NAME" { @@ -173,7 +174,7 @@ func TestUserAgent(t *testing.T) { if str != expectedStr { 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(testCase.envName) } @@ -181,9 +182,11 @@ func TestUserAgent(t *testing.T) { // Tests if the environment we are running is in DCOS. func TestIsDCOS(t *testing.T) { - sci := os.Getenv("MINIO_CI_CD") - os.Setenv("MINIO_CI_CD", "") - defer os.Setenv("MINIO_CI_CD", sci) + sci := globalIsCICD + globalIsCICD = false + defer func() { + globalIsCICD = sci + }() os.Setenv("MESOS_CONTAINER_NAME", "mesos-1111") dcos := IsDCOS() @@ -200,9 +203,11 @@ func TestIsDCOS(t *testing.T) { // Tests if the environment we are running is in kubernetes. func TestIsKubernetes(t *testing.T) { - sci := os.Getenv("MINIO_CI_CD") - os.Setenv("MINIO_CI_CD", "") - defer os.Setenv("MINIO_CI_CD", sci) + sci := globalIsCICD + globalIsCICD = false + defer func() { + globalIsCICD = sci + }() os.Setenv("KUBERNETES_SERVICE_HOST", "10.11.148.5") kubernetes := IsKubernetes() diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index a8b9fc5fe..dae25a6b8 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -213,29 +213,21 @@ func newXLStorage(ep Endpoint) (s *xlStorage, err error) { } var rootDisk bool - if globalIsCICD { - rootDisk = true - } else { - if globalRootDiskThreshold > 0 { - // When you do not want rely on automatic verification - // of rejecting root disks, we need to add this threshold - // to ensure that root disks are ignored properly. - info, err := disk.GetInfo(path) - if err != nil { - return nil, err - } + if globalRootDiskThreshold > 0 { + // Use MINIO_ROOTDISK_THRESHOLD_SIZE to figure out if + // this disk is a root disk. + info, err := disk.GetInfo(path) + if err != nil { + return nil, err + } - // treat those disks with size less than or equal to the - // threshold as rootDisks. - rootDisk = info.Total <= globalRootDiskThreshold - } else { - // When root disk threshold is not set, we rely - // on automatic detection - does not work in - // container environments. - rootDisk, err = disk.IsRootDisk(path, SlashSeparator) - if err != nil { - return nil, err - } + // treat those disks with size less than or equal to the + // threshold as rootDisks. + rootDisk = info.Total <= globalRootDiskThreshold + } else { + rootDisk, err = disk.IsRootDisk(path, SlashSeparator) + if err != nil { + return nil, err } } diff --git a/docs/bucket/replication/setup_3site_replication.sh b/docs/bucket/replication/setup_3site_replication.sh index 5b0b801f2..7fe7d3faa 100755 --- a/docs/bucket/replication/setup_3site_replication.sh +++ b/docs/bucket/replication/setup_3site_replication.sh @@ -25,6 +25,7 @@ catch() { catch set -e +export MINIO_CI_CD=1 export MINIO_BROWSER=off export MINIO_ROOT_USER="minio" export MINIO_ROOT_PASSWORD="minio123" diff --git a/docs/site-replication/run-multi-site-ldap.sh b/docs/site-replication/run-multi-site-ldap.sh index b6f7ebda9..7fa51aaa0 100755 --- a/docs/site-replication/run-multi-site-ldap.sh +++ b/docs/site-replication/run-multi-site-ldap.sh @@ -20,6 +20,7 @@ unset MINIO_KMS_KES_KEY_FILE unset MINIO_KMS_KES_ENDPOINT unset MINIO_KMS_KES_KEY_NAME +export MINIO_CI_CD=1 export MINIO_BROWSER=off export MINIO_ROOT_USER="minio" export MINIO_ROOT_PASSWORD="minio123" diff --git a/docs/site-replication/run-multi-site-minio-idp.sh b/docs/site-replication/run-multi-site-minio-idp.sh index 118db9c41..be325ad52 100755 --- a/docs/site-replication/run-multi-site-minio-idp.sh +++ b/docs/site-replication/run-multi-site-minio-idp.sh @@ -20,6 +20,7 @@ unset MINIO_KMS_KES_KEY_FILE unset MINIO_KMS_KES_ENDPOINT unset MINIO_KMS_KES_KEY_NAME +export MINIO_CI_CD=1 export MINIO_BROWSER=off export MINIO_ROOT_USER="minio" export MINIO_ROOT_PASSWORD="minio123" diff --git a/docs/site-replication/run-multi-site-oidc.sh b/docs/site-replication/run-multi-site-oidc.sh index 642f90b27..4daa358a8 100755 --- a/docs/site-replication/run-multi-site-oidc.sh +++ b/docs/site-replication/run-multi-site-oidc.sh @@ -20,6 +20,7 @@ unset MINIO_KMS_KES_KEY_FILE unset MINIO_KMS_KES_ENDPOINT unset MINIO_KMS_KES_KEY_NAME +export MINIO_CI_CD=1 export MINIO_BROWSER=off export MINIO_ROOT_USER="minio" export MINIO_ROOT_PASSWORD="minio123"