mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -05:00
use GlobalContext whenever possible (#9280)
This change is throughout the codebase to ensure that all codepaths honor GlobalContext
This commit is contained in:
parent
1b45be0d60
commit
f44cfb2863
@ -162,7 +162,7 @@ func (a adminAPIHandlers) SetConfigKVHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
|
|
||||||
// Make sure to write backend is encrypted
|
// Make sure to write backend is encrypted
|
||||||
if globalConfigEncrypted {
|
if globalConfigEncrypted {
|
||||||
saveConfig(context.Background(), objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
|
saveConfig(GlobalContext, objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
writeSuccessResponseHeadersOnly(w)
|
writeSuccessResponseHeadersOnly(w)
|
||||||
@ -403,7 +403,7 @@ func (a adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http.Reques
|
|||||||
|
|
||||||
// Make sure to write backend is encrypted
|
// Make sure to write backend is encrypted
|
||||||
if globalConfigEncrypted {
|
if globalConfigEncrypted {
|
||||||
saveConfig(context.Background(), objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
|
saveConfig(GlobalContext, objectAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
writeSuccessResponseHeadersOnly(w)
|
writeSuccessResponseHeadersOnly(w)
|
||||||
|
@ -790,7 +790,7 @@ func extractHealInitParams(vars map[string]string, qParms url.Values, r io.Reade
|
|||||||
if hip.clientToken == "" {
|
if hip.clientToken == "" {
|
||||||
jerr := json.NewDecoder(r).Decode(&hip.hs)
|
jerr := json.NewDecoder(r).Decode(&hip.hs)
|
||||||
if jerr != nil {
|
if jerr != nil {
|
||||||
logger.LogIf(context.Background(), jerr, logger.Application)
|
logger.LogIf(GlobalContext, jerr, logger.Application)
|
||||||
err = ErrRequestBodyParse
|
err = ErrRequestBodyParse
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -72,7 +71,7 @@ func prepareAdminXLTestBed() (*adminXLTestBed, error) {
|
|||||||
globalIAMSys = NewIAMSys()
|
globalIAMSys = NewIAMSys()
|
||||||
globalIAMSys.Init(GlobalContext, objLayer)
|
globalIAMSys.Init(GlobalContext, objLayer)
|
||||||
|
|
||||||
buckets, err := objLayer.ListBuckets(context.Background())
|
buckets, err := objLayer.ListBuckets(GlobalContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -314,12 +313,12 @@ func TestToAdminAPIErrCode(t *testing.T) {
|
|||||||
// 3. Non-admin API specific error.
|
// 3. Non-admin API specific error.
|
||||||
{
|
{
|
||||||
err: errDiskNotFound,
|
err: errDiskNotFound,
|
||||||
expectedAPIErr: toAPIErrorCode(context.Background(), errDiskNotFound),
|
expectedAPIErr: toAPIErrorCode(GlobalContext, errDiskNotFound),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range testCases {
|
for i, test := range testCases {
|
||||||
actualErr := toAdminAPIErrCode(context.Background(), test.err)
|
actualErr := toAdminAPIErrCode(GlobalContext, test.err)
|
||||||
if actualErr != test.expectedAPIErr {
|
if actualErr != test.expectedAPIErr {
|
||||||
t.Errorf("Test %d: Expected %v but received %v",
|
t.Errorf("Test %d: Expected %v but received %v",
|
||||||
i+1, test.expectedAPIErr, actualErr)
|
i+1, test.expectedAPIErr, actualErr)
|
||||||
|
@ -183,7 +183,7 @@ func (ahs *allHealState) stopHealSequence(path string) ([]byte, APIError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(&hsp)
|
b, err := json.Marshal(&hsp)
|
||||||
return b, toAdminAPIErr(context.Background(), err)
|
return b, toAdminAPIErr(GlobalContext, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LaunchNewHealSequence - launches a background routine that performs
|
// LaunchNewHealSequence - launches a background routine that performs
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
@ -142,7 +141,7 @@ func (b *streamingBitrotReader) ReadAt(buf []byte, offset int64) (int, error) {
|
|||||||
if !bytes.Equal(b.h.Sum(nil), b.hashBytes) {
|
if !bytes.Equal(b.h.Sum(nil), b.hashBytes) {
|
||||||
err := &errHashMismatch{fmt.Sprintf("hashes do not match expected %s, got %s",
|
err := &errHashMismatch{fmt.Sprintf("hashes do not match expected %s, got %s",
|
||||||
hex.EncodeToString(b.hashBytes), hex.EncodeToString(b.h.Sum(nil)))}
|
hex.EncodeToString(b.hashBytes), hex.EncodeToString(b.h.Sum(nil)))}
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
b.currOffset += int64(len(buf))
|
b.currOffset += int64(len(buf))
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
@ -36,12 +35,12 @@ type wholeBitrotWriter struct {
|
|||||||
func (b *wholeBitrotWriter) Write(p []byte) (int, error) {
|
func (b *wholeBitrotWriter) Write(p []byte) (int, error) {
|
||||||
err := b.disk.AppendFile(b.volume, b.filePath, p)
|
err := b.disk.AppendFile(b.volume, b.filePath, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
_, err = b.Hash.Write(p)
|
_, err = b.Hash.Write(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
@ -70,14 +69,14 @@ func (b *wholeBitrotReader) ReadAt(buf []byte, offset int64) (n int, err error)
|
|||||||
if b.buf == nil {
|
if b.buf == nil {
|
||||||
b.buf = make([]byte, b.tillOffset-offset)
|
b.buf = make([]byte, b.tillOffset-offset)
|
||||||
if _, err := b.disk.ReadFile(b.volume, b.filePath, offset, b.buf, b.verifier); err != nil {
|
if _, err := b.disk.ReadFile(b.volume, b.filePath, offset, b.buf, b.verifier); err != nil {
|
||||||
ctx := context.Background()
|
ctx := GlobalContext
|
||||||
logger.GetReqInfo(ctx).AppendTags("disk", b.disk.String())
|
logger.GetReqInfo(ctx).AppendTags("disk", b.disk.String())
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(b.buf) < len(buf) {
|
if len(b.buf) < len(buf) {
|
||||||
logger.LogIf(context.Background(), errLessData)
|
logger.LogIf(GlobalContext, errLessData)
|
||||||
return 0, errLessData
|
return 0, errLessData
|
||||||
}
|
}
|
||||||
n = copy(buf, b.buf)
|
n = copy(buf, b.buf)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
@ -72,7 +71,7 @@ func (a BitrotAlgorithm) New() hash.Hash {
|
|||||||
hh, _ := highwayhash.New(magicHighwayHash256Key) // New will never return error since key is 256 bit
|
hh, _ := highwayhash.New(magicHighwayHash256Key) // New will never return error since key is 256 bit
|
||||||
return hh
|
return hh
|
||||||
default:
|
default:
|
||||||
logger.CriticalIf(context.Background(), errors.New("Unsupported bitrot algorithm"))
|
logger.CriticalIf(GlobalContext, errors.New("Unsupported bitrot algorithm"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +87,7 @@ func (a BitrotAlgorithm) Available() bool {
|
|||||||
func (a BitrotAlgorithm) String() string {
|
func (a BitrotAlgorithm) String() string {
|
||||||
name, ok := bitrotAlgorithms[a]
|
name, ok := bitrotAlgorithms[a]
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.CriticalIf(context.Background(), errors.New("Unsupported bitrot algorithm"))
|
logger.CriticalIf(GlobalContext, errors.New("Unsupported bitrot algorithm"))
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ func (client *bootstrapRESTClient) reConnect() {
|
|||||||
// permanently. The only way to restore the connection is at the xl-sets layer by xlsets.monitorAndConnectEndpoints()
|
// permanently. The only way to restore the connection is at the xl-sets layer by xlsets.monitorAndConnectEndpoints()
|
||||||
// after verifying format.json
|
// after verifying format.json
|
||||||
func (client *bootstrapRESTClient) call(method string, values url.Values, body io.Reader, length int64) (respBody io.ReadCloser, err error) {
|
func (client *bootstrapRESTClient) call(method string, values url.Values, body io.Reader, length int64) (respBody io.ReadCloser, err error) {
|
||||||
return client.callWithContext(context.Background(), method, values, body, length)
|
return client.callWithContext(GlobalContext, method, values, body, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper to restClient.Call to handle network errors, in case of network error the connection is marked disconnected
|
// Wrapper to restClient.Call to handle network errors, in case of network error the connection is marked disconnected
|
||||||
|
@ -44,7 +44,7 @@ func NewBucketSSEConfigSys() *BucketSSEConfigSys {
|
|||||||
// load - Loads the bucket encryption configuration for the given list of buckets
|
// load - Loads the bucket encryption configuration for the given list of buckets
|
||||||
func (sys *BucketSSEConfigSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
func (sys *BucketSSEConfigSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
||||||
for _, bucket := range buckets {
|
for _, bucket := range buckets {
|
||||||
config, err := objAPI.GetBucketSSEConfig(context.Background(), bucket.Name)
|
config, err := objAPI.GetBucketSSEConfig(GlobalContext, bucket.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(BucketSSEConfigNotFound); ok {
|
if _, ok := err.(BucketSSEConfigNotFound); ok {
|
||||||
sys.Remove(bucket.Name)
|
sys.Remove(bucket.Name)
|
||||||
@ -81,7 +81,7 @@ func (sys *BucketSSEConfigSys) Get(bucket string) (config bucketsse.BucketSSECon
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := objAPI.GetBucketSSEConfig(context.Background(), bucket)
|
cfg, err := objAPI.GetBucketSSEConfig(GlobalContext, bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ func saveBucketSSEConfig(ctx context.Context, objAPI ObjectLayer, bucket string,
|
|||||||
func getBucketSSEConfig(objAPI ObjectLayer, bucket string) (*bucketsse.BucketSSEConfig, error) {
|
func getBucketSSEConfig(objAPI ObjectLayer, bucket string) (*bucketsse.BucketSSEConfig, error) {
|
||||||
// Path to bucket-encryption.xml for the given bucket.
|
// Path to bucket-encryption.xml for the given bucket.
|
||||||
configFile := path.Join(bucketConfigPrefix, bucket, bucketSSEConfig)
|
configFile := path.Join(bucketConfigPrefix, bucket, bucketSSEConfig)
|
||||||
configData, err := readConfig(context.Background(), objAPI, configFile)
|
configData, err := readConfig(GlobalContext, objAPI, configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errConfigNotFound {
|
if err == errConfigNotFound {
|
||||||
err = BucketSSEConfigNotFound{Bucket: bucket}
|
err = BucketSSEConfigNotFound{Bucket: bucket}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -70,7 +69,7 @@ func initFederatorBackend(buckets []BucketInfo, objLayer ObjectLayer) {
|
|||||||
// Get buckets in the DNS
|
// Get buckets in the DNS
|
||||||
dnsBuckets, err := globalDNSConfig.List()
|
dnsBuckets, err := globalDNSConfig.List()
|
||||||
if err != nil && err != dns.ErrNoEntriesFound {
|
if err != nil && err != dns.ErrNoEntriesFound {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,12 +117,12 @@ func initFederatorBackend(buckets []BucketInfo, objLayer ObjectLayer) {
|
|||||||
|
|
||||||
for _, err := range g.Wait() {
|
for _, err := range g.Wait() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, bucket := range bucketsInConflict.ToSlice() {
|
for _, bucket := range bucketsInConflict.ToSlice() {
|
||||||
logger.LogIf(context.Background(), fmt.Errorf("Unable to add bucket DNS entry for bucket %s, an entry exists for the same bucket. Use one of these IP addresses %v to access the bucket", bucket, globalDomainIPs.ToSlice()))
|
logger.LogIf(GlobalContext, fmt.Errorf("Unable to add bucket DNS entry for bucket %s, an entry exists for the same bucket. Use one of these IP addresses %v to access the bucket", bucket, globalDomainIPs.ToSlice()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove buckets that are in DNS for this server, but aren't local
|
// Remove buckets that are in DNS for this server, but aren't local
|
||||||
@ -140,7 +139,7 @@ func initFederatorBackend(buckets []BucketInfo, objLayer ObjectLayer) {
|
|||||||
// We go to here, so we know the bucket no longer exists,
|
// We go to here, so we know the bucket no longer exists,
|
||||||
// but is registered in DNS to this server
|
// but is registered in DNS to this server
|
||||||
if err = globalDNSConfig.Delete(bucket); err != nil {
|
if err = globalDNSConfig.Delete(bucket); err != nil {
|
||||||
logger.LogIf(context.Background(), fmt.Errorf("Failed to remove DNS entry for %s due to %w",
|
logger.LogIf(GlobalContext, fmt.Errorf("Failed to remove DNS entry for %s due to %w",
|
||||||
bucket, err))
|
bucket, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -36,7 +35,7 @@ func TestRemoveBucketHandler(t *testing.T) {
|
|||||||
|
|
||||||
func testRemoveBucketHandler(obj ObjectLayer, instanceType, bucketName string, apiRouter http.Handler,
|
func testRemoveBucketHandler(obj ObjectLayer, instanceType, bucketName string, apiRouter http.Handler,
|
||||||
credentials auth.Credentials, t *testing.T) {
|
credentials auth.Credentials, t *testing.T) {
|
||||||
_, err := obj.PutObject(context.Background(), bucketName, "test-object", mustGetPutObjReader(t, bytes.NewBuffer([]byte{}), int64(0), "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"), ObjectOptions{})
|
_, err := obj.PutObject(GlobalContext, bucketName, "test-object", mustGetPutObjReader(t, bytes.NewBuffer([]byte{}), int64(0), "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"), ObjectOptions{})
|
||||||
// if object upload fails stop the test.
|
// if object upload fails stop the test.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error uploading object: <ERROR> %v", err)
|
t.Fatalf("Error uploading object: <ERROR> %v", err)
|
||||||
@ -670,7 +669,7 @@ func testAPIDeleteMultipleObjectsHandler(obj ObjectLayer, instanceType, bucketNa
|
|||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
objectName := "test-object-" + strconv.Itoa(i)
|
objectName := "test-object-" + strconv.Itoa(i)
|
||||||
// uploading the object.
|
// uploading the object.
|
||||||
_, err = obj.PutObject(context.Background(), bucketName, objectName, mustGetPutObjReader(t, bytes.NewBuffer(contentBytes), int64(len(contentBytes)), "", sha256sum), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewBuffer(contentBytes), int64(len(contentBytes)), "", sha256sum), ObjectOptions{})
|
||||||
// if object upload fails stop the test.
|
// if object upload fails stop the test.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Put Object %d: Error uploading object: <ERROR> %v", i, err)
|
t.Fatalf("Put Object %d: Error uploading object: <ERROR> %v", i, err)
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -103,7 +102,7 @@ func testPutBucketPolicyHandler(obj ObjectLayer, instanceType, bucketName string
|
|||||||
credentials auth.Credentials, t *testing.T) {
|
credentials auth.Credentials, t *testing.T) {
|
||||||
|
|
||||||
bucketName1 := fmt.Sprintf("%s-1", bucketName)
|
bucketName1 := fmt.Sprintf("%s-1", bucketName)
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName1, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName1, ""); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"errors"
|
"errors"
|
||||||
@ -42,7 +41,7 @@ func init() {
|
|||||||
logger.RegisterError(config.FmtError)
|
logger.RegisterError(config.FmtError)
|
||||||
|
|
||||||
// Initialize globalConsoleSys system
|
// Initialize globalConsoleSys system
|
||||||
globalConsoleSys = NewConsoleLogger(context.Background())
|
globalConsoleSys = NewConsoleLogger(GlobalContext)
|
||||||
logger.AddTarget(globalConsoleSys)
|
logger.AddTarget(globalConsoleSys)
|
||||||
|
|
||||||
gob.Register(StorageErr(""))
|
gob.Register(StorageErr(""))
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -302,7 +301,7 @@ func validateConfig(s config.Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func lookupConfigs(s config.Config) {
|
func lookupConfigs(s config.Config) {
|
||||||
ctx := context.Background()
|
ctx := GlobalContext
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if !globalActiveCred.IsValid() {
|
if !globalActiveCred.IsValid() {
|
||||||
@ -553,11 +552,11 @@ func newSrvConfig(objAPI ObjectLayer) error {
|
|||||||
globalServerConfigMu.Unlock()
|
globalServerConfigMu.Unlock()
|
||||||
|
|
||||||
// Save config into file.
|
// Save config into file.
|
||||||
return saveServerConfig(context.Background(), objAPI, globalServerConfig)
|
return saveServerConfig(GlobalContext, objAPI, globalServerConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getValidConfig(objAPI ObjectLayer) (config.Config, error) {
|
func getValidConfig(objAPI ObjectLayer) (config.Config, error) {
|
||||||
return readServerConfig(context.Background(), objAPI)
|
return readServerConfig(GlobalContext, objAPI)
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadConfig - loads a new config from disk, overrides params
|
// loadConfig - loads a new config from disk, overrides params
|
||||||
|
@ -139,7 +139,7 @@ func checkBackendEtcdEncrypted(ctx context.Context, client *etcd.Client) (bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkBackendEncrypted(objAPI ObjectLayer) (bool, error) {
|
func checkBackendEncrypted(objAPI ObjectLayer) (bool, error) {
|
||||||
data, err := readConfig(context.Background(), objAPI, backendEncryptedFile)
|
data, err := readConfig(GlobalContext, objAPI, backendEncryptedFile)
|
||||||
if err != nil && err != errConfigNotFound {
|
if err != nil && err != errConfigNotFound {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -288,14 +288,14 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, activeCredOld auth.Crede
|
|||||||
logger.Info("Attempting encryption of all config, IAM users and policies on MinIO backend")
|
logger.Info("Attempting encryption of all config, IAM users and policies on MinIO backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := saveConfig(context.Background(), objAPI, backendEncryptedFile, backendEncryptedMigrationIncomplete)
|
err := saveConfig(GlobalContext, objAPI, backendEncryptedFile, backendEncryptedMigrationIncomplete)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var marker string
|
var marker string
|
||||||
for {
|
for {
|
||||||
res, err := objAPI.ListObjects(context.Background(), minioMetaBucket,
|
res, err := objAPI.ListObjects(GlobalContext, minioMetaBucket,
|
||||||
minioConfigPrefix, marker, "", maxObjectList)
|
minioConfigPrefix, marker, "", maxObjectList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -306,7 +306,7 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, activeCredOld auth.Crede
|
|||||||
cencdata []byte
|
cencdata []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
cdata, err = readConfig(context.Background(), objAPI, obj.Name)
|
cdata, err = readConfig(GlobalContext, objAPI, obj.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, activeCredOld auth.Crede
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = saveConfig(context.Background(), objAPI, obj.Name, cencdata); err != nil {
|
if err = saveConfig(GlobalContext, objAPI, obj.Name, cencdata); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,5 +355,5 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, activeCredOld auth.Crede
|
|||||||
logger.Info("Rotation complete, please make sure to unset MINIO_ACCESS_KEY_OLD and MINIO_SECRET_KEY_OLD envs")
|
logger.Info("Rotation complete, please make sure to unset MINIO_ACCESS_KEY_OLD and MINIO_SECRET_KEY_OLD envs")
|
||||||
}
|
}
|
||||||
|
|
||||||
return saveConfig(context.Background(), objAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
|
return saveConfig(GlobalContext, objAPI, backendEncryptedFile, backendEncryptedMigrationComplete)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@ -2430,7 +2429,7 @@ func migrateConfigToMinioSys(objAPI ObjectLayer) (err error) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if globalEtcdClient != nil {
|
if globalEtcdClient != nil {
|
||||||
deleteKeyEtcd(context.Background(), globalEtcdClient, configFile)
|
deleteKeyEtcd(GlobalContext, globalEtcdClient, configFile)
|
||||||
} else {
|
} else {
|
||||||
// Rename config.json to config.json.deprecated only upon
|
// Rename config.json to config.json.deprecated only upon
|
||||||
// success of this function.
|
// success of this function.
|
||||||
@ -2440,7 +2439,7 @@ func migrateConfigToMinioSys(objAPI ObjectLayer) (err error) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// Verify if backend already has the file (after holding lock)
|
// Verify if backend already has the file (after holding lock)
|
||||||
if err = checkConfig(context.Background(), objAPI, configFile); err != errConfigNotFound {
|
if err = checkConfig(GlobalContext, objAPI, configFile); err != errConfigNotFound {
|
||||||
return err
|
return err
|
||||||
} // if errConfigNotFound proceed to migrate..
|
} // if errConfigNotFound proceed to migrate..
|
||||||
|
|
||||||
@ -2466,7 +2465,7 @@ func migrateConfigToMinioSys(objAPI ObjectLayer) (err error) {
|
|||||||
// Initialize the server config, if no config exists.
|
// Initialize the server config, if no config exists.
|
||||||
return newSrvConfig(objAPI)
|
return newSrvConfig(objAPI)
|
||||||
}
|
}
|
||||||
return saveServerConfig(context.Background(), objAPI, config)
|
return saveServerConfig(GlobalContext, objAPI, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrates '.minio.sys/config.json' to v33.
|
// Migrates '.minio.sys/config.json' to v33.
|
||||||
@ -2502,7 +2501,7 @@ func migrateMinioSysConfig(objAPI ObjectLayer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkConfigVersion(objAPI ObjectLayer, configFile string, version string) (bool, []byte, error) {
|
func checkConfigVersion(objAPI ObjectLayer, configFile string, version string) (bool, []byte, error) {
|
||||||
data, err := readConfig(context.Background(), objAPI, configFile)
|
data, err := readConfig(GlobalContext, objAPI, configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@ -2548,7 +2547,7 @@ func migrateV27ToV28MinioSys(objAPI ObjectLayer) error {
|
|||||||
cfg.Version = "28"
|
cfg.Version = "28"
|
||||||
cfg.KMS = crypto.KMSConfig{}
|
cfg.KMS = crypto.KMSConfig{}
|
||||||
|
|
||||||
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil {
|
||||||
return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %w", err)
|
return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2575,7 +2574,7 @@ func migrateV28ToV29MinioSys(objAPI ObjectLayer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg.Version = "29"
|
cfg.Version = "29"
|
||||||
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil {
|
||||||
return fmt.Errorf("Failed to migrate config from ‘28’ to ‘29’. %w", err)
|
return fmt.Errorf("Failed to migrate config from ‘28’ to ‘29’. %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2607,7 +2606,7 @@ func migrateV29ToV30MinioSys(objAPI ObjectLayer) error {
|
|||||||
cfg.Compression.Extensions = strings.Split(compress.DefaultExtensions, config.ValueSeparator)
|
cfg.Compression.Extensions = strings.Split(compress.DefaultExtensions, config.ValueSeparator)
|
||||||
cfg.Compression.MimeTypes = strings.Split(compress.DefaultMimeTypes, config.ValueSeparator)
|
cfg.Compression.MimeTypes = strings.Split(compress.DefaultMimeTypes, config.ValueSeparator)
|
||||||
|
|
||||||
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil {
|
||||||
return fmt.Errorf("Failed to migrate config from ‘29’ to ‘30’. %w", err)
|
return fmt.Errorf("Failed to migrate config from ‘29’ to ‘30’. %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2642,7 +2641,7 @@ func migrateV30ToV31MinioSys(objAPI ObjectLayer) error {
|
|||||||
AuthToken: "",
|
AuthToken: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil {
|
||||||
return fmt.Errorf("Failed to migrate config from ‘30’ to ‘31’. %w", err)
|
return fmt.Errorf("Failed to migrate config from ‘30’ to ‘31’. %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2672,7 +2671,7 @@ func migrateV31ToV32MinioSys(objAPI ObjectLayer) error {
|
|||||||
cfg.Notify.NSQ = make(map[string]target.NSQArgs)
|
cfg.Notify.NSQ = make(map[string]target.NSQArgs)
|
||||||
cfg.Notify.NSQ["1"] = target.NSQArgs{}
|
cfg.Notify.NSQ["1"] = target.NSQArgs{}
|
||||||
|
|
||||||
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil {
|
||||||
return fmt.Errorf("Failed to migrate config from ‘31’ to ‘32’. %w", err)
|
return fmt.Errorf("Failed to migrate config from ‘31’ to ‘32’. %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2700,7 +2699,7 @@ func migrateV32ToV33MinioSys(objAPI ObjectLayer) error {
|
|||||||
|
|
||||||
cfg.Version = "33"
|
cfg.Version = "33"
|
||||||
|
|
||||||
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil {
|
||||||
return fmt.Errorf("Failed to migrate config from '32' to '33' . %w", err)
|
return fmt.Errorf("Failed to migrate config from '32' to '33' . %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2777,7 +2776,7 @@ func migrateMinioSysConfigToKV(objAPI ObjectLayer) error {
|
|||||||
notify.SetNotifyWebhook(newCfg, k, args)
|
notify.SetNotifyWebhook(newCfg, k, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = saveServerConfig(context.Background(), objAPI, newCfg); err != nil {
|
if err = saveServerConfig(GlobalContext, objAPI, newCfg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ func (c *diskCache) diskUsageLow() bool {
|
|||||||
di, err := disk.GetInfo(c.dir)
|
di, err := disk.GetInfo(c.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ func (c *diskCache) diskUsageHigh() bool {
|
|||||||
di, err := disk.GetInfo(c.dir)
|
di, err := disk.GetInfo(c.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ func (c *diskCache) diskAvailable(size int64) bool {
|
|||||||
di, err := disk.GetInfo(c.dir)
|
di, err := disk.GetInfo(c.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ func (c *diskCache) toClear() uint64 {
|
|||||||
di, err := disk.GetInfo(c.dir)
|
di, err := disk.GetInfo(c.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -800,7 +800,7 @@ func (c *diskCache) bitrotReadFromCache(ctx context.Context, filePath string, of
|
|||||||
if !bytes.Equal(hashBytes, checksumHash) {
|
if !bytes.Equal(hashBytes, checksumHash) {
|
||||||
err = fmt.Errorf("hashes do not match expected %s, got %s",
|
err = fmt.Errorf("hashes do not match expected %s, got %s",
|
||||||
hex.EncodeToString(checksumHash), hex.EncodeToString(hashBytes))
|
hex.EncodeToString(checksumHash), hex.EncodeToString(hashBytes))
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ func (c *cacheObjects) hashIndex(bucket, object string) int {
|
|||||||
// or the global env overrides.
|
// or the global env overrides.
|
||||||
func newCache(config cache.Config) ([]*diskCache, bool, error) {
|
func newCache(config cache.Config) ([]*diskCache, bool, error) {
|
||||||
var caches []*diskCache
|
var caches []*diskCache
|
||||||
ctx := logger.SetReqInfo(context.Background(), &logger.ReqInfo{})
|
ctx := logger.SetReqInfo(GlobalContext, &logger.ReqInfo{})
|
||||||
formats, migrating, err := loadAndValidateCacheFormat(ctx, config.Drives)
|
formats, migrating, err := loadAndValidateCacheFormat(ctx, config.Drives)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ func TestDiskCacheMaxUse(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cache := d[0]
|
cache := d[0]
|
||||||
ctx := context.Background()
|
ctx := GlobalContext
|
||||||
bucketName := "testbucket"
|
bucketName := "testbucket"
|
||||||
objectName := "testobject"
|
objectName := "testobject"
|
||||||
content := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
content := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
@ -817,7 +817,7 @@ func (o *ObjectInfo) EncryptedSize() int64 {
|
|||||||
// This cannot happen since AWS S3 allows parts to be 5GB at most
|
// This cannot happen since AWS S3 allows parts to be 5GB at most
|
||||||
// sio max. size is 256 TB
|
// sio max. size is 256 TB
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("size", strconv.FormatUint(size, 10))
|
reqInfo := (&logger.ReqInfo{}).AppendTags("size", strconv.FormatUint(size, 10))
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.CriticalIf(ctx, err)
|
logger.CriticalIf(ctx, err)
|
||||||
}
|
}
|
||||||
return int64(size)
|
return int64(size)
|
||||||
@ -845,7 +845,7 @@ func DecryptCopyObjectInfo(info *ObjectInfo, headers http.Header) (errCode APIEr
|
|||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if info.Size, err = info.DecryptedSize(); err != nil {
|
if info.Size, err = info.DecryptedSize(); err != nil {
|
||||||
errCode = toAPIErrorCode(context.Background(), err)
|
errCode = toAPIErrorCode(GlobalContext, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -271,7 +270,7 @@ func hostResolveToLocalhost(endpoint Endpoint) bool {
|
|||||||
"host",
|
"host",
|
||||||
endpoint.Hostname(),
|
endpoint.Hostname(),
|
||||||
)
|
)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.Application)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -341,7 +340,7 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
|||||||
startTime.Add(timeElapsed),
|
startTime.Add(timeElapsed),
|
||||||
"elapsed",
|
"elapsed",
|
||||||
""))
|
""))
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.Application)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -368,7 +367,7 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
|||||||
"elapsed",
|
"elapsed",
|
||||||
"",
|
"",
|
||||||
))
|
))
|
||||||
ctx := logger.SetReqInfo(context.Background(),
|
ctx := logger.SetReqInfo(GlobalContext,
|
||||||
reqInfo)
|
reqInfo)
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.Application)
|
||||||
}
|
}
|
||||||
@ -399,7 +398,7 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
|||||||
"elapsed",
|
"elapsed",
|
||||||
"",
|
"",
|
||||||
))
|
))
|
||||||
ctx := logger.SetReqInfo(context.Background(),
|
ctx := logger.SetReqInfo(GlobalContext,
|
||||||
reqInfo)
|
reqInfo)
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.Application)
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ func formatXLFixDeploymentID(endpoints Endpoints, storageDisks []StorageAPI, ref
|
|||||||
}
|
}
|
||||||
// Deployment ID needs to be set on all the disks.
|
// Deployment ID needs to be set on all the disks.
|
||||||
// Save `format.json` across all disks.
|
// Save `format.json` across all disks.
|
||||||
return saveFormatXLAll(context.Background(), storageDisks, formats)
|
return saveFormatXLAll(GlobalContext, storageDisks, formats)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ func formatXLFixLocalDeploymentID(endpoints Endpoints, storageDisks []StorageAPI
|
|||||||
}
|
}
|
||||||
format.ID = refFormat.ID
|
format.ID = refFormat.ID
|
||||||
if err := saveFormatXL(storageDisks[index], format, format.XL.This); err != nil {
|
if err := saveFormatXL(storageDisks[index], format, format.XL.This); err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return fmt.Errorf("Unable to save format.json, %w", err)
|
return fmt.Errorf("Unable to save format.json, %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -36,19 +35,19 @@ func TestFSRenameFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(path)
|
defer os.RemoveAll(path)
|
||||||
|
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "testvolume1")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "testvolume1")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = fsRenameFile(context.Background(), pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2")); err != nil {
|
if err = fsRenameFile(GlobalContext, pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = fsRenameFile(context.Background(), pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2")); err != errFileNotFound {
|
if err = fsRenameFile(GlobalContext, pathJoin(path, "testvolume1"), pathJoin(path, "testvolume2")); err != errFileNotFound {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = fsRenameFile(context.Background(), pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), pathJoin(path, "testvolume2")); err != errFileNameTooLong {
|
if err = fsRenameFile(GlobalContext, pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"), pathJoin(path, "testvolume2")); err != errFileNameTooLong {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
if err = fsRenameFile(context.Background(), pathJoin(path, "testvolume1"), pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); err != errFileNameTooLong {
|
if err = fsRenameFile(GlobalContext, pathJoin(path, "testvolume1"), pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); err != errFileNameTooLong {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,30 +62,30 @@ func TestFSStats(t *testing.T) {
|
|||||||
|
|
||||||
// Setup test environment.
|
// Setup test environment.
|
||||||
|
|
||||||
if err = fsMkdir(context.Background(), ""); err != errInvalidArgument {
|
if err = fsMkdir(GlobalContext, ""); err != errInvalidArgument {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); err != errFileNameTooLong {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); err != errFileNameTooLong {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol")); err != nil {
|
||||||
t.Fatalf("Unable to create volume, %s", err)
|
t.Fatalf("Unable to create volume, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var reader = bytes.NewReader([]byte("Hello, world"))
|
var reader = bytes.NewReader([]byte("Hello, world"))
|
||||||
if _, err = fsCreateFile(context.Background(), pathJoin(path, "success-vol", "success-file"), reader, nil, 0); err != nil {
|
if _, err = fsCreateFile(GlobalContext, pathJoin(path, "success-vol", "success-file"), reader, nil, 0); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
// Seek back.
|
// Seek back.
|
||||||
reader.Seek(0, 0)
|
reader.Seek(0, 0)
|
||||||
|
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol", "success-file")); err != errVolumeExists {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol", "success-file")); err != errVolumeExists {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = fsCreateFile(context.Background(), pathJoin(path, "success-vol", "path/to/success-file"), reader, nil, 0); err != nil {
|
if _, err = fsCreateFile(GlobalContext, pathJoin(path, "success-vol", "path/to/success-file"), reader, nil, 0); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
// Seek back.
|
// Seek back.
|
||||||
@ -169,12 +168,12 @@ func TestFSStats(t *testing.T) {
|
|||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
if testCase.srcPath != "" {
|
if testCase.srcPath != "" {
|
||||||
if _, err := fsStatFile(context.Background(), pathJoin(testCase.srcFSPath, testCase.srcVol,
|
if _, err := fsStatFile(GlobalContext, pathJoin(testCase.srcFSPath, testCase.srcVol,
|
||||||
testCase.srcPath)); err != testCase.expectedErr {
|
testCase.srcPath)); err != testCase.expectedErr {
|
||||||
t.Fatalf("TestPosix case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
t.Fatalf("TestPosix case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if _, err := fsStatVolume(context.Background(), pathJoin(testCase.srcFSPath, testCase.srcVol)); err != testCase.expectedErr {
|
if _, err := fsStatVolume(GlobalContext, pathJoin(testCase.srcFSPath, testCase.srcVol)); err != testCase.expectedErr {
|
||||||
t.Fatalf("TestPosix case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
t.Fatalf("TestPosix case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,20 +188,20 @@ func TestFSCreateAndOpen(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(path)
|
defer os.RemoveAll(path)
|
||||||
|
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol")); err != nil {
|
||||||
t.Fatalf("Unable to create directory, %s", err)
|
t.Fatalf("Unable to create directory, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = fsCreateFile(context.Background(), "", nil, nil, 0); err != errInvalidArgument {
|
if _, err = fsCreateFile(GlobalContext, "", nil, nil, 0); err != errInvalidArgument {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, _, err = fsOpenFile(context.Background(), "", -1); err != errInvalidArgument {
|
if _, _, err = fsOpenFile(GlobalContext, "", -1); err != errInvalidArgument {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var reader = bytes.NewReader([]byte("Hello, world"))
|
var reader = bytes.NewReader([]byte("Hello, world"))
|
||||||
if _, err = fsCreateFile(context.Background(), pathJoin(path, "success-vol", "success-file"), reader, nil, 0); err != nil {
|
if _, err = fsCreateFile(GlobalContext, pathJoin(path, "success-vol", "success-file"), reader, nil, 0); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
// Seek back.
|
// Seek back.
|
||||||
@ -230,18 +229,18 @@ func TestFSCreateAndOpen(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
_, err = fsCreateFile(context.Background(), pathJoin(path, testCase.srcVol, testCase.srcPath), reader, nil, 0)
|
_, err = fsCreateFile(GlobalContext, pathJoin(path, testCase.srcVol, testCase.srcPath), reader, nil, 0)
|
||||||
if err != testCase.expectedErr {
|
if err != testCase.expectedErr {
|
||||||
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
_, _, err = fsOpenFile(context.Background(), pathJoin(path, testCase.srcVol, testCase.srcPath), 0)
|
_, _, err = fsOpenFile(GlobalContext, pathJoin(path, testCase.srcVol, testCase.srcPath), 0)
|
||||||
if err != testCase.expectedErr {
|
if err != testCase.expectedErr {
|
||||||
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to open a directory.
|
// Attempt to open a directory.
|
||||||
if _, _, err = fsOpenFile(context.Background(), pathJoin(path), 0); err != errIsNotRegular {
|
if _, _, err = fsOpenFile(GlobalContext, pathJoin(path), 0); err != errIsNotRegular {
|
||||||
t.Fatal("Unexpected error", err)
|
t.Fatal("Unexpected error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,20 +254,20 @@ func TestFSDeletes(t *testing.T) {
|
|||||||
defer os.RemoveAll(path)
|
defer os.RemoveAll(path)
|
||||||
|
|
||||||
// Setup test environment.
|
// Setup test environment.
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol")); err != nil {
|
||||||
t.Fatalf("Unable to create directory, %s", err)
|
t.Fatalf("Unable to create directory, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf = make([]byte, 4096)
|
var buf = make([]byte, 4096)
|
||||||
var reader = bytes.NewReader([]byte("Hello, world"))
|
var reader = bytes.NewReader([]byte("Hello, world"))
|
||||||
if _, err = fsCreateFile(context.Background(), pathJoin(path, "success-vol", "success-file"), reader, buf, reader.Size()); err != nil {
|
if _, err = fsCreateFile(GlobalContext, pathJoin(path, "success-vol", "success-file"), reader, buf, reader.Size()); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
// Seek back.
|
// Seek back.
|
||||||
reader.Seek(0, io.SeekStart)
|
reader.Seek(0, io.SeekStart)
|
||||||
|
|
||||||
// folder is not empty
|
// folder is not empty
|
||||||
err = fsMkdir(context.Background(), pathJoin(path, "success-vol", "not-empty"))
|
err = fsMkdir(GlobalContext, pathJoin(path, "success-vol", "not-empty"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -278,10 +277,10 @@ func TestFSDeletes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recursive
|
// recursive
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol", "parent")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol", "parent")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol", "parent", "dir")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol", "parent", "dir")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +342,7 @@ func TestFSDeletes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
if err = fsDeleteFile(context.Background(), testCase.basePath, pathJoin(testCase.basePath, testCase.srcVol, testCase.srcPath)); err != testCase.expectedErr {
|
if err = fsDeleteFile(GlobalContext, testCase.basePath, pathJoin(testCase.basePath, testCase.srcVol, testCase.srcPath)); err != testCase.expectedErr {
|
||||||
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,7 +357,7 @@ func BenchmarkFSDeleteFile(b *testing.B) {
|
|||||||
defer os.RemoveAll(path)
|
defer os.RemoveAll(path)
|
||||||
|
|
||||||
// Setup test environment.
|
// Setup test environment.
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "benchmark")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "benchmark")); err != nil {
|
||||||
b.Fatalf("Unable to create directory, %s", err)
|
b.Fatalf("Unable to create directory, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +374,7 @@ func BenchmarkFSDeleteFile(b *testing.B) {
|
|||||||
}
|
}
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
|
|
||||||
err = fsDeleteFile(context.Background(), benchDir, filename)
|
err = fsDeleteFile(GlobalContext, benchDir, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -392,18 +391,18 @@ func TestFSRemoves(t *testing.T) {
|
|||||||
defer os.RemoveAll(path)
|
defer os.RemoveAll(path)
|
||||||
|
|
||||||
// Setup test environment.
|
// Setup test environment.
|
||||||
if err = fsMkdir(context.Background(), pathJoin(path, "success-vol")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(path, "success-vol")); err != nil {
|
||||||
t.Fatalf("Unable to create directory, %s", err)
|
t.Fatalf("Unable to create directory, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var reader = bytes.NewReader([]byte("Hello, world"))
|
var reader = bytes.NewReader([]byte("Hello, world"))
|
||||||
if _, err = fsCreateFile(context.Background(), pathJoin(path, "success-vol", "success-file"), reader, nil, 0); err != nil {
|
if _, err = fsCreateFile(GlobalContext, pathJoin(path, "success-vol", "success-file"), reader, nil, 0); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
// Seek back.
|
// Seek back.
|
||||||
reader.Seek(0, 0)
|
reader.Seek(0, 0)
|
||||||
|
|
||||||
if _, err = fsCreateFile(context.Background(), pathJoin(path, "success-vol", "success-file-new"), reader, nil, 0); err != nil {
|
if _, err = fsCreateFile(GlobalContext, pathJoin(path, "success-vol", "success-file-new"), reader, nil, 0); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
// Seek back.
|
// Seek back.
|
||||||
@ -477,25 +476,25 @@ func TestFSRemoves(t *testing.T) {
|
|||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
if testCase.srcPath != "" {
|
if testCase.srcPath != "" {
|
||||||
if err = fsRemoveFile(context.Background(), pathJoin(testCase.srcFSPath, testCase.srcVol, testCase.srcPath)); err != testCase.expectedErr {
|
if err = fsRemoveFile(GlobalContext, pathJoin(testCase.srcFSPath, testCase.srcVol, testCase.srcPath)); err != testCase.expectedErr {
|
||||||
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
t.Errorf("Test case %d: Expected: \"%s\", got: \"%s\"", i+1, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err = fsRemoveDir(context.Background(), pathJoin(testCase.srcFSPath, testCase.srcVol, testCase.srcPath)); err != testCase.expectedErr {
|
if err = fsRemoveDir(GlobalContext, pathJoin(testCase.srcFSPath, testCase.srcVol, testCase.srcPath)); err != testCase.expectedErr {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = fsRemoveAll(context.Background(), pathJoin(path, "success-vol")); err != nil {
|
if err = fsRemoveAll(GlobalContext, pathJoin(path, "success-vol")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = fsRemoveAll(context.Background(), ""); err != errInvalidArgument {
|
if err = fsRemoveAll(GlobalContext, ""); err != errInvalidArgument {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = fsRemoveAll(context.Background(), "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"); err != errFileNameTooLong {
|
if err = fsRemoveAll(GlobalContext, "my-obj-del-0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"); err != errFileNameTooLong {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,14 +508,14 @@ func TestFSRemoveMeta(t *testing.T) {
|
|||||||
defer os.RemoveAll(fsPath)
|
defer os.RemoveAll(fsPath)
|
||||||
|
|
||||||
// Setup test environment.
|
// Setup test environment.
|
||||||
if err = fsMkdir(context.Background(), pathJoin(fsPath, "success-vol")); err != nil {
|
if err = fsMkdir(GlobalContext, pathJoin(fsPath, "success-vol")); err != nil {
|
||||||
t.Fatalf("Unable to create directory, %s", err)
|
t.Fatalf("Unable to create directory, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath := pathJoin(fsPath, "success-vol", "success-file")
|
filePath := pathJoin(fsPath, "success-vol", "success-file")
|
||||||
|
|
||||||
var reader = bytes.NewReader([]byte("Hello, world"))
|
var reader = bytes.NewReader([]byte("Hello, world"))
|
||||||
if _, err = fsCreateFile(context.Background(), filePath, reader, nil, 0); err != nil {
|
if _, err = fsCreateFile(GlobalContext, filePath, reader, nil, 0); err != nil {
|
||||||
t.Fatalf("Unable to create file, %s", err)
|
t.Fatalf("Unable to create file, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,7 +534,7 @@ func TestFSRemoveMeta(t *testing.T) {
|
|||||||
t.Fatal(tmpErr)
|
t.Fatal(tmpErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := fsRemoveMeta(context.Background(), fsPath, filePath, tmpDir); err != nil {
|
if err := fsRemoveMeta(GlobalContext, fsPath, filePath, tmpDir); err != nil {
|
||||||
t.Fatalf("Unable to remove file, %s", err)
|
t.Fatalf("Unable to remove file, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,7 +560,7 @@ func TestFSIsFile(t *testing.T) {
|
|||||||
t.Fatalf("Unable to create file %s", filePath)
|
t.Fatalf("Unable to create file %s", filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fsIsFile(context.Background(), filePath) {
|
if !fsIsFile(GlobalContext, filePath) {
|
||||||
t.Fatalf("Expected %s to be a file", filePath)
|
t.Fatalf("Expected %s to be a file", filePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -54,10 +53,10 @@ func TestReadFSMetadata(t *testing.T) {
|
|||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
if _, err := obj.PutObject(context.Background(), bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{}); err != nil {
|
if _, err := obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{}); err != nil {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ func TestReadFSMetadata(t *testing.T) {
|
|||||||
|
|
||||||
// Regular fs metadata reading, no errors expected
|
// Regular fs metadata reading, no errors expected
|
||||||
fsMeta := fsMetaV1{}
|
fsMeta := fsMetaV1{}
|
||||||
if _, err = fsMeta.ReadFrom(context.Background(), rlk.LockedFile); err != nil {
|
if _, err = fsMeta.ReadFrom(GlobalContext, rlk.LockedFile); err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,10 +88,10 @@ func TestWriteFSMetadata(t *testing.T) {
|
|||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
if _, err := obj.PutObject(context.Background(), bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{}); err != nil {
|
if _, err := obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{}); err != nil {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +107,7 @@ func TestWriteFSMetadata(t *testing.T) {
|
|||||||
|
|
||||||
// FS metadata reading, no errors expected (healthy disk)
|
// FS metadata reading, no errors expected (healthy disk)
|
||||||
fsMeta := fsMetaV1{}
|
fsMeta := fsMetaV1{}
|
||||||
_, err = fsMeta.ReadFrom(context.Background(), rlk.LockedFile)
|
_, err = fsMeta.ReadFrom(GlobalContext, rlk.LockedFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func TestFSCleanupMultipartUploadsInRoutine(t *testing.T) {
|
|||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
// Create a context we can cancel.
|
// Create a context we can cancel.
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(GlobalContext)
|
||||||
obj.MakeBucketWithLocation(ctx, bucketName, "")
|
obj.MakeBucketWithLocation(ctx, bucketName, "")
|
||||||
|
|
||||||
uploadID, err := obj.NewMultipartUpload(ctx, bucketName, objectName, ObjectOptions{})
|
uploadID, err := obj.NewMultipartUpload(ctx, bucketName, objectName, ObjectOptions{})
|
||||||
@ -51,7 +51,7 @@ func TestFSCleanupMultipartUploadsInRoutine(t *testing.T) {
|
|||||||
cleanupWg.Add(1)
|
cleanupWg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer cleanupWg.Done()
|
defer cleanupWg.Done()
|
||||||
fs.cleanupStaleMultipartUploads(context.Background(), time.Millisecond, 0, ctx.Done())
|
fs.cleanupStaleMultipartUploads(GlobalContext, time.Millisecond, 0, ctx.Done())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for 100ms such that - we have given enough time for
|
// Wait for 100ms such that - we have given enough time for
|
||||||
@ -61,7 +61,7 @@ func TestFSCleanupMultipartUploadsInRoutine(t *testing.T) {
|
|||||||
cleanupWg.Wait()
|
cleanupWg.Wait()
|
||||||
|
|
||||||
// Check if upload id was already purged.
|
// Check if upload id was already purged.
|
||||||
if err = obj.AbortMultipartUpload(context.Background(), bucketName, objectName, uploadID); err != nil {
|
if err = obj.AbortMultipartUpload(GlobalContext, bucketName, objectName, uploadID); err != nil {
|
||||||
if _, ok := err.(InvalidUploadID); !ok {
|
if _, ok := err.(InvalidUploadID); !ok {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
@ -81,13 +81,13 @@ func TestNewMultipartUploadFaultyDisk(t *testing.T) {
|
|||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Cannot create bucket, err: ", err)
|
t.Fatal("Cannot create bucket, err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with disk removed.
|
// Test with disk removed.
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
if _, err := fs.NewMultipartUpload(context.Background(), bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}}); err != nil {
|
if _, err := fs.NewMultipartUpload(GlobalContext, bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}}); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
@ -106,11 +106,11 @@ func TestPutObjectPartFaultyDisk(t *testing.T) {
|
|||||||
data := []byte("12345")
|
data := []byte("12345")
|
||||||
dataLen := int64(len(data))
|
dataLen := int64(len(data))
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Cannot create bucket, err: ", err)
|
t.Fatal("Cannot create bucket, err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadID, err := obj.NewMultipartUpload(context.Background(), bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
uploadID, err := obj.NewMultipartUpload(GlobalContext, bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ func TestPutObjectPartFaultyDisk(t *testing.T) {
|
|||||||
newDisk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
newDisk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
||||||
defer os.RemoveAll(newDisk)
|
defer os.RemoveAll(newDisk)
|
||||||
obj = initFSObjects(newDisk, t)
|
obj = initFSObjects(newDisk, t)
|
||||||
if _, err = obj.PutObjectPart(context.Background(), bucketName, objectName, uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(data), dataLen, md5Hex, sha256sum), ObjectOptions{}); err != nil {
|
if _, err = obj.PutObjectPart(GlobalContext, bucketName, objectName, uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(data), dataLen, md5Hex, sha256sum), ObjectOptions{}); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
@ -139,11 +139,11 @@ func TestCompleteMultipartUploadFaultyDisk(t *testing.T) {
|
|||||||
objectName := "object"
|
objectName := "object"
|
||||||
data := []byte("12345")
|
data := []byte("12345")
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Cannot create bucket, err: ", err)
|
t.Fatal("Cannot create bucket, err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadID, err := obj.NewMultipartUpload(context.Background(), bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
uploadID, err := obj.NewMultipartUpload(GlobalContext, bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ func TestCompleteMultipartUploadFaultyDisk(t *testing.T) {
|
|||||||
newDisk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
newDisk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
||||||
defer os.RemoveAll(newDisk)
|
defer os.RemoveAll(newDisk)
|
||||||
obj = initFSObjects(newDisk, t)
|
obj = initFSObjects(newDisk, t)
|
||||||
if _, err := obj.CompleteMultipartUpload(context.Background(), bucketName, objectName, uploadID, parts, ObjectOptions{}); err != nil {
|
if _, err := obj.CompleteMultipartUpload(GlobalContext, bucketName, objectName, uploadID, parts, ObjectOptions{}); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
@ -172,23 +172,23 @@ func TestCompleteMultipartUpload(t *testing.T) {
|
|||||||
objectName := "object"
|
objectName := "object"
|
||||||
data := []byte("12345")
|
data := []byte("12345")
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Cannot create bucket, err: ", err)
|
t.Fatal("Cannot create bucket, err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadID, err := obj.NewMultipartUpload(context.Background(), bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
uploadID, err := obj.NewMultipartUpload(GlobalContext, bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
md5Hex := getMD5Hash(data)
|
md5Hex := getMD5Hash(data)
|
||||||
|
|
||||||
if _, err := obj.PutObjectPart(context.Background(), bucketName, objectName, uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(data), 5, md5Hex, ""), ObjectOptions{}); err != nil {
|
if _, err := obj.PutObjectPart(GlobalContext, bucketName, objectName, uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(data), 5, md5Hex, ""), ObjectOptions{}); err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts := []CompletePart{{PartNumber: 1, ETag: md5Hex}}
|
parts := []CompletePart{{PartNumber: 1, ETag: md5Hex}}
|
||||||
if _, err := obj.CompleteMultipartUpload(context.Background(), bucketName, objectName, uploadID, parts, ObjectOptions{}); err != nil {
|
if _, err := obj.CompleteMultipartUpload(GlobalContext, bucketName, objectName, uploadID, parts, ObjectOptions{}); err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,22 +204,22 @@ func TestAbortMultipartUpload(t *testing.T) {
|
|||||||
objectName := "object"
|
objectName := "object"
|
||||||
data := []byte("12345")
|
data := []byte("12345")
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Cannot create bucket, err: ", err)
|
t.Fatal("Cannot create bucket, err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadID, err := obj.NewMultipartUpload(context.Background(), bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
uploadID, err := obj.NewMultipartUpload(GlobalContext, bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
md5Hex := getMD5Hash(data)
|
md5Hex := getMD5Hash(data)
|
||||||
|
|
||||||
if _, err := obj.PutObjectPart(context.Background(), bucketName, objectName, uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(data), 5, md5Hex, ""), ObjectOptions{}); err != nil {
|
if _, err := obj.PutObjectPart(GlobalContext, bucketName, objectName, uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(data), 5, md5Hex, ""), ObjectOptions{}); err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second) // Without Sleep on windows, the fs.AbortMultipartUpload() fails with "The process cannot access the file because it is being used by another process."
|
time.Sleep(time.Second) // Without Sleep on windows, the fs.AbortMultipartUpload() fails with "The process cannot access the file because it is being used by another process."
|
||||||
if err := obj.AbortMultipartUpload(context.Background(), bucketName, objectName, uploadID); err != nil {
|
if err := obj.AbortMultipartUpload(GlobalContext, bucketName, objectName, uploadID); err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,11 +235,11 @@ func TestListMultipartUploadsFaultyDisk(t *testing.T) {
|
|||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Cannot create bucket, err: ", err)
|
t.Fatal("Cannot create bucket, err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := obj.NewMultipartUpload(context.Background(), bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
_, err := obj.NewMultipartUpload(GlobalContext, bucketName, objectName, ObjectOptions{UserDefined: map[string]string{"X-Amz-Meta-xid": "3f"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ func TestListMultipartUploadsFaultyDisk(t *testing.T) {
|
|||||||
newDisk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
newDisk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
||||||
defer os.RemoveAll(newDisk)
|
defer os.RemoveAll(newDisk)
|
||||||
obj = initFSObjects(newDisk, t)
|
obj = initFSObjects(newDisk, t)
|
||||||
if _, err := obj.ListMultipartUploads(context.Background(), bucketName, objectName, "", "", "", 1000); err != nil {
|
if _, err := obj.ListMultipartUploads(GlobalContext, bucketName, objectName, "", "", "", 1000); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error ", err)
|
t.Fatal("Unexpected error ", err)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"os"
|
"os"
|
||||||
pathutil "path"
|
pathutil "path"
|
||||||
"sync"
|
"sync"
|
||||||
@ -51,7 +50,7 @@ func (fsi *fsIOPool) lookupToRead(path string) (*lock.RLockedFile, bool) {
|
|||||||
if rlkFile.IsClosed() {
|
if rlkFile.IsClosed() {
|
||||||
// Log this as an error.
|
// Log this as an error.
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("path", path)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("path", path)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, errUnexpected)
|
logger.LogIf(ctx, errUnexpected)
|
||||||
|
|
||||||
// Purge the cached lock path from map.
|
// Purge the cached lock path from map.
|
||||||
|
@ -121,7 +121,7 @@ func initMetaVolumeFS(fsPath, fsUUID string) error {
|
|||||||
|
|
||||||
// NewFSObjectLayer - initialize new fs object layer.
|
// NewFSObjectLayer - initialize new fs object layer.
|
||||||
func NewFSObjectLayer(fsPath string) (ObjectLayer, error) {
|
func NewFSObjectLayer(fsPath string) (ObjectLayer, error) {
|
||||||
ctx := context.Background()
|
ctx := GlobalContext
|
||||||
if fsPath == "" {
|
if fsPath == "" {
|
||||||
return nil, errInvalidArgument
|
return nil, errInvalidArgument
|
||||||
}
|
}
|
||||||
@ -1089,7 +1089,7 @@ func (fs *FSObjects) listDirFactory() ListDirFunc {
|
|||||||
var err error
|
var err error
|
||||||
entries, err = readDir(pathJoin(fs.fsPath, bucket, prefixDir))
|
entries, err = readDir(pathJoin(fs.fsPath, bucket, prefixDir))
|
||||||
if err != nil && err != errFileNotFound {
|
if err != nil && err != errFileNotFound {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if len(entries) == 0 {
|
if len(entries) == 0 {
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
@ -37,11 +36,11 @@ func TestFSParentDirIsObject(t *testing.T) {
|
|||||||
bucketName := "testbucket"
|
bucketName := "testbucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
if err = obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err = obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
objectContent := "12345"
|
objectContent := "12345"
|
||||||
objInfo, err := obj.PutObject(context.Background(), bucketName, objectName,
|
objInfo, err := obj.PutObject(GlobalContext, bucketName, objectName,
|
||||||
mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -84,7 +83,7 @@ func TestFSParentDirIsObject(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
gotValue := fs.parentDirIsObject(context.Background(), bucketName, testCase.objectName)
|
gotValue := fs.parentDirIsObject(GlobalContext, bucketName, testCase.objectName)
|
||||||
if testCase.parentIsObject != gotValue {
|
if testCase.parentIsObject != gotValue {
|
||||||
t.Errorf("Test %d: Unexpected value returned got %t, expected %t", i+1, gotValue, testCase.parentIsObject)
|
t.Errorf("Test %d: Unexpected value returned got %t, expected %t", i+1, gotValue, testCase.parentIsObject)
|
||||||
}
|
}
|
||||||
@ -125,23 +124,23 @@ func TestFSShutdown(t *testing.T) {
|
|||||||
fs := obj.(*FSObjects)
|
fs := obj.(*FSObjects)
|
||||||
|
|
||||||
objectContent := "12345"
|
objectContent := "12345"
|
||||||
obj.MakeBucketWithLocation(context.Background(), bucketName, "")
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
obj.PutObject(context.Background(), bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
||||||
return fs, disk
|
return fs, disk
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test Shutdown with regular conditions
|
// Test Shutdown with regular conditions
|
||||||
fs, disk := prepareTest()
|
fs, disk := prepareTest()
|
||||||
if err := fs.Shutdown(context.Background()); err != nil {
|
if err := fs.Shutdown(GlobalContext); err != nil {
|
||||||
t.Fatal("Cannot shutdown the FS object: ", err)
|
t.Fatal("Cannot shutdown the FS object: ", err)
|
||||||
}
|
}
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
|
|
||||||
// Test Shutdown with faulty disk
|
// Test Shutdown with faulty disk
|
||||||
fs, disk = prepareTest()
|
fs, disk = prepareTest()
|
||||||
fs.DeleteObject(context.Background(), bucketName, objectName)
|
fs.DeleteObject(GlobalContext, bucketName, objectName)
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
if err := fs.Shutdown(context.Background()); err != nil {
|
if err := fs.Shutdown(GlobalContext); err != nil {
|
||||||
t.Fatal("Got unexpected fs shutdown error: ", err)
|
t.Fatal("Got unexpected fs shutdown error: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,18 +155,18 @@ func TestFSGetBucketInfo(t *testing.T) {
|
|||||||
fs := obj.(*FSObjects)
|
fs := obj.(*FSObjects)
|
||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
|
|
||||||
err := obj.MakeBucketWithLocation(context.Background(), "a", "")
|
err := obj.MakeBucketWithLocation(GlobalContext, "a", "")
|
||||||
if !isSameType(err, BucketNameInvalid{}) {
|
if !isSameType(err, BucketNameInvalid{}) {
|
||||||
t.Fatal("BucketNameInvalid error not returned")
|
t.Fatal("BucketNameInvalid error not returned")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), bucketName, "")
|
err = obj.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with valid parameters
|
// Test with valid parameters
|
||||||
info, err := fs.GetBucketInfo(context.Background(), bucketName)
|
info, err := fs.GetBucketInfo(GlobalContext, bucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -176,7 +175,7 @@ func TestFSGetBucketInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test with non-existent bucket
|
// Test with non-existent bucket
|
||||||
_, err = fs.GetBucketInfo(context.Background(), "a")
|
_, err = fs.GetBucketInfo(GlobalContext, "a")
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("BucketNotFound error not returned")
|
t.Fatal("BucketNotFound error not returned")
|
||||||
}
|
}
|
||||||
@ -184,7 +183,7 @@ func TestFSGetBucketInfo(t *testing.T) {
|
|||||||
// Check for buckets and should get disk not found.
|
// Check for buckets and should get disk not found.
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
|
|
||||||
if _, err = fs.GetBucketInfo(context.Background(), bucketName); err != nil {
|
if _, err = fs.GetBucketInfo(GlobalContext, bucketName); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("BucketNotFound error not returned")
|
t.Fatal("BucketNotFound error not returned")
|
||||||
}
|
}
|
||||||
@ -200,12 +199,12 @@ func TestFSPutObject(t *testing.T) {
|
|||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
objectName := "1/2/3/4/object"
|
objectName := "1/2/3/4/object"
|
||||||
|
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// With a regular object.
|
// With a regular object.
|
||||||
_, err := obj.PutObject(context.Background(), bucketName+"non-existent", objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
_, err := obj.PutObject(GlobalContext, bucketName+"non-existent", objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Unexpected should fail here, bucket doesn't exist")
|
t.Fatal("Unexpected should fail here, bucket doesn't exist")
|
||||||
}
|
}
|
||||||
@ -214,7 +213,7 @@ func TestFSPutObject(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// With a directory object.
|
// With a directory object.
|
||||||
_, err = obj.PutObject(context.Background(), bucketName+"non-existent", objectName+SlashSeparator, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), 0, "", ""), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucketName+"non-existent", objectName+SlashSeparator, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), 0, "", ""), ObjectOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Unexpected should fail here, bucket doesn't exist")
|
t.Fatal("Unexpected should fail here, bucket doesn't exist")
|
||||||
}
|
}
|
||||||
@ -222,11 +221,11 @@ func TestFSPutObject(t *testing.T) {
|
|||||||
t.Fatalf("Expected error type BucketNotFound, got %#v", err)
|
t.Fatalf("Expected error type BucketNotFound, got %#v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
_, err = obj.PutObject(context.Background(), bucketName, objectName+"/1", mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucketName, objectName+"/1", mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Unexpected should fail here, backend corruption occurred")
|
t.Fatal("Unexpected should fail here, backend corruption occurred")
|
||||||
}
|
}
|
||||||
@ -241,7 +240,7 @@ func TestFSPutObject(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucketName, objectName+"/1/", mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), 0, "", ""), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucketName, objectName+"/1/", mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), 0, "", ""), ObjectOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("Unexpected should fail here, backned corruption occurred")
|
t.Fatal("Unexpected should fail here, backned corruption occurred")
|
||||||
}
|
}
|
||||||
@ -268,33 +267,33 @@ func TestFSDeleteObject(t *testing.T) {
|
|||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
obj.MakeBucketWithLocation(context.Background(), bucketName, "")
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
obj.PutObject(context.Background(), bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
obj.PutObject(GlobalContext, bucketName, objectName, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
||||||
|
|
||||||
// Test with invalid bucket name
|
// Test with invalid bucket name
|
||||||
if err := fs.DeleteObject(context.Background(), "fo", objectName); !isSameType(err, BucketNameInvalid{}) {
|
if err := fs.DeleteObject(GlobalContext, "fo", objectName); !isSameType(err, BucketNameInvalid{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with bucket does not exist
|
// Test with bucket does not exist
|
||||||
if err := fs.DeleteObject(context.Background(), "foobucket", "fooobject"); !isSameType(err, BucketNotFound{}) {
|
if err := fs.DeleteObject(GlobalContext, "foobucket", "fooobject"); !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with invalid object name
|
// Test with invalid object name
|
||||||
if err := fs.DeleteObject(context.Background(), bucketName, "\\"); !isSameType(err, ObjectNotFound{}) {
|
if err := fs.DeleteObject(GlobalContext, bucketName, "\\"); !isSameType(err, ObjectNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with object does not exist.
|
// Test with object does not exist.
|
||||||
if err := fs.DeleteObject(context.Background(), bucketName, "foooobject"); !isSameType(err, ObjectNotFound{}) {
|
if err := fs.DeleteObject(GlobalContext, bucketName, "foooobject"); !isSameType(err, ObjectNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with valid condition
|
// Test with valid condition
|
||||||
if err := fs.DeleteObject(context.Background(), bucketName, objectName); err != nil {
|
if err := fs.DeleteObject(GlobalContext, bucketName, objectName); err != nil {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete object should err disk not found.
|
// Delete object should err disk not found.
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
if err := fs.DeleteObject(context.Background(), bucketName, objectName); err != nil {
|
if err := fs.DeleteObject(GlobalContext, bucketName, objectName); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@ -312,30 +311,30 @@ func TestFSDeleteBucket(t *testing.T) {
|
|||||||
fs := obj.(*FSObjects)
|
fs := obj.(*FSObjects)
|
||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
|
|
||||||
err := obj.MakeBucketWithLocation(context.Background(), bucketName, "")
|
err := obj.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with an invalid bucket name
|
// Test with an invalid bucket name
|
||||||
if err = fs.DeleteBucket(context.Background(), "fo", false); !isSameType(err, BucketNotFound{}) {
|
if err = fs.DeleteBucket(GlobalContext, "fo", false); !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test with an inexistant bucket
|
// Test with an inexistant bucket
|
||||||
if err = fs.DeleteBucket(context.Background(), "foobucket", false); !isSameType(err, BucketNotFound{}) {
|
if err = fs.DeleteBucket(GlobalContext, "foobucket", false); !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
// Test with a valid case
|
// Test with a valid case
|
||||||
if err = fs.DeleteBucket(context.Background(), bucketName, false); err != nil {
|
if err = fs.DeleteBucket(GlobalContext, bucketName, false); err != nil {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.MakeBucketWithLocation(context.Background(), bucketName, "")
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
|
|
||||||
// Delete bucket should get error disk not found.
|
// Delete bucket should get error disk not found.
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
if err = fs.DeleteBucket(context.Background(), bucketName, false); err != nil {
|
if err = fs.DeleteBucket(GlobalContext, bucketName, false); err != nil {
|
||||||
if !isSameType(err, BucketNotFound{}) {
|
if !isSameType(err, BucketNotFound{}) {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@ -352,7 +351,7 @@ func TestFSListBuckets(t *testing.T) {
|
|||||||
fs := obj.(*FSObjects)
|
fs := obj.(*FSObjects)
|
||||||
|
|
||||||
bucketName := "bucket"
|
bucketName := "bucket"
|
||||||
if err := obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err := obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +366,7 @@ func TestFSListBuckets(t *testing.T) {
|
|||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
// Test list buckets to have only one entry.
|
// Test list buckets to have only one entry.
|
||||||
buckets, err := fs.ListBuckets(context.Background())
|
buckets, err := fs.ListBuckets(GlobalContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@ -377,7 +376,7 @@ func TestFSListBuckets(t *testing.T) {
|
|||||||
|
|
||||||
// Test ListBuckets with disk not found.
|
// Test ListBuckets with disk not found.
|
||||||
os.RemoveAll(disk)
|
os.RemoveAll(disk)
|
||||||
if _, err := fs.ListBuckets(context.Background()); err != nil {
|
if _, err := fs.ListBuckets(GlobalContext); err != nil {
|
||||||
if err != errDiskNotFound {
|
if err != errDiskNotFound {
|
||||||
t.Fatal("Unexpected error: ", err)
|
t.Fatal("Unexpected error: ", err)
|
||||||
}
|
}
|
||||||
@ -390,7 +389,7 @@ func TestFSHealObject(t *testing.T) {
|
|||||||
defer os.RemoveAll(disk)
|
defer os.RemoveAll(disk)
|
||||||
|
|
||||||
obj := initFSObjects(disk, t)
|
obj := initFSObjects(disk, t)
|
||||||
_, err := obj.HealObject(context.Background(), "bucket", "object", madmin.HealOpts{})
|
_, err := obj.HealObject(GlobalContext, "bucket", "object", madmin.HealOpts{})
|
||||||
if err == nil || !isSameType(err, NotImplemented{}) {
|
if err == nil || !isSameType(err, NotImplemented{}) {
|
||||||
t.Fatalf("Heal Object should return NotImplemented error ")
|
t.Fatalf("Heal Object should return NotImplemented error ")
|
||||||
}
|
}
|
||||||
@ -402,7 +401,7 @@ func TestFSHealObjects(t *testing.T) {
|
|||||||
defer os.RemoveAll(disk)
|
defer os.RemoveAll(disk)
|
||||||
|
|
||||||
obj := initFSObjects(disk, t)
|
obj := initFSObjects(disk, t)
|
||||||
err := obj.HealObjects(context.Background(), "bucket", "prefix", madmin.HealOpts{}, nil)
|
err := obj.HealObjects(GlobalContext, "bucket", "prefix", madmin.HealOpts{}, nil)
|
||||||
if err == nil || !isSameType(err, NotImplemented{}) {
|
if err == nil || !isSameType(err, NotImplemented{}) {
|
||||||
t.Fatalf("Heal Object should return NotImplemented error ")
|
t.Fatalf("Heal Object should return NotImplemented error ")
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -134,7 +133,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
|||||||
gatewayHandleEnvVars()
|
gatewayHandleEnvVars()
|
||||||
|
|
||||||
// Set system resources to maximum.
|
// Set system resources to maximum.
|
||||||
logger.LogIf(context.Background(), setMaxResources())
|
logger.LogIf(GlobalContext, setMaxResources())
|
||||||
|
|
||||||
// Set when gateway is enabled
|
// Set when gateway is enabled
|
||||||
globalIsGateway = true
|
globalIsGateway = true
|
||||||
@ -237,7 +236,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
|||||||
// sub-systems, make sure that we do not move the above codeblock elsewhere.
|
// sub-systems, make sure that we do not move the above codeblock elsewhere.
|
||||||
if enableConfigOps {
|
if enableConfigOps {
|
||||||
logger.FatalIf(globalConfigSys.Init(newObject), "Unable to initialize config system")
|
logger.FatalIf(globalConfigSys.Init(newObject), "Unable to initialize config system")
|
||||||
buckets, err := newObject.ListBuckets(context.Background())
|
buckets, err := newObject.ListBuckets(GlobalContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal(err, "Unable to list buckets")
|
logger.Fatal(err, "Unable to list buckets")
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ func printGatewayStartupMessage(apiEndPoints []string, backendType string) {
|
|||||||
// If cache layer is enabled, print cache capacity.
|
// If cache layer is enabled, print cache capacity.
|
||||||
cacheAPI := newCachedObjectLayerFn()
|
cacheAPI := newCachedObjectLayerFn()
|
||||||
if cacheAPI != nil {
|
if cacheAPI != nil {
|
||||||
printCacheStorageInfo(cacheAPI.StorageInfo(context.Background()))
|
printCacheStorageInfo(cacheAPI.StorageInfo(GlobalContext))
|
||||||
}
|
}
|
||||||
// Prints credential.
|
// Prints credential.
|
||||||
printGatewayCommonMsg(strippedAPIEndpoints)
|
printGatewayCommonMsg(strippedAPIEndpoints)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -84,7 +83,7 @@ func TestS3MetaToAzureProperties(t *testing.T) {
|
|||||||
"X_Amz_Matdesc": "{}",
|
"X_Amz_Matdesc": "{}",
|
||||||
"X_Amz_Iv": "eWmyryl8kq+EVnnsE7jpOg==",
|
"X_Amz_Iv": "eWmyryl8kq+EVnnsE7jpOg==",
|
||||||
}
|
}
|
||||||
meta, _, err := s3MetaToAzureProperties(context.Background(), headers)
|
meta, _, err := s3MetaToAzureProperties(minio.GlobalContext, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test failed, with %s", err)
|
t.Fatalf("Test failed, with %s", err)
|
||||||
}
|
}
|
||||||
@ -94,7 +93,7 @@ func TestS3MetaToAzureProperties(t *testing.T) {
|
|||||||
headers = map[string]string{
|
headers = map[string]string{
|
||||||
"invalid--meta": "value",
|
"invalid--meta": "value",
|
||||||
}
|
}
|
||||||
_, _, err = s3MetaToAzureProperties(context.Background(), headers)
|
_, _, err = s3MetaToAzureProperties(minio.GlobalContext, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(minio.UnsupportedMetadata); !ok {
|
if _, ok := err.(minio.UnsupportedMetadata); !ok {
|
||||||
t.Fatalf("Test failed with unexpected error %s, expected UnsupportedMetadata", err)
|
t.Fatalf("Test failed with unexpected error %s, expected UnsupportedMetadata", err)
|
||||||
@ -104,7 +103,7 @@ func TestS3MetaToAzureProperties(t *testing.T) {
|
|||||||
headers = map[string]string{
|
headers = map[string]string{
|
||||||
"content-md5": "Dce7bmCX61zvxzP5QmfelQ==",
|
"content-md5": "Dce7bmCX61zvxzP5QmfelQ==",
|
||||||
}
|
}
|
||||||
_, props, err := s3MetaToAzureProperties(context.Background(), headers)
|
_, props, err := s3MetaToAzureProperties(minio.GlobalContext, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test failed, with %s", err)
|
t.Fatalf("Test failed, with %s", err)
|
||||||
}
|
}
|
||||||
@ -286,7 +285,7 @@ func TestCheckAzureUploadID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, uploadID := range invalidUploadIDs {
|
for _, uploadID := range invalidUploadIDs {
|
||||||
if err := checkAzureUploadID(context.Background(), uploadID); err == nil {
|
if err := checkAzureUploadID(minio.GlobalContext, uploadID); err == nil {
|
||||||
t.Fatalf("%s: expected: <error>, got: <nil>", uploadID)
|
t.Fatalf("%s: expected: <error>, got: <nil>", uploadID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +296,7 @@ func TestCheckAzureUploadID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, uploadID := range validUploadIDs {
|
for _, uploadID := range validUploadIDs {
|
||||||
if err := checkAzureUploadID(context.Background(), uploadID); err != nil {
|
if err := checkAzureUploadID(minio.GlobalContext, uploadID); err != nil {
|
||||||
t.Fatalf("%s: expected: <nil>, got: %s", uploadID, err)
|
t.Fatalf("%s: expected: <nil>, got: %s", uploadID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ func (g *B2) Name() string {
|
|||||||
// NewGatewayLayer returns b2 gateway layer, implements ObjectLayer interface to
|
// NewGatewayLayer returns b2 gateway layer, implements ObjectLayer interface to
|
||||||
// talk to B2 remote backend.
|
// talk to B2 remote backend.
|
||||||
func (g *B2) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *B2) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
||||||
ctx := context.Background()
|
ctx := minio.GlobalContext
|
||||||
client, err := b2.AuthorizeAccount(ctx, creds.AccessKey, creds.SecretKey, b2.Transport(minio.NewGatewayHTTPTransport()))
|
client, err := b2.AuthorizeAccount(ctx, creds.AccessKey, creds.SecretKey, b2.Transport(minio.NewGatewayHTTPTransport()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -144,12 +144,12 @@ EXAMPLES:
|
|||||||
func gcsGatewayMain(ctx *cli.Context) {
|
func gcsGatewayMain(ctx *cli.Context) {
|
||||||
projectID := ctx.Args().First()
|
projectID := ctx.Args().First()
|
||||||
if projectID == "" && os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" {
|
if projectID == "" && os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" {
|
||||||
logger.LogIf(context.Background(), errGCSProjectIDNotFound, logger.Application)
|
logger.LogIf(minio.GlobalContext, errGCSProjectIDNotFound, logger.Application)
|
||||||
cli.ShowCommandHelpAndExit(ctx, "gcs", 1)
|
cli.ShowCommandHelpAndExit(ctx, "gcs", 1)
|
||||||
}
|
}
|
||||||
if projectID != "" && !isValidGCSProjectIDFormat(projectID) {
|
if projectID != "" && !isValidGCSProjectIDFormat(projectID) {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("projectID", ctx.Args().First())
|
reqInfo := (&logger.ReqInfo{}).AppendTags("projectID", ctx.Args().First())
|
||||||
contxt := logger.SetReqInfo(context.Background(), reqInfo)
|
contxt := logger.SetReqInfo(minio.GlobalContext, reqInfo)
|
||||||
logger.LogIf(contxt, errGCSInvalidProjectID, logger.Application)
|
logger.LogIf(contxt, errGCSInvalidProjectID, logger.Application)
|
||||||
cli.ShowCommandHelpAndExit(ctx, "gcs", 1)
|
cli.ShowCommandHelpAndExit(ctx, "gcs", 1)
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ func (g *GCS) Name() string {
|
|||||||
|
|
||||||
// NewGatewayLayer returns gcs ObjectLayer.
|
// NewGatewayLayer returns gcs ObjectLayer.
|
||||||
func (g *GCS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *GCS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
||||||
ctx := context.Background()
|
ctx := minio.GlobalContext
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if g.projectID == "" {
|
if g.projectID == "" {
|
||||||
@ -373,7 +373,7 @@ func (l *gcsGateway) CleanupGCSMinioSysTmpBucket(ctx context.Context, bucket str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if err != iterator.Done {
|
if err != iterator.Done {
|
||||||
reqInfo := &logger.ReqInfo{BucketName: bucket}
|
reqInfo := &logger.ReqInfo{BucketName: bucket}
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(minio.GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -383,7 +383,7 @@ func (l *gcsGateway) CleanupGCSMinioSysTmpBucket(ctx context.Context, bucket str
|
|||||||
err := l.client.Bucket(bucket).Object(attrs.Name).Delete(ctx)
|
err := l.client.Bucket(bucket).Object(attrs.Name).Delete(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := &logger.ReqInfo{BucketName: bucket, ObjectName: attrs.Name}
|
reqInfo := &logger.ReqInfo{BucketName: bucket, ObjectName: attrs.Name}
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(minio.GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -332,13 +332,13 @@ func (n *hdfsObjects) listDirFactory() minio.ListDirFunc {
|
|||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(minio.GlobalContext, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
fis, err := f.Readdir(0)
|
fis, err := f.Readdir(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(minio.GlobalContext, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(fis) == 0 {
|
if len(fis) == 0 {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -115,7 +114,7 @@ func TestS3MetaToOSSOptions(t *testing.T) {
|
|||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
"x-amz-meta-invalid_meta": "value",
|
"x-amz-meta-invalid_meta": "value",
|
||||||
}
|
}
|
||||||
_, err = appendS3MetaToOSSOptions(context.Background(), nil, headers)
|
_, err = appendS3MetaToOSSOptions(minio.GlobalContext, nil, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(minio.UnsupportedMetadata); !ok {
|
if _, ok := err.(minio.UnsupportedMetadata); !ok {
|
||||||
t.Fatalf("Test failed with unexpected error %s, expected UnsupportedMetadata", err)
|
t.Fatalf("Test failed with unexpected error %s, expected UnsupportedMetadata", err)
|
||||||
@ -132,7 +131,7 @@ func TestS3MetaToOSSOptions(t *testing.T) {
|
|||||||
"X-Amz-Meta-X-Amz-Matdesc": "{}",
|
"X-Amz-Meta-X-Amz-Matdesc": "{}",
|
||||||
"X-Amz-Meta-X-Amz-Iv": "eWmyryl8kq+EVnnsE7jpOg==",
|
"X-Amz-Meta-X-Amz-Iv": "eWmyryl8kq+EVnnsE7jpOg==",
|
||||||
}
|
}
|
||||||
opts, err := appendS3MetaToOSSOptions(context.Background(), nil, headers)
|
opts, err := appendS3MetaToOSSOptions(minio.GlobalContext, nil, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test failed, with %s", err)
|
t.Fatalf("Test failed, with %s", err)
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,9 @@ package s3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
minio "github.com/minio/minio/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tests for GW metadata format validity.
|
// Tests for GW metadata format validity.
|
||||||
@ -62,7 +63,7 @@ func TestReadGWMetadata(t *testing.T) {
|
|||||||
|
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
buf := bytes.NewBufferString(tt.metaStr)
|
buf := bytes.NewBufferString(tt.metaStr)
|
||||||
m, err := readGWMetadata(context.Background(), *buf)
|
m, err := readGWMetadata(minio.GlobalContext, *buf)
|
||||||
if err != nil && tt.pass {
|
if err != nil && tt.pass {
|
||||||
t.Errorf("Test %d: Expected parse gw metadata to succeed, but failed, %s", i+1, err)
|
t.Errorf("Test %d: Expected parse gw metadata to succeed, but failed, %s", i+1, err)
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ func (g *S3) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
|
|||||||
encS := s3EncObjects{s}
|
encS := s3EncObjects{s}
|
||||||
|
|
||||||
// Start stale enc multipart uploads cleanup routine.
|
// Start stale enc multipart uploads cleanup routine.
|
||||||
go encS.cleanupStaleEncMultipartUploads(context.Background(),
|
go encS.cleanupStaleEncMultipartUploads(minio.GlobalContext,
|
||||||
minio.GlobalMultipartCleanupInterval, minio.GlobalMultipartExpiry, minio.GlobalServiceDoneCh)
|
minio.GlobalMultipartCleanupInterval, minio.GlobalMultipartExpiry, minio.GlobalServiceDoneCh)
|
||||||
|
|
||||||
return &encS, nil
|
return &encS, nil
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -723,7 +722,7 @@ func setBucketForwardingHandler(h http.Handler) http.Handler {
|
|||||||
PassHost: true,
|
PassHost: true,
|
||||||
RoundTripper: NewGatewayHTTPTransport(),
|
RoundTripper: NewGatewayHTTPTransport(),
|
||||||
Logger: func(err error) {
|
Logger: func(err error) {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return bucketForwardingHandler{fwd, h}
|
return bucketForwardingHandler{fwd, h}
|
||||||
|
@ -51,7 +51,7 @@ func parseLocationConstraint(r *http.Request) (location string, s3Error APIError
|
|||||||
locationConstraint := createBucketLocationConfiguration{}
|
locationConstraint := createBucketLocationConfiguration{}
|
||||||
err := xmlDecoder(r.Body, &locationConstraint, r.ContentLength)
|
err := xmlDecoder(r.Body, &locationConstraint, r.ContentLength)
|
||||||
if err != nil && r.ContentLength != 0 {
|
if err != nil && r.ContentLength != 0 {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
// Treat all other failures as XML parsing errors.
|
// Treat all other failures as XML parsing errors.
|
||||||
return "", ErrMalformedXML
|
return "", ErrMalformedXML
|
||||||
} // else for both err as nil or io.EOF
|
} // else for both err as nil or io.EOF
|
||||||
@ -431,7 +431,7 @@ func getResource(path string, host string, domains []string) (string, error) {
|
|||||||
if host, _, err = net.SplitHostPort(host); err != nil {
|
if host, _, err = net.SplitHostPort(host); err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("host", host)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("host", host)
|
||||||
reqInfo.AppendTags("path", path)
|
reqInfo.AppendTags("path", path)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -164,6 +163,6 @@ func webRequestAuthenticate(req *http.Request) (*xjwt.MapClaims, bool, error) {
|
|||||||
func newAuthToken(audience string) string {
|
func newAuthToken(audience string) string {
|
||||||
cred := globalActiveCred
|
cred := globalActiveCred
|
||||||
token, err := authenticateNode(cred.AccessKey, cred.SecretKey, audience)
|
token, err := authenticateNode(cred.AccessKey, cred.SecretKey, audience)
|
||||||
logger.CriticalIf(context.Background(), err)
|
logger.CriticalIf(GlobalContext, err)
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (sys *LifecycleSys) Get(bucketName string) (lc lifecycle.Lifecycle, ok bool
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l, err := objAPI.GetBucketLifecycle(context.Background(), bucketName)
|
l, err := objAPI.GetBucketLifecycle(GlobalContext, bucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func saveLifecycleConfig(ctx context.Context, objAPI ObjectLayer, bucketName str
|
|||||||
func getLifecycleConfig(objAPI ObjectLayer, bucketName string) (*lifecycle.Lifecycle, error) {
|
func getLifecycleConfig(objAPI ObjectLayer, bucketName string) (*lifecycle.Lifecycle, error) {
|
||||||
// Construct path to lifecycle.xml for the given bucket.
|
// Construct path to lifecycle.xml for the given bucket.
|
||||||
configFile := path.Join(bucketConfigPrefix, bucketName, bucketLifecycleConfig)
|
configFile := path.Join(bucketConfigPrefix, bucketName, bucketLifecycleConfig)
|
||||||
configData, err := readConfig(context.Background(), objAPI, configFile)
|
configData, err := readConfig(GlobalContext, objAPI, configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errConfigNotFound {
|
if err == errConfigNotFound {
|
||||||
err = BucketLifecycleNotFound{Bucket: bucketName}
|
err = BucketLifecycleNotFound{Bucket: bucketName}
|
||||||
@ -139,7 +139,7 @@ func (sys *LifecycleSys) Init(buckets []BucketInfo, objAPI ObjectLayer) error {
|
|||||||
// Loads lifecycle policies for all buckets into LifecycleSys.
|
// Loads lifecycle policies for all buckets into LifecycleSys.
|
||||||
func (sys *LifecycleSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
func (sys *LifecycleSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
||||||
for _, bucket := range buckets {
|
for _, bucket := range buckets {
|
||||||
config, err := objAPI.GetBucketLifecycle(context.Background(), bucket.Name)
|
config, err := objAPI.GetBucketLifecycle(GlobalContext, bucket.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(BucketLifecycleNotFound); ok {
|
if _, ok := err.(BucketLifecycleNotFound); ok {
|
||||||
sys.Remove(bucket.Name)
|
sys.Remove(bucket.Name)
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
@ -174,7 +173,7 @@ func newlockRESTClient(endpoint Endpoint) *lockRESTClient {
|
|||||||
trFn := newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout, rest.DefaultRESTTimeout)
|
trFn := newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout, rest.DefaultRESTTimeout)
|
||||||
restClient, err := rest.NewClient(serverURL, trFn, newAuthToken)
|
restClient, err := rest.NewClient(serverURL, trFn, newAuthToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return &lockRESTClient{endpoint: endpoint, restClient: restClient, connected: 0}
|
return &lockRESTClient{endpoint: endpoint, restClient: restClient, connected: 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -163,7 +162,7 @@ func gatewayMetricsPrometheus(ch chan<- prometheus.Metric) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := objLayer.GetMetrics(context.Background())
|
m, err := objLayer.GetMetrics(GlobalContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -354,7 +353,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch disk space info
|
// Fetch disk space info
|
||||||
storageInfo := objLayer.StorageInfo(context.Background(), true)
|
storageInfo := objLayer.StorageInfo(GlobalContext, true)
|
||||||
|
|
||||||
offlineDisks := storageInfo.Backend.OfflineDisks
|
offlineDisks := storageInfo.Backend.OfflineDisks
|
||||||
onlineDisks := storageInfo.Backend.OnlineDisks
|
onlineDisks := storageInfo.Backend.OnlineDisks
|
||||||
@ -424,13 +423,13 @@ func metricsHandler() http.Handler {
|
|||||||
registry := prometheus.NewRegistry()
|
registry := prometheus.NewRegistry()
|
||||||
|
|
||||||
err := registry.Register(minioVersionInfo)
|
err := registry.Register(minioVersionInfo)
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
|
|
||||||
err = registry.Register(httpRequestsDuration)
|
err = registry.Register(httpRequestsDuration)
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
|
|
||||||
err = registry.Register(newMinioCollector())
|
err = registry.Register(newMinioCollector())
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
|
|
||||||
gatherers := prometheus.Gatherers{
|
gatherers := prometheus.Gatherers{
|
||||||
prometheus.DefaultGatherer,
|
prometheus.DefaultGatherer,
|
||||||
|
@ -128,7 +128,7 @@ func (n *nsLockMap) unlock(volume string, path string, readLock bool) {
|
|||||||
}
|
}
|
||||||
n.lockMapMutex.Lock()
|
n.lockMapMutex.Lock()
|
||||||
if nsLk.ref == 0 {
|
if nsLk.ref == 0 {
|
||||||
logger.LogIf(context.Background(), errors.New("Namespace reference count cannot be 0"))
|
logger.LogIf(GlobalContext, errors.New("Namespace reference count cannot be 0"))
|
||||||
} else {
|
} else {
|
||||||
nsLk.ref--
|
nsLk.ref--
|
||||||
if nsLk.ref == 0 {
|
if nsLk.ref == 0 {
|
||||||
|
@ -143,7 +143,7 @@ func (sys *NotificationSys) ReloadFormat(dryRun bool) []NotificationPeerErr {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.ReloadFormat(dryRun)
|
return client.ReloadFormat(dryRun)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ func (sys *NotificationSys) DeletePolicy(policyName string) []NotificationPeerEr
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.DeletePolicy(policyName)
|
return client.DeletePolicy(policyName)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ func (sys *NotificationSys) LoadPolicy(policyName string) []NotificationPeerErr
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.LoadPolicy(policyName)
|
return client.LoadPolicy(policyName)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ func (sys *NotificationSys) LoadPolicyMapping(userOrGroup string, isGroup bool)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.LoadPolicyMapping(userOrGroup, isGroup)
|
return client.LoadPolicyMapping(userOrGroup, isGroup)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ func (sys *NotificationSys) DeleteUser(accessKey string) []NotificationPeerErr {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.DeleteUser(accessKey)
|
return client.DeleteUser(accessKey)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ func (sys *NotificationSys) LoadUser(accessKey string, temp bool) []Notification
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.LoadUser(accessKey, temp)
|
return client.LoadUser(accessKey, temp)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ func (sys *NotificationSys) LoadGroup(group string) []NotificationPeerErr {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error { return client.LoadGroup(group) }, idx, *client.host)
|
ng.Go(GlobalContext, func() error { return client.LoadGroup(group) }, idx, *client.host)
|
||||||
}
|
}
|
||||||
return ng.Wait()
|
return ng.Wait()
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ func (sys *NotificationSys) BackgroundHealStatus() []madmin.BgHealState {
|
|||||||
}
|
}
|
||||||
st, err := client.BackgroundHealStatus()
|
st, err := client.BackgroundHealStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
} else {
|
} else {
|
||||||
states[idx] = st
|
states[idx] = st
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ func (sys *NotificationSys) StartProfiling(profiler string) []NotificationPeerEr
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.StartProfiling(profiler)
|
return client.StartProfiling(profiler)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ func (sys *NotificationSys) ServerUpdate(updateURL, sha256Hex string, latestRele
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.ServerUpdate(updateURL, sha256Hex, latestReleaseTime)
|
return client.ServerUpdate(updateURL, sha256Hex, latestReleaseTime)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ func (sys *NotificationSys) SignalService(sig serviceSignal) []NotificationPeerE
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
client := client
|
client := client
|
||||||
ng.Go(context.Background(), func() error {
|
ng.Go(GlobalContext, func() error {
|
||||||
return client.SignalService(sig)
|
return client.SignalService(sig)
|
||||||
}, idx, *client.host)
|
}, idx, *client.host)
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ func (sys *NotificationSys) RemoteTargetExist(bucketName string, targetID event.
|
|||||||
// Loads notification policies for all buckets into NotificationSys.
|
// Loads notification policies for all buckets into NotificationSys.
|
||||||
func (sys *NotificationSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
func (sys *NotificationSys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
||||||
for _, bucket := range buckets {
|
for _, bucket := range buckets {
|
||||||
ctx := logger.SetReqInfo(context.Background(), &logger.ReqInfo{BucketName: bucket.Name})
|
ctx := logger.SetReqInfo(GlobalContext, &logger.ReqInfo{BucketName: bucket.Name})
|
||||||
config, err := readNotificationConfig(ctx, objAPI, bucket.Name)
|
config, err := readNotificationConfig(ctx, objAPI, bucket.Name)
|
||||||
if err != nil && err != errNoSuchNotifications {
|
if err != nil && err != errNoSuchNotifications {
|
||||||
if _, ok := err.(*event.ErrARNNotFound); ok {
|
if _, ok := err.(*event.ErrARNNotFound); ok {
|
||||||
@ -769,7 +769,7 @@ func (sys *NotificationSys) RemoveAllRemoteTargets() {
|
|||||||
func (sys *NotificationSys) RemoveRemoteTarget(bucketName string, targetID event.TargetID) {
|
func (sys *NotificationSys) RemoveRemoteTarget(bucketName string, targetID event.TargetID) {
|
||||||
for terr := range sys.targetList.Remove(targetID) {
|
for terr := range sys.targetList.Remove(targetID) {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("targetID", terr.ID.Name)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("targetID", terr.ID.Name)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, terr.Err)
|
logger.LogIf(ctx, terr.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,7 +843,7 @@ func (sys *NotificationSys) NetReadPerfInfo(size int64) []ServerNetReadPerfInfo
|
|||||||
info, err := client.NetReadPerfInfo(size)
|
info, err := client.NetReadPerfInfo(size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", client.host.String())
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", client.host.String())
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
|
|
||||||
info.Addr = client.host.String()
|
info.Addr = client.host.String()
|
||||||
@ -869,7 +869,7 @@ func (sys *NotificationSys) CollectNetPerfInfo(size int64) map[string][]ServerNe
|
|||||||
info, err := client.CollectNetPerfInfo(size)
|
info, err := client.CollectNetPerfInfo(size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", client.host.String())
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", client.host.String())
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ func (sys *NotificationSys) NetOBDInfo(ctx context.Context) madmin.ServerNetOBDI
|
|||||||
|
|
||||||
addr := client.host.String()
|
addr := client.host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
netOBDs[index].Addr = addr
|
netOBDs[index].Addr = addr
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1029,7 +1029,7 @@ func (sys *NotificationSys) DriveOBDInfo(ctx context.Context) []madmin.ServerDri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1059,7 +1059,7 @@ func (sys *NotificationSys) CPUOBDInfo(ctx context.Context) []madmin.ServerCPUOB
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1089,7 +1089,7 @@ func (sys *NotificationSys) DiskHwOBDInfo(ctx context.Context) []madmin.ServerDi
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1119,7 +1119,7 @@ func (sys *NotificationSys) OsOBDInfo(ctx context.Context) []madmin.ServerOsOBDI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1149,7 +1149,7 @@ func (sys *NotificationSys) MemOBDInfo(ctx context.Context) []madmin.ServerMemOB
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1179,7 +1179,7 @@ func (sys *NotificationSys) ProcOBDInfo(ctx context.Context) []madmin.ServerProc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1209,7 +1209,7 @@ func (sys *NotificationSys) DrivePerfInfo(size int64) []madmin.ServerDrivesPerfI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1239,7 +1239,7 @@ func (sys *NotificationSys) MemUsageInfo() []ServerMemUsageInfo {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1269,7 +1269,7 @@ func (sys *NotificationSys) CPULoadInfo() []ServerCPULoadInfo {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
addr := sys.peerClients[index].host.String()
|
addr := sys.peerClients[index].host.String()
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("remotePeer", addr)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
reply[index].Addr = addr
|
reply[index].Addr = addr
|
||||||
reply[index].Error = err.Error()
|
reply[index].Error = err.Error()
|
||||||
@ -1467,7 +1467,7 @@ func sendEvent(args eventArgs) {
|
|||||||
reqInfo := &logger.ReqInfo{BucketName: args.BucketName, ObjectName: args.Object.Name}
|
reqInfo := &logger.ReqInfo{BucketName: args.BucketName, ObjectName: args.Object.Name}
|
||||||
reqInfo.AppendTags("EventName", args.EventName.String())
|
reqInfo.AppendTags("EventName", args.EventName.String())
|
||||||
reqInfo.AppendTags("targetID", err.ID.Name)
|
reqInfo.AppendTags("targetID", err.ID.Name)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogOnceIf(ctx, err.Err, err.ID)
|
logger.LogOnceIf(ctx, err.Err, err.ID)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -219,7 +218,7 @@ func pathJoin(elem ...string) string {
|
|||||||
func mustGetUUID() string {
|
func mustGetUUID() string {
|
||||||
uuid, err := uuid.New()
|
uuid, err := uuid.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.CriticalIf(context.Background(), err)
|
logger.CriticalIf(GlobalContext, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return uuid.String()
|
return uuid.String()
|
||||||
|
@ -375,7 +375,7 @@ func checkPutObjectLockAllowed(ctx context.Context, r *http.Request, bucket, obj
|
|||||||
|
|
||||||
func initBucketObjectLockConfig(buckets []BucketInfo, objAPI ObjectLayer) error {
|
func initBucketObjectLockConfig(buckets []BucketInfo, objAPI ObjectLayer) error {
|
||||||
for _, bucket := range buckets {
|
for _, bucket := range buckets {
|
||||||
ctx := logger.SetReqInfo(context.Background(), &logger.ReqInfo{BucketName: bucket.Name})
|
ctx := logger.SetReqInfo(GlobalContext, &logger.ReqInfo{BucketName: bucket.Name})
|
||||||
configFile := path.Join(bucketConfigPrefix, bucket.Name, bucketObjectLockEnabledConfigFile)
|
configFile := path.Join(bucketConfigPrefix, bucket.Name, bucketObjectLockEnabledConfigFile)
|
||||||
bucketObjLockData, err := readConfig(ctx, objAPI, configFile)
|
bucketObjLockData, err := readConfig(ctx, objAPI, configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -66,7 +66,7 @@ func (client *peerRESTClient) reConnect() {
|
|||||||
// permanently. The only way to restore the connection is at the xl-sets layer by xlsets.monitorAndConnectEndpoints()
|
// permanently. The only way to restore the connection is at the xl-sets layer by xlsets.monitorAndConnectEndpoints()
|
||||||
// after verifying format.json
|
// after verifying format.json
|
||||||
func (client *peerRESTClient) call(method string, values url.Values, body io.Reader, length int64) (respBody io.ReadCloser, err error) {
|
func (client *peerRESTClient) call(method string, values url.Values, body io.Reader, length int64) (respBody io.ReadCloser, err error) {
|
||||||
return client.callWithContext(context.Background(), method, values, body, length)
|
return client.callWithContext(GlobalContext, method, values, body, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper to restClient.Call to handle network errors, in case of network error the connection is marked disconnected
|
// Wrapper to restClient.Call to handle network errors, in case of network error the connection is marked disconnected
|
||||||
@ -633,7 +633,7 @@ func (client *peerRESTClient) sendEvent(bucket string, targetID, remoteTargetID
|
|||||||
reqInfo := &logger.ReqInfo{BucketName: bucket}
|
reqInfo := &logger.ReqInfo{BucketName: bucket}
|
||||||
reqInfo.AppendTags("targetID", targetID.Name)
|
reqInfo.AppendTags("targetID", targetID.Name)
|
||||||
reqInfo.AppendTags("event", eventData.EventName.String())
|
reqInfo.AppendTags("event", eventData.EventName.String())
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
globalNotificationSys.RemoveRemoteTarget(bucket, targetID)
|
globalNotificationSys.RemoveRemoteTarget(bucket, targetID)
|
||||||
}
|
}
|
||||||
@ -934,7 +934,7 @@ func (client *peerRESTClient) doTrace(traceCh chan interface{}, doneCh chan stru
|
|||||||
values.Set(peerRESTTraceErr, strconv.FormatBool(trcErr))
|
values.Set(peerRESTTraceErr, strconv.FormatBool(trcErr))
|
||||||
|
|
||||||
// To cancel the REST request in case doneCh gets closed.
|
// To cancel the REST request in case doneCh gets closed.
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(GlobalContext)
|
||||||
|
|
||||||
cancelCh := make(chan struct{})
|
cancelCh := make(chan struct{})
|
||||||
defer close(cancelCh)
|
defer close(cancelCh)
|
||||||
@ -972,7 +972,7 @@ func (client *peerRESTClient) doTrace(traceCh chan interface{}, doneCh chan stru
|
|||||||
|
|
||||||
func (client *peerRESTClient) doListen(listenCh chan interface{}, doneCh chan struct{}, v url.Values) {
|
func (client *peerRESTClient) doListen(listenCh chan interface{}, doneCh chan struct{}, v url.Values) {
|
||||||
// To cancel the REST request in case doneCh gets closed.
|
// To cancel the REST request in case doneCh gets closed.
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(GlobalContext)
|
||||||
|
|
||||||
cancelCh := make(chan struct{})
|
cancelCh := make(chan struct{})
|
||||||
defer close(cancelCh)
|
defer close(cancelCh)
|
||||||
@ -1045,7 +1045,7 @@ func (client *peerRESTClient) ConsoleLog(logCh chan interface{}, doneCh chan str
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
// get cancellation context to properly unsubscribe peers
|
// get cancellation context to properly unsubscribe peers
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(GlobalContext)
|
||||||
respBody, err := client.callWithContext(ctx, peerRESTMethodLog, nil, nil, -1)
|
respBody, err := client.callWithContext(ctx, peerRESTMethodLog, nil, nil, -1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Retry the failed request.
|
// Retry the failed request.
|
||||||
@ -1087,7 +1087,7 @@ func getRemoteHosts(endpointZones EndpointZones) []*xnet.Host {
|
|||||||
for _, hostStr := range GetRemotePeers(endpointZones) {
|
for _, hostStr := range GetRemotePeers(endpointZones) {
|
||||||
host, err := xnet.ParseHost(hostStr)
|
host, err := xnet.ParseHost(hostStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
remoteHosts = append(remoteHosts, host)
|
remoteHosts = append(remoteHosts, host)
|
||||||
@ -1102,7 +1102,7 @@ func getRestClients(endpoints EndpointZones) []*peerRESTClient {
|
|||||||
for i, host := range peerHosts {
|
for i, host := range peerHosts {
|
||||||
client, err := newPeerRESTClient(host)
|
client, err := newPeerRESTClient(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
restClients[i] = client
|
restClients[i] = client
|
||||||
|
@ -729,7 +729,7 @@ func (s *peerRESTServer) ReloadFormatHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := objAPI.ReloadFormat(context.Background(), dryRun)
|
err := objAPI.ReloadFormat(GlobalContext, dryRun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.writeErrorResponse(w, err)
|
s.writeErrorResponse(w, err)
|
||||||
return
|
return
|
||||||
@ -947,7 +947,7 @@ func (s *peerRESTServer) SendEventHandler(w http.ResponseWriter, r *http.Request
|
|||||||
for i := range errs {
|
for i := range errs {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("Event", eventReq.Event.EventName.String())
|
reqInfo := (&logger.ReqInfo{}).AppendTags("Event", eventReq.Event.EventName.String())
|
||||||
reqInfo.AppendTags("targetName", eventReq.TargetID.Name)
|
reqInfo.AppendTags("targetName", eventReq.TargetID.Name)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, errs[i].Err)
|
logger.LogIf(ctx, errs[i].Err)
|
||||||
|
|
||||||
eventResp.Success = false
|
eventResp.Success = false
|
||||||
|
@ -74,7 +74,7 @@ func (sys *PolicySys) IsAllowed(args policy.Args) bool {
|
|||||||
// is used to validate bucket policies.
|
// is used to validate bucket policies.
|
||||||
objAPI := newObjectLayerFn()
|
objAPI := newObjectLayerFn()
|
||||||
if objAPI != nil {
|
if objAPI != nil {
|
||||||
config, err := objAPI.GetBucketPolicy(context.Background(), args.BucketName)
|
config, err := objAPI.GetBucketPolicy(GlobalContext, args.BucketName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return config.IsAllowed(args)
|
return config.IsAllowed(args)
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ func (sys *PolicySys) IsAllowed(args policy.Args) bool {
|
|||||||
// Loads policies for all buckets into PolicySys.
|
// Loads policies for all buckets into PolicySys.
|
||||||
func (sys *PolicySys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
func (sys *PolicySys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
||||||
for _, bucket := range buckets {
|
for _, bucket := range buckets {
|
||||||
config, err := objAPI.GetBucketPolicy(context.Background(), bucket.Name)
|
config, err := objAPI.GetBucketPolicy(GlobalContext, bucket.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(BucketPolicyNotFound); ok {
|
if _, ok := err.(BucketPolicyNotFound); ok {
|
||||||
sys.Remove(bucket.Name)
|
sys.Remove(bucket.Name)
|
||||||
@ -113,8 +113,8 @@ func (sys *PolicySys) load(buckets []BucketInfo, objAPI ObjectLayer) error {
|
|||||||
logger.Info("Found in-consistent bucket policies, Migrating them for Bucket: (%s)", bucket.Name)
|
logger.Info("Found in-consistent bucket policies, Migrating them for Bucket: (%s)", bucket.Name)
|
||||||
config.Version = policy.DefaultVersion
|
config.Version = policy.DefaultVersion
|
||||||
|
|
||||||
if err = savePolicyConfig(context.Background(), objAPI, bucket.Name, config); err != nil {
|
if err = savePolicyConfig(GlobalContext, objAPI, bucket.Name, config); err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ func getPolicyConfig(objAPI ObjectLayer, bucketName string) (*policy.Policy, err
|
|||||||
// Construct path to policy.json for the given bucket.
|
// Construct path to policy.json for the given bucket.
|
||||||
configFile := path.Join(bucketConfigPrefix, bucketName, bucketPolicyConfig)
|
configFile := path.Join(bucketConfigPrefix, bucketName, bucketPolicyConfig)
|
||||||
|
|
||||||
configData, err := readConfig(context.Background(), objAPI, configFile)
|
configData, err := readConfig(GlobalContext, objAPI, configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errConfigNotFound {
|
if err == errConfigNotFound {
|
||||||
err = BucketPolicyNotFound{Bucket: bucketName}
|
err = BucketPolicyNotFound{Bucket: bucketName}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -80,7 +79,7 @@ func readDirN(dirPath string, count int) (entries []string, err error) {
|
|||||||
st, err = os.Stat(path.Join(dirPath, fi.Name()))
|
st, err = os.Stat(path.Join(dirPath, fi.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("path", path.Join(dirPath, fi.Name()))
|
reqInfo := (&logger.ReqInfo{}).AppendTags("path", path.Join(dirPath, fi.Name()))
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ func isDirEmpty(dirname string) bool {
|
|||||||
f, err := os.Open((dirname))
|
f, err := os.Open((dirname))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -189,7 +189,7 @@ func isDirEmpty(dirname string) bool {
|
|||||||
_, err = f.Readdirnames(1)
|
_, err = f.Readdirnames(1)
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -746,7 +746,7 @@ func (s *posix) WalkSplunk(volume, dirPath, marker string, endWalkCh <-chan stru
|
|||||||
return false, filterMatchingPrefix(entries, dirEntry)
|
return false, filterMatchingPrefix(entries, dirEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
walkResultCh := startTreeWalk(context.Background(), volume, dirPath, marker, true, listDir, endWalkCh)
|
walkResultCh := startTreeWalk(GlobalContext, volume, dirPath, marker, true, listDir, endWalkCh)
|
||||||
for {
|
for {
|
||||||
walkResult, ok := <-walkResultCh
|
walkResult, ok := <-walkResultCh
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -820,7 +820,7 @@ func (s *posix) Walk(volume, dirPath, marker string, recursive bool, leafFile st
|
|||||||
return false, filterMatchingPrefix(entries, dirEntry)
|
return false, filterMatchingPrefix(entries, dirEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
walkResultCh := startTreeWalk(context.Background(), volume, dirPath, marker, recursive, listDir, endWalkCh)
|
walkResultCh := startTreeWalk(GlobalContext, volume, dirPath, marker, recursive, listDir, endWalkCh)
|
||||||
for {
|
for {
|
||||||
walkResult, ok := <-walkResultCh
|
walkResult, ok := <-walkResultCh
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -39,7 +38,7 @@ var printEndpointError = func() func(Endpoint, error) {
|
|||||||
|
|
||||||
return func(endpoint Endpoint, err error) {
|
return func(endpoint Endpoint, err error) {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("endpoint", endpoint.String())
|
reqInfo := (&logger.ReqInfo{}).AppendTags("endpoint", endpoint.String())
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
m, ok := printOnce[endpoint]
|
m, ok := printOnce[endpoint]
|
||||||
@ -272,7 +271,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
|
|||||||
zoneCount, setCount, drivesPerSet)
|
zoneCount, setCount, drivesPerSet)
|
||||||
|
|
||||||
// Initialize erasure code format on disks
|
// Initialize erasure code format on disks
|
||||||
format, err = initFormatXL(context.Background(), storageDisks, setCount, drivesPerSet, deploymentID)
|
format, err = initFormatXL(GlobalContext, storageDisks, setCount, drivesPerSet, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func initSafeMode(buckets []BucketInfo) (err error) {
|
|||||||
// at a given time, this big transaction lock ensures this
|
// at a given time, this big transaction lock ensures this
|
||||||
// appropriately. This is also true for rotation of encrypted
|
// appropriately. This is also true for rotation of encrypted
|
||||||
// content.
|
// content.
|
||||||
objLock := newObject.NewNSLock(context.Background(), minioMetaBucket, transactionConfigPrefix)
|
objLock := newObject.NewNSLock(GlobalContext, minioMetaBucket, transactionConfigPrefix)
|
||||||
if err = objLock.GetLock(globalOperationTimeout); err != nil {
|
if err = objLock.GetLock(globalOperationTimeout); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ func serverMain(ctx *cli.Context) {
|
|||||||
setDefaultProfilerRates()
|
setDefaultProfilerRates()
|
||||||
|
|
||||||
// Initialize globalConsoleSys system
|
// Initialize globalConsoleSys system
|
||||||
globalConsoleSys = NewConsoleLogger(context.Background())
|
globalConsoleSys = NewConsoleLogger(GlobalContext)
|
||||||
|
|
||||||
signal.Notify(globalOSSignalCh, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(globalOSSignalCh, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
@ -55,7 +54,7 @@ func printStartupSafeModeMessage(apiEndpoints []string, err error) {
|
|||||||
// Object layer is initialized then print StorageInfo in safe mode.
|
// Object layer is initialized then print StorageInfo in safe mode.
|
||||||
objAPI := newObjectLayerWithoutSafeModeFn()
|
objAPI := newObjectLayerWithoutSafeModeFn()
|
||||||
if objAPI != nil {
|
if objAPI != nil {
|
||||||
if msg := getStorageInfoMsgSafeMode(objAPI.StorageInfo(context.Background(), false)); msg != "" {
|
if msg := getStorageInfoMsgSafeMode(objAPI.StorageInfo(GlobalContext, false)); msg != "" {
|
||||||
logStartupMessage(msg)
|
logStartupMessage(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,13 +110,13 @@ func printStartupMessage(apiEndpoints []string) {
|
|||||||
// If cache layer is enabled, print cache capacity.
|
// If cache layer is enabled, print cache capacity.
|
||||||
cachedObjAPI := newCachedObjectLayerFn()
|
cachedObjAPI := newCachedObjectLayerFn()
|
||||||
if cachedObjAPI != nil {
|
if cachedObjAPI != nil {
|
||||||
printCacheStorageInfo(cachedObjAPI.StorageInfo(context.Background()))
|
printCacheStorageInfo(cachedObjAPI.StorageInfo(GlobalContext))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object layer is initialized then print StorageInfo.
|
// Object layer is initialized then print StorageInfo.
|
||||||
objAPI := newObjectLayerFn()
|
objAPI := newObjectLayerFn()
|
||||||
if objAPI != nil {
|
if objAPI != nil {
|
||||||
printStorageInfo(objAPI.StorageInfo(context.Background(), false))
|
printStorageInfo(objAPI.StorageInfo(GlobalContext, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints credential, region and browser access.
|
// Prints credential, region and browser access.
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"io"
|
"io"
|
||||||
@ -64,7 +63,7 @@ func getContentSha256Cksum(r *http.Request, stype serviceType) string {
|
|||||||
if stype == serviceSTS {
|
if stype == serviceSTS {
|
||||||
payload, err := ioutil.ReadAll(io.LimitReader(r.Body, stsRequestBodyLimit))
|
payload, err := ioutil.ReadAll(io.LimitReader(r.Body, stsRequestBodyLimit))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.CriticalIf(context.Background(), err)
|
logger.CriticalIf(GlobalContext, err)
|
||||||
}
|
}
|
||||||
sum256 := sha256.New()
|
sum256 := sha256.New()
|
||||||
sum256.Write(payload)
|
sum256.Write(payload)
|
||||||
|
@ -575,7 +575,7 @@ func newStorageRESTClient(endpoint Endpoint) *storageRESTClient {
|
|||||||
trFn := newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout, rest.DefaultRESTTimeout)
|
trFn := newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout, rest.DefaultRESTTimeout)
|
||||||
restClient, err := rest.NewClient(serverURL, trFn, newAuthToken)
|
restClient, err := rest.NewClient(serverURL, trFn, newAuthToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
return &storageRESTClient{endpoint: endpoint, restClient: restClient, connected: 0}
|
return &storageRESTClient{endpoint: endpoint, restClient: restClient, connected: 0}
|
||||||
}
|
}
|
||||||
return &storageRESTClient{endpoint: endpoint, restClient: restClient, connected: 1}
|
return &storageRESTClient{endpoint: endpoint, restClient: restClient, connected: 1}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
@ -414,7 +413,7 @@ func (s *storageRESTServer) ReadFileStreamHandler(w http.ResponseWriter, r *http
|
|||||||
type readMetadataFunc func(buf []byte, volume, entry string) FileInfo
|
type readMetadataFunc func(buf []byte, volume, entry string) FileInfo
|
||||||
|
|
||||||
func readMetadata(buf []byte, volume, entry string) FileInfo {
|
func readMetadata(buf []byte, volume, entry string) FileInfo {
|
||||||
m, err := xlMetaV1UnmarshalJSON(context.Background(), buf)
|
m, err := xlMetaV1UnmarshalJSON(GlobalContext, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FileInfo{}
|
return FileInfo{}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ func IsDocker() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log error, as we will not propagate it to caller
|
// Log error, as we will not propagate it to caller
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
|
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ func IsBOSH() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log error, as we will not propagate it to caller
|
// Log error, as we will not propagate it to caller
|
||||||
logger.LogIf(context.Background(), err)
|
logger.LogIf(GlobalContext, err)
|
||||||
|
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ func getHelmVersion(helmInfoFilePath string) string {
|
|||||||
// without Helm charts as well.
|
// without Helm charts as well.
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("helmInfoFilePath", helmInfoFilePath)
|
reqInfo := (&logger.ReqInfo{}).AppendTags("helmInfoFilePath", helmInfoFilePath)
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
@ -71,7 +71,7 @@ func IsErr(err error, errs ...error) bool {
|
|||||||
func request2BucketObjectName(r *http.Request) (bucketName, objectName string) {
|
func request2BucketObjectName(r *http.Request) (bucketName, objectName string) {
|
||||||
path, err := getResource(r.URL.Path, r.Host, globalDomainNames)
|
path, err := getResource(r.URL.Path, r.Host, globalDomainNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.CriticalIf(context.Background(), err)
|
logger.CriticalIf(GlobalContext, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return path2BucketObject(path)
|
return path2BucketObject(path)
|
||||||
|
@ -247,5 +247,5 @@ func newWebContext(r *http.Request, args ToKeyValuer, api string) context.Contex
|
|||||||
BucketName: bucket,
|
BucketName: bucket,
|
||||||
ObjectName: object,
|
ObjectName: object,
|
||||||
}
|
}
|
||||||
return logger.SetReqInfo(context.Background(), reqInfo)
|
return logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1183,7 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
objInfo, err := putObject(context.Background(), bucket, object, pReader, opts)
|
objInfo, err := putObject(GlobalContext, bucket, object, pReader, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeWebErrorResponse(w, err)
|
writeWebErrorResponse(w, err)
|
||||||
return
|
return
|
||||||
@ -2272,7 +2272,7 @@ func writeWebErrorResponse(w http.ResponseWriter, err error) {
|
|||||||
reqInfo := &logger.ReqInfo{
|
reqInfo := &logger.ReqInfo{
|
||||||
DeploymentID: globalDeploymentID,
|
DeploymentID: globalDeploymentID,
|
||||||
}
|
}
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
apiErr := toWebAPIError(ctx, err)
|
apiErr := toWebAPIError(ctx, err)
|
||||||
w.WriteHeader(apiErr.HTTPStatusCode)
|
w.WriteHeader(apiErr.HTTPStatusCode)
|
||||||
w.Write([]byte(apiErr.Description))
|
w.Write([]byte(apiErr.Description))
|
||||||
|
@ -363,7 +363,7 @@ func newXLSets(endpoints Endpoints, storageDisks []StorageAPI, format *formatXLV
|
|||||||
mrfUploadCh: make(chan partialUpload, 10000),
|
mrfUploadCh: make(chan partialUpload, 10000),
|
||||||
}
|
}
|
||||||
|
|
||||||
go s.sets[i].cleanupStaleMultipartUploads(context.Background(),
|
go s.sets[i].cleanupStaleMultipartUploads(GlobalContext,
|
||||||
GlobalMultipartCleanupInterval, GlobalMultipartExpiry, GlobalServiceDoneCh)
|
GlobalMultipartCleanupInterval, GlobalMultipartExpiry, GlobalServiceDoneCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ func undoMakeBucketSets(bucket string, sets []*xlObjects, errs []error) {
|
|||||||
index := index
|
index := index
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
if errs[index] == nil {
|
if errs[index] == nil {
|
||||||
return sets[index].DeleteBucket(context.Background(), bucket, false)
|
return sets[index].DeleteBucket(GlobalContext, bucket, false)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, index)
|
}, index)
|
||||||
@ -712,7 +712,7 @@ func undoDeleteBucketSets(bucket string, sets []*xlObjects, errs []error) {
|
|||||||
index := index
|
index := index
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
if errs[index] == nil {
|
if errs[index] == nil {
|
||||||
return sets[index].MakeBucketWithLocation(context.Background(), bucket, "")
|
return sets[index].MakeBucketWithLocation(GlobalContext, bucket, "")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, index)
|
}, index)
|
||||||
@ -1026,7 +1026,7 @@ func (s *xlSets) listObjectsNonSlash(ctx context.Context, bucket, prefix, marker
|
|||||||
defer close(endWalkCh)
|
defer close(endWalkCh)
|
||||||
|
|
||||||
const ndisks = 3
|
const ndisks = 3
|
||||||
entryChs := s.startMergeWalksN(context.Background(), bucket, prefix, "", true, endWalkCh, ndisks)
|
entryChs := s.startMergeWalksN(GlobalContext, bucket, prefix, "", true, endWalkCh, ndisks)
|
||||||
|
|
||||||
var objInfos []ObjectInfo
|
var objInfos []ObjectInfo
|
||||||
var eof bool
|
var eof bool
|
||||||
@ -1175,7 +1175,7 @@ func (s *xlSets) listObjects(ctx context.Context, bucket, prefix, marker, delimi
|
|||||||
if entryChs == nil {
|
if entryChs == nil {
|
||||||
endWalkCh = make(chan struct{})
|
endWalkCh = make(chan struct{})
|
||||||
// start file tree walk across at most randomly 3 disks in a set.
|
// start file tree walk across at most randomly 3 disks in a set.
|
||||||
entryChs = s.startMergeWalksN(context.Background(), bucket, prefix, marker, recursive, endWalkCh, ndisks)
|
entryChs = s.startMergeWalksN(GlobalContext, bucket, prefix, marker, recursive, endWalkCh, ndisks)
|
||||||
}
|
}
|
||||||
|
|
||||||
entries := mergeEntriesCh(entryChs, maxKeys, ndisks)
|
entries := mergeEntriesCh(entryChs, maxKeys, ndisks)
|
||||||
|
@ -83,5 +83,5 @@ func (xl xlObjects) isObject(bucket, prefix string) (ok bool) {
|
|||||||
// ignored if necessary.
|
// ignored if necessary.
|
||||||
readQuorum := getReadQuorum(len(storageDisks))
|
readQuorum := getReadQuorum(len(storageDisks))
|
||||||
|
|
||||||
return reduceReadQuorumErrs(context.Background(), g.Wait(), objectOpIgnoredErrs, readQuorum) == nil
|
return reduceReadQuorumErrs(GlobalContext, g.Wait(), objectOpIgnoredErrs, readQuorum) == nil
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -38,11 +37,11 @@ func TestXLParentDirIsObject(t *testing.T) {
|
|||||||
bucketName := "testbucket"
|
bucketName := "testbucket"
|
||||||
objectName := "object"
|
objectName := "object"
|
||||||
|
|
||||||
if err = obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err = obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
objectContent := "12345"
|
objectContent := "12345"
|
||||||
objInfo, err := obj.PutObject(context.Background(), bucketName, objectName,
|
objInfo, err := obj.PutObject(GlobalContext, bucketName, objectName,
|
||||||
mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
mustGetPutObjReader(t, bytes.NewReader([]byte(objectContent)), int64(len(objectContent)), "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -87,7 +86,7 @@ func TestXLParentDirIsObject(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
gotValue := xl.parentDirIsObject(context.Background(), bucketName, testCase.objectName)
|
gotValue := xl.parentDirIsObject(GlobalContext, bucketName, testCase.objectName)
|
||||||
if testCase.parentIsObject != gotValue {
|
if testCase.parentIsObject != gotValue {
|
||||||
t.Errorf("Test %d: Unexpected value returned got %t, expected %t", i+1, gotValue, testCase.parentIsObject)
|
t.Errorf("Test %d: Unexpected value returned got %t, expected %t", i+1, gotValue, testCase.parentIsObject)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -175,15 +174,15 @@ func TestListOnlineDisks(t *testing.T) {
|
|||||||
// Prepare bucket/object backend for the tests below.
|
// Prepare bucket/object backend for the tests below.
|
||||||
|
|
||||||
// Cleanup from previous test.
|
// Cleanup from previous test.
|
||||||
obj.DeleteObject(context.Background(), bucket, object)
|
obj.DeleteObject(GlobalContext, bucket, object)
|
||||||
obj.DeleteBucket(context.Background(), bucket, false)
|
obj.DeleteBucket(GlobalContext, bucket, false)
|
||||||
|
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), "bucket", "")
|
err = obj.MakeBucketWithLocation(GlobalContext, "bucket", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to make a bucket %v", err)
|
t.Fatalf("Failed to make a bucket %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
@ -229,7 +228,7 @@ func TestListOnlineDisks(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partsMetadata, errs := readAllXLMetadata(context.Background(), xlDisks, bucket, object)
|
partsMetadata, errs := readAllXLMetadata(GlobalContext, xlDisks, bucket, object)
|
||||||
for i := range partsMetadata {
|
for i := range partsMetadata {
|
||||||
if errs[i] != nil {
|
if errs[i] != nil {
|
||||||
t.Fatalf("Test %d: expected error to be nil: %s", i+1, errs[i].Error())
|
t.Fatalf("Test %d: expected error to be nil: %s", i+1, errs[i].Error())
|
||||||
@ -243,7 +242,7 @@ func TestListOnlineDisks(t *testing.T) {
|
|||||||
i+1, test.expectedTime, modTime)
|
i+1, test.expectedTime, modTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
availableDisks, newErrs := disksWithAllParts(context.Background(), onlineDisks, partsMetadata, test.errs, bucket, object, madmin.HealDeepScan)
|
availableDisks, newErrs := disksWithAllParts(GlobalContext, onlineDisks, partsMetadata, test.errs, bucket, object, madmin.HealDeepScan)
|
||||||
test.errs = newErrs
|
test.errs = newErrs
|
||||||
|
|
||||||
if test._tamperBackend != noTamper {
|
if test._tamperBackend != noTamper {
|
||||||
@ -257,7 +256,7 @@ func TestListOnlineDisks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDisksWithAllParts(t *testing.T) {
|
func TestDisksWithAllParts(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := GlobalContext
|
||||||
obj, disks, err := prepareXL16()
|
obj, disks, err := prepareXL16()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Prepare XL backend failed - %v", err)
|
t.Fatalf("Prepare XL backend failed - %v", err)
|
||||||
|
@ -712,7 +712,7 @@ func (xl xlObjects) HealObject(ctx context.Context, bucket, object string, opts
|
|||||||
} else {
|
} else {
|
||||||
newReqInfo = logger.NewReqInfo("", "", globalDeploymentID, "", "Heal", bucket, object)
|
newReqInfo = logger.NewReqInfo("", "", globalDeploymentID, "", "Heal", bucket, object)
|
||||||
}
|
}
|
||||||
healCtx := logger.SetReqInfo(context.Background(), newReqInfo)
|
healCtx := logger.SetReqInfo(GlobalContext, newReqInfo)
|
||||||
|
|
||||||
// Healing directories handle it separately.
|
// Healing directories handle it separately.
|
||||||
if HasSuffix(object, SlashSeparator) {
|
if HasSuffix(object, SlashSeparator) {
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ func TestUndoMakeBucket(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bucketName := getRandomBucketName()
|
bucketName := getRandomBucketName()
|
||||||
if err = obj.MakeBucketWithLocation(context.Background(), bucketName, ""); err != nil {
|
if err = obj.MakeBucketWithLocation(GlobalContext, bucketName, ""); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
z := obj.(*xlZones)
|
z := obj.(*xlZones)
|
||||||
@ -49,7 +48,7 @@ func TestUndoMakeBucket(t *testing.T) {
|
|||||||
undoMakeBucket(xl.getDisks(), bucketName)
|
undoMakeBucket(xl.getDisks(), bucketName)
|
||||||
|
|
||||||
// Validate if bucket was deleted properly.
|
// Validate if bucket was deleted properly.
|
||||||
_, err = obj.GetBucketInfo(context.Background(), bucketName)
|
_, err = obj.GetBucketInfo(GlobalContext, bucketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case BucketNotFound:
|
case BucketNotFound:
|
||||||
@ -83,21 +82,21 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
data := bytes.Repeat([]byte("a"), 5*1024*1024)
|
data := bytes.Repeat([]byte("a"), 5*1024*1024)
|
||||||
var opts ObjectOptions
|
var opts ObjectOptions
|
||||||
|
|
||||||
err = objLayer.MakeBucketWithLocation(context.Background(), bucket, "")
|
err = objLayer.MakeBucketWithLocation(GlobalContext, bucket, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to make a bucket - %v", err)
|
t.Fatalf("Failed to make a bucket - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an object with multiple parts uploaded in decreasing
|
// Create an object with multiple parts uploaded in decreasing
|
||||||
// part number.
|
// part number.
|
||||||
uploadID, err := objLayer.NewMultipartUpload(context.Background(), bucket, object, opts)
|
uploadID, err := objLayer.NewMultipartUpload(GlobalContext, bucket, object, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create a multipart upload - %v", err)
|
t.Fatalf("Failed to create a multipart upload - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var uploadedParts []CompletePart
|
var uploadedParts []CompletePart
|
||||||
for _, partID := range []int{2, 1} {
|
for _, partID := range []int{2, 1} {
|
||||||
pInfo, err1 := objLayer.PutObjectPart(context.Background(), bucket, object, uploadID, partID, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), opts)
|
pInfo, err1 := objLayer.PutObjectPart(GlobalContext, bucket, object, uploadID, partID, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), opts)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
t.Fatalf("Failed to upload a part - %v", err1)
|
t.Fatalf("Failed to upload a part - %v", err1)
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = objLayer.CompleteMultipartUpload(context.Background(), bucket, object, uploadID, uploadedParts, ObjectOptions{})
|
_, err = objLayer.CompleteMultipartUpload(GlobalContext, bucket, object, uploadID, uploadedParts, ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to complete multipart upload - %v", err)
|
t.Fatalf("Failed to complete multipart upload - %v", err)
|
||||||
}
|
}
|
||||||
@ -121,7 +120,7 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
t.Fatalf("Failed to delete a file - %v", err)
|
t.Fatalf("Failed to delete a file - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = objLayer.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
_, err = objLayer.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to heal object - %v", err)
|
t.Fatalf("Failed to heal object - %v", err)
|
||||||
}
|
}
|
||||||
@ -144,7 +143,7 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failure during creating part.1 - %v", err)
|
t.Errorf("Failure during creating part.1 - %v", err)
|
||||||
}
|
}
|
||||||
_, err = objLayer.HealObject(context.Background(), bucket, object, madmin.HealOpts{DryRun: false, Remove: true, ScanMode: madmin.HealDeepScan})
|
_, err = objLayer.HealObject(GlobalContext, bucket, object, madmin.HealOpts{DryRun: false, Remove: true, ScanMode: madmin.HealDeepScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected nil but received %v", err)
|
t.Errorf("Expected nil but received %v", err)
|
||||||
}
|
}
|
||||||
@ -170,7 +169,7 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failure during creating part.1 - %v", err)
|
t.Errorf("Failure during creating part.1 - %v", err)
|
||||||
}
|
}
|
||||||
_, err = objLayer.HealObject(context.Background(), bucket, object, madmin.HealOpts{DryRun: false, Remove: true, ScanMode: madmin.HealDeepScan})
|
_, err = objLayer.HealObject(GlobalContext, bucket, object, madmin.HealOpts{DryRun: false, Remove: true, ScanMode: madmin.HealDeepScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected nil but received %v", err)
|
t.Errorf("Expected nil but received %v", err)
|
||||||
}
|
}
|
||||||
@ -190,7 +189,7 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try healing now, expect to receive errFileNotFound.
|
// Try healing now, expect to receive errFileNotFound.
|
||||||
_, err = objLayer.HealObject(context.Background(), bucket, object, madmin.HealOpts{DryRun: false, Remove: true, ScanMode: madmin.HealDeepScan})
|
_, err = objLayer.HealObject(GlobalContext, bucket, object, madmin.HealOpts{DryRun: false, Remove: true, ScanMode: madmin.HealDeepScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(ObjectNotFound); !ok {
|
if _, ok := err.(ObjectNotFound); !ok {
|
||||||
t.Errorf("Expect %v but received %v", ObjectNotFound{Bucket: bucket, Object: object}, err)
|
t.Errorf("Expect %v but received %v", ObjectNotFound{Bucket: bucket, Object: object}, err)
|
||||||
@ -198,7 +197,7 @@ func TestHealObjectCorrupted(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// since majority of xl.jsons are not available, object should be successfully deleted.
|
// since majority of xl.jsons are not available, object should be successfully deleted.
|
||||||
_, err = objLayer.GetObjectInfo(context.Background(), bucket, object, ObjectOptions{})
|
_, err = objLayer.GetObjectInfo(GlobalContext, bucket, object, ObjectOptions{})
|
||||||
if _, ok := err.(ObjectNotFound); !ok {
|
if _, ok := err.(ObjectNotFound); !ok {
|
||||||
t.Errorf("Expect %v but received %v", ObjectNotFound{Bucket: bucket, Object: object}, err)
|
t.Errorf("Expect %v but received %v", ObjectNotFound{Bucket: bucket, Object: object}, err)
|
||||||
}
|
}
|
||||||
@ -225,21 +224,21 @@ func TestHealObjectXL(t *testing.T) {
|
|||||||
data := bytes.Repeat([]byte("a"), 5*1024*1024)
|
data := bytes.Repeat([]byte("a"), 5*1024*1024)
|
||||||
var opts ObjectOptions
|
var opts ObjectOptions
|
||||||
|
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), bucket, "")
|
err = obj.MakeBucketWithLocation(GlobalContext, bucket, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to make a bucket - %v", err)
|
t.Fatalf("Failed to make a bucket - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an object with multiple parts uploaded in decreasing
|
// Create an object with multiple parts uploaded in decreasing
|
||||||
// part number.
|
// part number.
|
||||||
uploadID, err := obj.NewMultipartUpload(context.Background(), bucket, object, opts)
|
uploadID, err := obj.NewMultipartUpload(GlobalContext, bucket, object, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create a multipart upload - %v", err)
|
t.Fatalf("Failed to create a multipart upload - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var uploadedParts []CompletePart
|
var uploadedParts []CompletePart
|
||||||
for _, partID := range []int{2, 1} {
|
for _, partID := range []int{2, 1} {
|
||||||
pInfo, err1 := obj.PutObjectPart(context.Background(), bucket, object, uploadID, partID, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), opts)
|
pInfo, err1 := obj.PutObjectPart(GlobalContext, bucket, object, uploadID, partID, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), opts)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
t.Fatalf("Failed to upload a part - %v", err1)
|
t.Fatalf("Failed to upload a part - %v", err1)
|
||||||
}
|
}
|
||||||
@ -249,7 +248,7 @@ func TestHealObjectXL(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.CompleteMultipartUpload(context.Background(), bucket, object, uploadID, uploadedParts, ObjectOptions{})
|
_, err = obj.CompleteMultipartUpload(GlobalContext, bucket, object, uploadID, uploadedParts, ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to complete multipart upload - %v", err)
|
t.Fatalf("Failed to complete multipart upload - %v", err)
|
||||||
}
|
}
|
||||||
@ -263,7 +262,7 @@ func TestHealObjectXL(t *testing.T) {
|
|||||||
t.Fatalf("Failed to delete a file - %v", err)
|
t.Fatalf("Failed to delete a file - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
_, err = obj.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to heal object - %v", err)
|
t.Fatalf("Failed to heal object - %v", err)
|
||||||
}
|
}
|
||||||
@ -285,7 +284,7 @@ func TestHealObjectXL(t *testing.T) {
|
|||||||
z.zones[0].xlDisksMu.Unlock()
|
z.zones[0].xlDisksMu.Unlock()
|
||||||
|
|
||||||
// Try healing now, expect to receive errDiskNotFound.
|
// Try healing now, expect to receive errDiskNotFound.
|
||||||
_, err = obj.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealDeepScan})
|
_, err = obj.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealDeepScan})
|
||||||
// since majority of xl.jsons are not available, object quorum can't be read properly and error will be errXLReadQuorum
|
// since majority of xl.jsons are not available, object quorum can't be read properly and error will be errXLReadQuorum
|
||||||
if _, ok := err.(InsufficientReadQuorum); !ok {
|
if _, ok := err.(InsufficientReadQuorum); !ok {
|
||||||
t.Errorf("Expected %v but received %v", InsufficientReadQuorum{}, err)
|
t.Errorf("Expected %v but received %v", InsufficientReadQuorum{}, err)
|
||||||
@ -311,13 +310,13 @@ func TestHealEmptyDirectoryXL(t *testing.T) {
|
|||||||
object := "empty-dir/"
|
object := "empty-dir/"
|
||||||
var opts ObjectOptions
|
var opts ObjectOptions
|
||||||
|
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), bucket, "")
|
err = obj.MakeBucketWithLocation(GlobalContext, bucket, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to make a bucket - %v", err)
|
t.Fatalf("Failed to make a bucket - %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload an empty directory
|
// Upload an empty directory
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t,
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t,
|
||||||
bytes.NewReader([]byte{}), 0, "", ""), opts)
|
bytes.NewReader([]byte{}), 0, "", ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -333,7 +332,7 @@ func TestHealEmptyDirectoryXL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Heal the object
|
// Heal the object
|
||||||
hr, err := obj.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
hr, err := obj.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to heal object - %v", err)
|
t.Fatalf("Failed to heal object - %v", err)
|
||||||
}
|
}
|
||||||
@ -357,7 +356,7 @@ func TestHealEmptyDirectoryXL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Heal the same object again
|
// Heal the same object again
|
||||||
hr, err = obj.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
hr, err = obj.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to heal object - %v", err)
|
t.Fatalf("Failed to heal object - %v", err)
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func (c *ChecksumInfo) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !c.Algorithm.Available() {
|
if !c.Algorithm.Available() {
|
||||||
logger.LogIf(context.Background(), errBitrotHashAlgoInvalid)
|
logger.LogIf(GlobalContext, errBitrotHashAlgoInvalid)
|
||||||
return errBitrotHashAlgoInvalid
|
return errBitrotHashAlgoInvalid
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ func TestObjectToPartOffset(t *testing.T) {
|
|||||||
|
|
||||||
// Test them.
|
// Test them.
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
index, offset, err := xlMeta.ObjectToPartOffset(context.Background(), testCase.offset)
|
index, offset, err := xlMeta.ObjectToPartOffset(GlobalContext, testCase.offset)
|
||||||
if err != testCase.expectedErr {
|
if err != testCase.expectedErr {
|
||||||
t.Fatalf("%+v: expected = %s, got: %s", testCase, testCase.expectedErr, err)
|
t.Fatalf("%+v: expected = %s, got: %s", testCase, testCase.expectedErr, err)
|
||||||
}
|
}
|
||||||
@ -192,7 +191,7 @@ func TestPickValidXLMeta(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, test := range testCases {
|
for i, test := range testCases {
|
||||||
xlMeta, err := pickValidXLMeta(context.Background(), test.metaArr, test.modTime, len(test.metaArr)/2)
|
xlMeta, err := pickValidXLMeta(GlobalContext, test.metaArr, test.modTime, len(test.metaArr)/2)
|
||||||
if test.expectedErr != nil {
|
if test.expectedErr != nil {
|
||||||
if err.Error() != test.expectedErr.Error() {
|
if err.Error() != test.expectedErr.Error() {
|
||||||
t.Errorf("Test %d: Expected to fail with %v but received %v",
|
t.Errorf("Test %d: Expected to fail with %v but received %v",
|
||||||
|
@ -40,20 +40,20 @@ func TestXLCleanupStaleMultipartUploads(t *testing.T) {
|
|||||||
objectName := "object"
|
objectName := "object"
|
||||||
var opts ObjectOptions
|
var opts ObjectOptions
|
||||||
|
|
||||||
obj.MakeBucketWithLocation(context.Background(), bucketName, "")
|
obj.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
uploadID, err := obj.NewMultipartUpload(context.Background(), bucketName, objectName, opts)
|
uploadID, err := obj.NewMultipartUpload(GlobalContext, bucketName, objectName, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a context we can cancel.
|
// Create a context we can cancel.
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(GlobalContext)
|
||||||
|
|
||||||
var cleanupWg sync.WaitGroup
|
var cleanupWg sync.WaitGroup
|
||||||
cleanupWg.Add(1)
|
cleanupWg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer cleanupWg.Done()
|
defer cleanupWg.Done()
|
||||||
xl.cleanupStaleMultipartUploads(context.Background(), time.Millisecond, 0, ctx.Done())
|
xl.cleanupStaleMultipartUploads(GlobalContext, time.Millisecond, 0, ctx.Done())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for 100ms such that - we have given enough time for cleanup routine to kick in.
|
// Wait for 100ms such that - we have given enough time for cleanup routine to kick in.
|
||||||
@ -65,7 +65,7 @@ func TestXLCleanupStaleMultipartUploads(t *testing.T) {
|
|||||||
cleanupWg.Wait()
|
cleanupWg.Wait()
|
||||||
|
|
||||||
// Check if upload id was already purged.
|
// Check if upload id was already purged.
|
||||||
if err = obj.AbortMultipartUpload(context.Background(), bucketName, objectName, uploadID); err != nil {
|
if err = obj.AbortMultipartUpload(GlobalContext, bucketName, objectName, uploadID); err != nil {
|
||||||
if _, ok := err.(InvalidUploadID); !ok {
|
if _, ok := err.(InvalidUploadID); !ok {
|
||||||
t.Fatal("Unexpected err: ", err)
|
t.Fatal("Unexpected err: ", err)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
@ -46,23 +45,23 @@ func TestRepeatPutObjectPart(t *testing.T) {
|
|||||||
// cleaning up of temporary test directories
|
// cleaning up of temporary test directories
|
||||||
defer removeRoots(disks)
|
defer removeRoots(disks)
|
||||||
|
|
||||||
err = objLayer.MakeBucketWithLocation(context.Background(), "bucket1", "")
|
err = objLayer.MakeBucketWithLocation(GlobalContext, "bucket1", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadID, err := objLayer.NewMultipartUpload(context.Background(), "bucket1", "mpartObj1", opts)
|
uploadID, err := objLayer.NewMultipartUpload(GlobalContext, "bucket1", "mpartObj1", opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
fiveMBBytes := bytes.Repeat([]byte("a"), 5*humanize.MiByte)
|
fiveMBBytes := bytes.Repeat([]byte("a"), 5*humanize.MiByte)
|
||||||
md5Hex := getMD5Hash(fiveMBBytes)
|
md5Hex := getMD5Hash(fiveMBBytes)
|
||||||
_, err = objLayer.PutObjectPart(context.Background(), "bucket1", "mpartObj1", uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(fiveMBBytes), 5*humanize.MiByte, md5Hex, ""), opts)
|
_, err = objLayer.PutObjectPart(GlobalContext, "bucket1", "mpartObj1", uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(fiveMBBytes), 5*humanize.MiByte, md5Hex, ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// PutObjectPart should succeed even if part already exists. ref: https://github.com/minio/minio/issues/1930
|
// PutObjectPart should succeed even if part already exists. ref: https://github.com/minio/minio/issues/1930
|
||||||
_, err = objLayer.PutObjectPart(context.Background(), "bucket1", "mpartObj1", uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(fiveMBBytes), 5*humanize.MiByte, md5Hex, ""), opts)
|
_, err = objLayer.PutObjectPart(GlobalContext, "bucket1", "mpartObj1", uploadID, 1, mustGetPutObjReader(t, bytes.NewReader(fiveMBBytes), 5*humanize.MiByte, md5Hex, ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -90,18 +89,18 @@ func TestXLDeleteObjectBasic(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = xl.MakeBucketWithLocation(context.Background(), "bucket", "")
|
err = xl.MakeBucketWithLocation(GlobalContext, "bucket", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create object "dir/obj" under bucket "bucket" for Test 7 to pass
|
// Create object "dir/obj" under bucket "bucket" for Test 7 to pass
|
||||||
_, err = xl.PutObject(context.Background(), "bucket", "dir/obj", mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
_, err = xl.PutObject(GlobalContext, "bucket", "dir/obj", mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("XL Object upload failed: <ERROR> %s", err)
|
t.Fatalf("XL Object upload failed: <ERROR> %s", err)
|
||||||
}
|
}
|
||||||
for i, test := range testCases {
|
for i, test := range testCases {
|
||||||
actualErr := xl.DeleteObject(context.Background(), test.bucket, test.object)
|
actualErr := xl.DeleteObject(GlobalContext, test.bucket, test.object)
|
||||||
if test.expectedErr != nil && actualErr != test.expectedErr {
|
if test.expectedErr != nil && actualErr != test.expectedErr {
|
||||||
t.Errorf("Test %d: Expected to fail with %s, but failed with %s", i+1, test.expectedErr, actualErr)
|
t.Errorf("Test %d: Expected to fail with %s, but failed with %s", i+1, test.expectedErr, actualErr)
|
||||||
}
|
}
|
||||||
@ -145,13 +144,13 @@ func TestXLDeleteObjectsXLSet(t *testing.T) {
|
|||||||
{bucketName, "obj_4"},
|
{bucketName, "obj_4"},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := xlSets.MakeBucketWithLocation(context.Background(), bucketName, "")
|
err := xlSets.MakeBucketWithLocation(GlobalContext, bucketName, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
_, err = xlSets.PutObject(context.Background(), testCase.bucket, testCase.object,
|
_, err = xlSets.PutObject(GlobalContext, testCase.bucket, testCase.object,
|
||||||
mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("XL Object upload failed: <ERROR> %s", err)
|
t.Fatalf("XL Object upload failed: <ERROR> %s", err)
|
||||||
@ -167,7 +166,7 @@ func TestXLDeleteObjectsXLSet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
objectNames := toObjectNames(testCases)
|
objectNames := toObjectNames(testCases)
|
||||||
delErrs, err := xlSets.DeleteObjects(context.Background(), bucketName, objectNames)
|
delErrs, err := xlSets.DeleteObjects(GlobalContext, bucketName, objectNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to call DeleteObjects with the error: `%v`", err)
|
t.Errorf("Failed to call DeleteObjects with the error: `%v`", err)
|
||||||
}
|
}
|
||||||
@ -179,7 +178,7 @@ func TestXLDeleteObjectsXLSet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
_, statErr := xlSets.GetObjectInfo(context.Background(), test.bucket, test.object, ObjectOptions{})
|
_, statErr := xlSets.GetObjectInfo(GlobalContext, test.bucket, test.object, ObjectOptions{})
|
||||||
switch statErr.(type) {
|
switch statErr.(type) {
|
||||||
case ObjectNotFound:
|
case ObjectNotFound:
|
||||||
default:
|
default:
|
||||||
@ -201,7 +200,7 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
|
|||||||
xl := z.zones[0].sets[0]
|
xl := z.zones[0].sets[0]
|
||||||
|
|
||||||
// Create "bucket"
|
// Create "bucket"
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), "bucket", "")
|
err = obj.MakeBucketWithLocation(GlobalContext, "bucket", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -210,7 +209,7 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
|
|||||||
object := "object"
|
object := "object"
|
||||||
opts := ObjectOptions{}
|
opts := ObjectOptions{}
|
||||||
// Create object "obj" under bucket "bucket".
|
// Create object "obj" under bucket "bucket".
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -225,13 +224,13 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
|
|||||||
return xlDisks
|
return xlDisks
|
||||||
}
|
}
|
||||||
z.zones[0].xlDisksMu.Unlock()
|
z.zones[0].xlDisksMu.Unlock()
|
||||||
err = obj.DeleteObject(context.Background(), bucket, object)
|
err = obj.DeleteObject(GlobalContext, bucket, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create "obj" under "bucket".
|
// Create "obj" under "bucket".
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -245,7 +244,7 @@ func TestXLDeleteObjectDiskNotFound(t *testing.T) {
|
|||||||
return xlDisks
|
return xlDisks
|
||||||
}
|
}
|
||||||
z.zones[0].xlDisksMu.Unlock()
|
z.zones[0].xlDisksMu.Unlock()
|
||||||
err = obj.DeleteObject(context.Background(), bucket, object)
|
err = obj.DeleteObject(GlobalContext, bucket, object)
|
||||||
// since majority of disks are not available, metaquorum is not achieved and hence errXLReadQuorum error
|
// since majority of disks are not available, metaquorum is not achieved and hence errXLReadQuorum error
|
||||||
if err != toObjectErr(errXLReadQuorum, bucket, object) {
|
if err != toObjectErr(errXLReadQuorum, bucket, object) {
|
||||||
t.Errorf("Expected deleteObject to fail with %v, but failed with %v", toObjectErr(errXLReadQuorum, bucket, object), err)
|
t.Errorf("Expected deleteObject to fail with %v, but failed with %v", toObjectErr(errXLReadQuorum, bucket, object), err)
|
||||||
@ -265,7 +264,7 @@ func TestGetObjectNoQuorum(t *testing.T) {
|
|||||||
xl := z.zones[0].sets[0]
|
xl := z.zones[0].sets[0]
|
||||||
|
|
||||||
// Create "bucket"
|
// Create "bucket"
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), "bucket", "")
|
err = obj.MakeBucketWithLocation(GlobalContext, "bucket", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -274,7 +273,7 @@ func TestGetObjectNoQuorum(t *testing.T) {
|
|||||||
object := "object"
|
object := "object"
|
||||||
opts := ObjectOptions{}
|
opts := ObjectOptions{}
|
||||||
// Create "object" under "bucket".
|
// Create "object" under "bucket".
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -303,7 +302,7 @@ func TestGetObjectNoQuorum(t *testing.T) {
|
|||||||
}
|
}
|
||||||
z.zones[0].xlDisksMu.Unlock()
|
z.zones[0].xlDisksMu.Unlock()
|
||||||
// Fetch object from store.
|
// Fetch object from store.
|
||||||
err = xl.GetObject(context.Background(), bucket, object, 0, int64(len("abcd")), ioutil.Discard, "", opts)
|
err = xl.GetObject(GlobalContext, bucket, object, 0, int64(len("abcd")), ioutil.Discard, "", opts)
|
||||||
if err != toObjectErr(errXLReadQuorum, bucket, object) {
|
if err != toObjectErr(errXLReadQuorum, bucket, object) {
|
||||||
t.Errorf("Expected putObject to fail with %v, but failed with %v", toObjectErr(errXLWriteQuorum, bucket, object), err)
|
t.Errorf("Expected putObject to fail with %v, but failed with %v", toObjectErr(errXLWriteQuorum, bucket, object), err)
|
||||||
}
|
}
|
||||||
@ -324,7 +323,7 @@ func TestPutObjectNoQuorum(t *testing.T) {
|
|||||||
xl := z.zones[0].sets[0]
|
xl := z.zones[0].sets[0]
|
||||||
|
|
||||||
// Create "bucket"
|
// Create "bucket"
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), "bucket", "")
|
err = obj.MakeBucketWithLocation(GlobalContext, "bucket", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -333,7 +332,7 @@ func TestPutObjectNoQuorum(t *testing.T) {
|
|||||||
object := "object"
|
object := "object"
|
||||||
opts := ObjectOptions{}
|
opts := ObjectOptions{}
|
||||||
// Create "object" under "bucket".
|
// Create "object" under "bucket".
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -362,7 +361,7 @@ func TestPutObjectNoQuorum(t *testing.T) {
|
|||||||
}
|
}
|
||||||
z.zones[0].xlDisksMu.Unlock()
|
z.zones[0].xlDisksMu.Unlock()
|
||||||
// Upload new content to same object "object"
|
// Upload new content to same object "object"
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader([]byte("abcd")), int64(len("abcd")), "", ""), opts)
|
||||||
if err != toObjectErr(errXLWriteQuorum, bucket, object) {
|
if err != toObjectErr(errXLWriteQuorum, bucket, object) {
|
||||||
t.Errorf("Expected putObject to fail with %v, but failed with %v", toObjectErr(errXLWriteQuorum, bucket, object), err)
|
t.Errorf("Expected putObject to fail with %v, but failed with %v", toObjectErr(errXLWriteQuorum, bucket, object), err)
|
||||||
}
|
}
|
||||||
@ -381,7 +380,7 @@ func TestHealing(t *testing.T) {
|
|||||||
xl := z.zones[0].sets[0]
|
xl := z.zones[0].sets[0]
|
||||||
|
|
||||||
// Create "bucket"
|
// Create "bucket"
|
||||||
err = obj.MakeBucketWithLocation(context.Background(), "bucket", "")
|
err = obj.MakeBucketWithLocation(GlobalContext, "bucket", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -396,13 +395,13 @@ func TestHealing(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object, mustGetPutObjReader(t, bytes.NewReader(data), length, "", ""), ObjectOptions{})
|
_, err = obj.PutObject(GlobalContext, bucket, object, mustGetPutObjReader(t, bytes.NewReader(data), length, "", ""), ObjectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
disk := xl.getDisks()[0]
|
disk := xl.getDisks()[0]
|
||||||
xlMetaPreHeal, err := readXLMeta(context.Background(), disk, bucket, object)
|
xlMetaPreHeal, err := readXLMeta(GlobalContext, disk, bucket, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -414,12 +413,12 @@ func TestHealing(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = xl.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
_, err = xl.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealNormalScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
xlMetaPostHeal, err := readXLMeta(context.Background(), disk, bucket, object)
|
xlMetaPostHeal, err := readXLMeta(GlobalContext, disk, bucket, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -438,17 +437,17 @@ func TestHealing(t *testing.T) {
|
|||||||
// gone down when an object was replaced by a new object.
|
// gone down when an object was replaced by a new object.
|
||||||
xlMetaOutDated := xlMetaPreHeal
|
xlMetaOutDated := xlMetaPreHeal
|
||||||
xlMetaOutDated.Stat.ModTime = time.Now()
|
xlMetaOutDated.Stat.ModTime = time.Now()
|
||||||
err = writeXLMetadata(context.Background(), disk, bucket, object, xlMetaOutDated)
|
err = writeXLMetadata(GlobalContext, disk, bucket, object, xlMetaOutDated)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = xl.HealObject(context.Background(), bucket, object, madmin.HealOpts{ScanMode: madmin.HealDeepScan})
|
_, err = xl.HealObject(GlobalContext, bucket, object, madmin.HealOpts{ScanMode: madmin.HealDeepScan})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
xlMetaPostHeal, err = readXLMeta(context.Background(), disk, bucket, object)
|
xlMetaPostHeal, err = readXLMeta(GlobalContext, disk, bucket, object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -465,7 +464,7 @@ func TestHealing(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// This would create the bucket.
|
// This would create the bucket.
|
||||||
_, err = xl.HealBucket(context.Background(), bucket, false, false)
|
_, err = xl.HealBucket(GlobalContext, bucket, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -492,41 +491,41 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
|||||||
xl := z.zones[0].sets[0]
|
xl := z.zones[0].sets[0]
|
||||||
xlDisks := xl.getDisks()
|
xlDisks := xl.getDisks()
|
||||||
|
|
||||||
err := obj.MakeBucketWithLocation(context.Background(), bucket, globalMinioDefaultRegion)
|
err := obj.MakeBucketWithLocation(GlobalContext, bucket, globalMinioDefaultRegion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to make a bucket %v", err)
|
t.Fatalf("Failed to make a bucket %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object for test case 1 - No StorageClass defined, no MetaData in PutObject
|
// Object for test case 1 - No StorageClass defined, no MetaData in PutObject
|
||||||
object1 := "object1"
|
object1 := "object1"
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object1, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), opts)
|
_, err = obj.PutObject(GlobalContext, bucket, object1, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts1, errs1 := readAllXLMetadata(context.Background(), xlDisks, bucket, object1)
|
parts1, errs1 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object1)
|
||||||
|
|
||||||
// Object for test case 2 - No StorageClass defined, MetaData in PutObject requesting RRS Class
|
// Object for test case 2 - No StorageClass defined, MetaData in PutObject requesting RRS Class
|
||||||
object2 := "object2"
|
object2 := "object2"
|
||||||
metadata2 := make(map[string]string)
|
metadata2 := make(map[string]string)
|
||||||
metadata2["x-amz-storage-class"] = storageclass.RRS
|
metadata2["x-amz-storage-class"] = storageclass.RRS
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object2, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata2})
|
_, err = obj.PutObject(GlobalContext, bucket, object2, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata2})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts2, errs2 := readAllXLMetadata(context.Background(), xlDisks, bucket, object2)
|
parts2, errs2 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object2)
|
||||||
|
|
||||||
// Object for test case 3 - No StorageClass defined, MetaData in PutObject requesting Standard Storage Class
|
// Object for test case 3 - No StorageClass defined, MetaData in PutObject requesting Standard Storage Class
|
||||||
object3 := "object3"
|
object3 := "object3"
|
||||||
metadata3 := make(map[string]string)
|
metadata3 := make(map[string]string)
|
||||||
metadata3["x-amz-storage-class"] = storageclass.STANDARD
|
metadata3["x-amz-storage-class"] = storageclass.STANDARD
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object3, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata3})
|
_, err = obj.PutObject(GlobalContext, bucket, object3, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata3})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts3, errs3 := readAllXLMetadata(context.Background(), xlDisks, bucket, object3)
|
parts3, errs3 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object3)
|
||||||
|
|
||||||
// Object for test case 4 - Standard StorageClass defined as Parity 6, MetaData in PutObject requesting Standard Storage Class
|
// Object for test case 4 - Standard StorageClass defined as Parity 6, MetaData in PutObject requesting Standard Storage Class
|
||||||
object4 := "object4"
|
object4 := "object4"
|
||||||
@ -538,12 +537,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object4, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata4})
|
_, err = obj.PutObject(GlobalContext, bucket, object4, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata4})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts4, errs4 := readAllXLMetadata(context.Background(), xlDisks, bucket, object4)
|
parts4, errs4 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object4)
|
||||||
|
|
||||||
// Object for test case 5 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting RRS Class
|
// Object for test case 5 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting RRS Class
|
||||||
// Reset global storage class flags
|
// Reset global storage class flags
|
||||||
@ -556,12 +555,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object5, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata5})
|
_, err = obj.PutObject(GlobalContext, bucket, object5, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata5})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts5, errs5 := readAllXLMetadata(context.Background(), xlDisks, bucket, object5)
|
parts5, errs5 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object5)
|
||||||
|
|
||||||
// Object for test case 6 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting Standard Storage Class
|
// Object for test case 6 - RRS StorageClass defined as Parity 2, MetaData in PutObject requesting Standard Storage Class
|
||||||
object6 := "object6"
|
object6 := "object6"
|
||||||
@ -573,12 +572,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object6, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata6})
|
_, err = obj.PutObject(GlobalContext, bucket, object6, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata6})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts6, errs6 := readAllXLMetadata(context.Background(), xlDisks, bucket, object6)
|
parts6, errs6 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object6)
|
||||||
|
|
||||||
// Object for test case 7 - Standard StorageClass defined as Parity 5, MetaData in PutObject requesting RRS Class
|
// Object for test case 7 - Standard StorageClass defined as Parity 5, MetaData in PutObject requesting RRS Class
|
||||||
// Reset global storage class flags
|
// Reset global storage class flags
|
||||||
@ -591,12 +590,12 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = obj.PutObject(context.Background(), bucket, object7, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata7})
|
_, err = obj.PutObject(GlobalContext, bucket, object7, mustGetPutObjReader(t, bytes.NewReader(data), int64(len(data)), "", ""), ObjectOptions{UserDefined: metadata7})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to putObject %v", err)
|
t.Fatalf("Failed to putObject %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parts7, errs7 := readAllXLMetadata(context.Background(), xlDisks, bucket, object7)
|
parts7, errs7 := readAllXLMetadata(GlobalContext, xlDisks, bucket, object7)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
parts []xlMetaV1
|
parts []xlMetaV1
|
||||||
@ -614,7 +613,7 @@ func testObjectQuorumFromMeta(obj ObjectLayer, instanceType string, dirs []strin
|
|||||||
{parts7, errs7, 14, 15, nil},
|
{parts7, errs7, 14, 15, nil},
|
||||||
}
|
}
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
actualReadQuorum, actualWriteQuorum, err := objectQuorumFromMeta(context.Background(), *xl, tt.parts, tt.errs)
|
actualReadQuorum, actualWriteQuorum, err := objectQuorumFromMeta(GlobalContext, *xl, tt.parts, tt.errs)
|
||||||
if tt.expectedError != nil && err == nil {
|
if tt.expectedError != nil && err == nil {
|
||||||
t.Errorf("Test %d, Expected %s, got %s", i+1, tt.expectedError, err)
|
t.Errorf("Test %d, Expected %s, got %s", i+1, tt.expectedError, err)
|
||||||
return
|
return
|
||||||
|
@ -195,7 +195,7 @@ func shuffleDisks(disks []StorageAPI, distribution []int) (shuffledDisks []Stora
|
|||||||
// the corresponding error in errs slice is not nil
|
// the corresponding error in errs slice is not nil
|
||||||
func evalDisks(disks []StorageAPI, errs []error) []StorageAPI {
|
func evalDisks(disks []StorageAPI, errs []error) []StorageAPI {
|
||||||
if len(errs) != len(disks) {
|
if len(errs) != len(disks) {
|
||||||
logger.LogIf(context.Background(), errors.New("unexpected disks/errors slice length"))
|
logger.LogIf(GlobalContext, errors.New("unexpected disks/errors slice length"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
newDisks := make([]StorageAPI, len(disks))
|
newDisks := make([]StorageAPI, len(disks))
|
||||||
|
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -90,11 +89,11 @@ func TestReduceErrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Validates list of all the testcases for returning valid errors.
|
// Validates list of all the testcases for returning valid errors.
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
gotErr := reduceReadQuorumErrs(context.Background(), testCase.errs, testCase.ignoredErrs, 5)
|
gotErr := reduceReadQuorumErrs(GlobalContext, testCase.errs, testCase.ignoredErrs, 5)
|
||||||
if gotErr != testCase.err {
|
if gotErr != testCase.err {
|
||||||
t.Errorf("Test %d : expected %s, got %s", i+1, testCase.err, gotErr)
|
t.Errorf("Test %d : expected %s, got %s", i+1, testCase.err, gotErr)
|
||||||
}
|
}
|
||||||
gotNewErr := reduceWriteQuorumErrs(context.Background(), testCase.errs, testCase.ignoredErrs, 6)
|
gotNewErr := reduceWriteQuorumErrs(GlobalContext, testCase.errs, testCase.ignoredErrs, 6)
|
||||||
if gotNewErr != errXLWriteQuorum {
|
if gotNewErr != errXLWriteQuorum {
|
||||||
t.Errorf("Test %d : expected %s, got %s", i+1, errXLWriteQuorum, gotErr)
|
t.Errorf("Test %d : expected %s, got %s", i+1, errXLWriteQuorum, gotErr)
|
||||||
}
|
}
|
||||||
@ -302,7 +301,7 @@ func TestGetXLMetaV1Jsoniter1(t *testing.T) {
|
|||||||
t.Errorf("Unmarshalling failed: %v", err)
|
t.Errorf("Unmarshalling failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
jsoniterXLMeta, err := xlMetaV1UnmarshalJSON(context.Background(), xlMetaJSON)
|
jsoniterXLMeta, err := xlMetaV1UnmarshalJSON(GlobalContext, xlMetaJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("jsoniter parsing of XLMeta failed: %v", err)
|
t.Errorf("jsoniter parsing of XLMeta failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -319,7 +318,7 @@ func TestGetXLMetaV1Jsoniter10(t *testing.T) {
|
|||||||
if err := json.Unmarshal(xlMetaJSON, &unMarshalXLMeta); err != nil {
|
if err := json.Unmarshal(xlMetaJSON, &unMarshalXLMeta); err != nil {
|
||||||
t.Errorf("Unmarshalling failed: %v", err)
|
t.Errorf("Unmarshalling failed: %v", err)
|
||||||
}
|
}
|
||||||
jsoniterXLMeta, err := xlMetaV1UnmarshalJSON(context.Background(), xlMetaJSON)
|
jsoniterXLMeta, err := xlMetaV1UnmarshalJSON(GlobalContext, xlMetaJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("jsoniter parsing of XLMeta failed: %v", err)
|
t.Errorf("jsoniter parsing of XLMeta failed: %v", err)
|
||||||
}
|
}
|
||||||
@ -349,7 +348,7 @@ func TestGetPartSizeFromIdx(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
s, err := calculatePartSizeFromIdx(context.Background(), testCase.totalSize, testCase.partSize, testCase.partIndex)
|
s, err := calculatePartSizeFromIdx(GlobalContext, testCase.totalSize, testCase.partSize, testCase.partIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Test %d: Expected to pass but failed. %s", i+1, err)
|
t.Errorf("Test %d: Expected to pass but failed. %s", i+1, err)
|
||||||
}
|
}
|
||||||
@ -373,7 +372,7 @@ func TestGetPartSizeFromIdx(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, testCaseFailure := range testCasesFailure {
|
for i, testCaseFailure := range testCasesFailure {
|
||||||
_, err := calculatePartSizeFromIdx(context.Background(), testCaseFailure.totalSize, testCaseFailure.partSize, testCaseFailure.partIndex)
|
_, err := calculatePartSizeFromIdx(GlobalContext, testCaseFailure.totalSize, testCaseFailure.partSize, testCaseFailure.partIndex)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("Test %d: Expected to failed but passed. %s", i+1, err)
|
t.Errorf("Test %d: Expected to failed but passed. %s", i+1, err)
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ func getDisksInfo(disks []StorageAPI, endpoints Endpoints) (disksInfo []DiskInfo
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("disk", disks[index].String())
|
reqInfo := (&logger.ReqInfo{}).AppendTags("disk", disks[index].String())
|
||||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
}
|
}
|
||||||
disksInfo[index] = info
|
disksInfo[index] = info
|
||||||
|
@ -80,7 +80,7 @@ func newXLZones(endpointZones EndpointZones) (ObjectLayer, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !z.SingleZone() {
|
if !z.SingleZone() {
|
||||||
z.quickHealBuckets(context.Background())
|
z.quickHealBuckets(GlobalContext)
|
||||||
}
|
}
|
||||||
return z, nil
|
return z, nil
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ func undoMakeBucketZones(bucket string, zones []*xlSets, errs []error) {
|
|||||||
index := index
|
index := index
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
if errs[index] == nil {
|
if errs[index] == nil {
|
||||||
return zones[index].DeleteBucket(context.Background(), bucket, false)
|
return zones[index].DeleteBucket(GlobalContext, bucket, false)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, index)
|
}, index)
|
||||||
@ -1286,7 +1286,7 @@ func undoDeleteBucketZones(bucket string, zones []*xlSets, errs []error) {
|
|||||||
index := index
|
index := index
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
if errs[index] == nil {
|
if errs[index] == nil {
|
||||||
return zones[index].MakeBucketWithLocation(context.Background(), bucket, "")
|
return zones[index].MakeBucketWithLocation(GlobalContext, bucket, "")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, index)
|
}, index)
|
||||||
|
Loading…
Reference in New Issue
Block a user