Migrate config to KV data format (#8392)

- adding oauth support to MinIO browser (#8400) by @kanagaraj
- supports multi-line get/set/del for all config fields
- add support for comments, allow toggle
- add extensive validation of config before saving
- support MinIO browser to support proper claims, using STS tokens
- env support for all config parameters, legacy envs are also
  supported with all documentation now pointing to latest ENVs
- preserve accessKey/secretKey from FS mode setups
- add history support implements three APIs
  - ClearHistory
  - RestoreHistory
  - ListHistory
- add help command support for each config parameters
- all the bug fixes after migration to KV, and other bug
  fixes encountered during testing.
This commit is contained in:
Harshavardhana
2019-10-22 22:59:13 -07:00
committed by kannappanr
parent 8836d57e3c
commit ee4a6a823d
185 changed files with 8228 additions and 3597 deletions

View File

@@ -56,6 +56,7 @@ import (
"github.com/gorilla/mux"
"github.com/minio/minio-go/v6/pkg/s3signer"
"github.com/minio/minio-go/v6/pkg/s3utils"
"github.com/minio/minio/cmd/config"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/bpool"
@@ -329,7 +330,7 @@ func UnstartedTestServer(t TestErrHandler, instanceType string) TestServer {
// Test Server needs to start before formatting of disks.
// Get credential.
credentials := globalServerConfig.GetCredential()
credentials := globalActiveCred
testServer.Obj = objLayer
for _, disk := range disks {
@@ -465,13 +466,6 @@ func resetGlobalIsXL() {
globalIsXL = false
}
func resetGlobalIsEnvs() {
globalIsEnvCreds = false
globalIsEnvWORM = false
globalIsEnvBrowser = false
globalIsEnvRegion = false
}
// reset global heal state
func resetGlobalHealState() {
if globalAllHealState == nil {
@@ -485,14 +479,6 @@ func resetGlobalHealState() {
}
}
}
func resetGlobalCacheEnvs() {
globalIsDiskCacheEnabled = false
}
// sets globalObjectAPI to `nil`.
func resetGlobalCacheObjectAPI() {
globalCacheObjectAPI = nil
}
// sets globalIAMSys to `nil`.
func resetGlobalIAMSys() {
@@ -517,14 +503,8 @@ func resetTestGlobals() {
resetGlobalEndpoints()
// Reset global isXL flag.
resetGlobalIsXL()
// Reset global isEnvCreds flag.
resetGlobalIsEnvs()
// Reset global heal state
resetGlobalHealState()
//Reset global disk cache flags
resetGlobalCacheEnvs()
// Reset globalCacheObjectAPI to nil
resetGlobalCacheObjectAPI()
// Reset globalIAMSys to `nil`
resetGlobalIAMSys()
}
@@ -539,11 +519,18 @@ func newTestConfig(bucketLocation string, obj ObjectLayer) (err error) {
return err
}
logger.Disable = true
globalActiveCred = auth.Credentials{
AccessKey: auth.DefaultAccessKey,
SecretKey: auth.DefaultSecretKey,
}
// Set a default region.
globalServerConfig.SetRegion(bucketLocation)
config.SetRegion(globalServerConfig, bucketLocation)
// Save config.
return saveServerConfig(context.Background(), obj, globalServerConfig)
return saveServerConfig(context.Background(), obj, globalServerConfig, nil)
}
// Deleting the temporary backend and stopping the server.
@@ -772,7 +759,7 @@ func newTestStreamingRequest(method, urlStr string, dataLength, chunkSize int64,
func assembleStreamingChunks(req *http.Request, body io.ReadSeeker, chunkSize int64,
secretKey, signature string, currTime time.Time) (*http.Request, error) {
regionStr := globalServerConfig.GetRegion()
regionStr := globalServerRegion
var stream []byte
var buffer []byte
body.Seek(0, 0)
@@ -880,7 +867,7 @@ func preSignV4(req *http.Request, accessKeyID, secretAccessKey string, expires i
return errors.New("Presign cannot be generated without access and secret keys")
}
region := globalServerConfig.GetRegion()
region := globalServerRegion
date := UTCNow()
scope := getScope(date, region)
credential := fmt.Sprintf("%s/%s", accessKeyID, scope)
@@ -1008,7 +995,7 @@ func signRequestV4(req *http.Request, accessKey, secretKey string) error {
}
sort.Strings(headers)
region := globalServerConfig.GetRegion()
region := globalServerRegion
// Get canonical headers.
var buf bytes.Buffer
@@ -1953,7 +1940,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
globalPolicySys = NewPolicySys()
globalPolicySys.Init(buckets, objLayer)
credentials := globalServerConfig.GetCredential()
credentials := globalActiveCred
// Executing the object layer tests for single node setup.
objAPITest(objLayer, FSTestStr, bucketFS, fsAPIRouter, credentials, t)
@@ -1999,6 +1986,17 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
t.Fatal("Unexpected error", err)
}
globalIAMSys = NewIAMSys()
globalIAMSys.Init(objLayer)
buckets, err := objLayer.ListBuckets(context.Background())
if err != nil {
t.Fatalf("Unable to list buckets on backend %s", err)
}
globalPolicySys = NewPolicySys()
globalPolicySys.Init(buckets, objLayer)
// Executing the object layer tests for single node setup.
objTest(objLayer, FSTestStr, t)