mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
parent
b91040f7fb
commit
5686a7e273
@ -41,7 +41,7 @@ type BucketMetadataSys struct {
|
|||||||
|
|
||||||
// Remove bucket metadata from memory.
|
// Remove bucket metadata from memory.
|
||||||
func (sys *BucketMetadataSys) Remove(bucket string) {
|
func (sys *BucketMetadataSys) Remove(bucket string) {
|
||||||
if globalIsGateway && globalGatewayName != "nas" {
|
if globalIsGateway {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sys.Lock()
|
sys.Lock()
|
||||||
@ -74,9 +74,12 @@ func (sys *BucketMetadataSys) Update(bucket string, configFile string, configDat
|
|||||||
return errServerNotInitialized
|
return errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
if globalIsGateway && globalGatewayName != "nas" {
|
if globalIsGateway {
|
||||||
// This code is needed only for gateway implementations.
|
// This code is needed only for gateway implementations.
|
||||||
if configFile == bucketPolicyConfig {
|
if configFile == bucketPolicyConfig {
|
||||||
|
if configData == nil {
|
||||||
|
return objAPI.DeleteBucketPolicy(GlobalContext, bucket)
|
||||||
|
}
|
||||||
config, err := policy.ParseConfig(bytes.NewReader(configData), bucket)
|
config, err := policy.ParseConfig(bytes.NewReader(configData), bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -195,6 +198,19 @@ func (sys *BucketMetadataSys) GetLifecycleConfig(bucket string) (*lifecycle.Life
|
|||||||
// GetNotificationConfig returns configured notification config
|
// GetNotificationConfig returns configured notification config
|
||||||
// The returned object may not be modified.
|
// The returned object may not be modified.
|
||||||
func (sys *BucketMetadataSys) GetNotificationConfig(bucket string) (*event.Config, error) {
|
func (sys *BucketMetadataSys) GetNotificationConfig(bucket string) (*event.Config, error) {
|
||||||
|
if globalIsGateway && globalGatewayName == "nas" {
|
||||||
|
// Only needed in case of NAS gateway.
|
||||||
|
objAPI := newObjectLayerWithoutSafeModeFn()
|
||||||
|
if objAPI == nil {
|
||||||
|
return nil, errServerNotInitialized
|
||||||
|
}
|
||||||
|
meta, err := loadBucketMetadata(GlobalContext, objAPI, bucket)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return meta.notificationConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
meta, err := sys.GetConfig(bucket)
|
meta, err := sys.GetConfig(bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -221,6 +237,14 @@ func (sys *BucketMetadataSys) GetSSEConfig(bucket string) (*bucketsse.BucketSSEC
|
|||||||
// GetPolicyConfig returns configured bucket policy
|
// GetPolicyConfig returns configured bucket policy
|
||||||
// The returned object may not be modified.
|
// The returned object may not be modified.
|
||||||
func (sys *BucketMetadataSys) GetPolicyConfig(bucket string) (*policy.Policy, error) {
|
func (sys *BucketMetadataSys) GetPolicyConfig(bucket string) (*policy.Policy, error) {
|
||||||
|
if globalIsGateway {
|
||||||
|
objAPI := newObjectLayerWithoutSafeModeFn()
|
||||||
|
if objAPI == nil {
|
||||||
|
return nil, errServerNotInitialized
|
||||||
|
}
|
||||||
|
return objAPI.GetBucketPolicy(GlobalContext, bucket)
|
||||||
|
}
|
||||||
|
|
||||||
meta, err := sys.GetConfig(bucket)
|
meta, err := sys.GetConfig(bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, errConfigNotFound) {
|
if errors.Is(err, errConfigNotFound) {
|
||||||
@ -244,7 +268,7 @@ func (sys *BucketMetadataSys) GetQuotaConfig(bucket string) (*madmin.BucketQuota
|
|||||||
return meta.quotaConfig, nil
|
return meta.quotaConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetConfig returns a specific configuration from the bucket metadata.
|
// GetConfig returns the current bucket metadata
|
||||||
// The returned object may not be modified.
|
// The returned object may not be modified.
|
||||||
func (sys *BucketMetadataSys) GetConfig(bucket string) (BucketMetadata, error) {
|
func (sys *BucketMetadataSys) GetConfig(bucket string) (BucketMetadata, error) {
|
||||||
objAPI := newObjectLayerWithoutSafeModeFn()
|
objAPI := newObjectLayerWithoutSafeModeFn()
|
||||||
@ -252,7 +276,7 @@ func (sys *BucketMetadataSys) GetConfig(bucket string) (BucketMetadata, error) {
|
|||||||
return newBucketMetadata(bucket), errServerNotInitialized
|
return newBucketMetadata(bucket), errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
if globalIsGateway && globalGatewayName != "nas" {
|
if globalIsGateway {
|
||||||
return newBucketMetadata(bucket), NotImplemented{}
|
return newBucketMetadata(bucket), NotImplemented{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,6 @@ type PolicySys struct{}
|
|||||||
|
|
||||||
// Get returns stored bucket policy
|
// Get returns stored bucket policy
|
||||||
func (sys *PolicySys) Get(bucket string) (*policy.Policy, error) {
|
func (sys *PolicySys) Get(bucket string) (*policy.Policy, error) {
|
||||||
if globalIsGateway {
|
|
||||||
objAPI := newObjectLayerFn()
|
|
||||||
if objAPI == nil {
|
|
||||||
return nil, errServerNotInitialized
|
|
||||||
}
|
|
||||||
return objAPI.GetBucketPolicy(GlobalContext, bucket)
|
|
||||||
}
|
|
||||||
return globalBucketMetadataSys.GetPolicyConfig(bucket)
|
return globalBucketMetadataSys.GetPolicyConfig(bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
cmd/fs-v1.go
39
cmd/fs-v1.go
@ -39,6 +39,7 @@ import (
|
|||||||
"github.com/minio/minio/cmd/config"
|
"github.com/minio/minio/cmd/config"
|
||||||
xhttp "github.com/minio/minio/cmd/http"
|
xhttp "github.com/minio/minio/cmd/http"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
|
"github.com/minio/minio/pkg/bucket/policy"
|
||||||
"github.com/minio/minio/pkg/color"
|
"github.com/minio/minio/pkg/color"
|
||||||
"github.com/minio/minio/pkg/lock"
|
"github.com/minio/minio/pkg/lock"
|
||||||
"github.com/minio/minio/pkg/madmin"
|
"github.com/minio/minio/pkg/madmin"
|
||||||
@ -361,6 +362,44 @@ func (fs *FSObjects) MakeBucketWithLocation(ctx context.Context, bucket, locatio
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBucketPolicy - only needed for FS in NAS mode
|
||||||
|
func (fs *FSObjects) GetBucketPolicy(ctx context.Context, bucket string) (*policy.Policy, error) {
|
||||||
|
meta, err := loadBucketMetadata(ctx, fs, bucket)
|
||||||
|
if err != nil {
|
||||||
|
return nil, BucketPolicyNotFound{Bucket: bucket}
|
||||||
|
}
|
||||||
|
if meta.policyConfig == nil {
|
||||||
|
return nil, BucketPolicyNotFound{Bucket: bucket}
|
||||||
|
}
|
||||||
|
return meta.policyConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBucketPolicy - only needed for FS in NAS mode
|
||||||
|
func (fs *FSObjects) SetBucketPolicy(ctx context.Context, bucket string, p *policy.Policy) error {
|
||||||
|
meta, err := loadBucketMetadata(ctx, fs, bucket)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
configData, err := json.Marshal(p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
meta.PolicyConfigJSON = configData
|
||||||
|
|
||||||
|
return meta.Save(ctx, fs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteBucketPolicy - only needed for FS in NAS mode
|
||||||
|
func (fs *FSObjects) DeleteBucketPolicy(ctx context.Context, bucket string) error {
|
||||||
|
meta, err := loadBucketMetadata(ctx, fs, bucket)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
meta.PolicyConfigJSON = nil
|
||||||
|
return meta.Save(ctx, fs)
|
||||||
|
}
|
||||||
|
|
||||||
// GetBucketInfo - fetch bucket metadata info.
|
// GetBucketInfo - fetch bucket metadata info.
|
||||||
func (fs *FSObjects) GetBucketInfo(ctx context.Context, bucket string) (bi BucketInfo, e error) {
|
func (fs *FSObjects) GetBucketInfo(ctx context.Context, bucket string) (bi BucketInfo, e error) {
|
||||||
atomic.AddInt64(&fs.activeIOCount, 1)
|
atomic.AddInt64(&fs.activeIOCount, 1)
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"github.com/minio/minio-go/v6/pkg/tags"
|
"github.com/minio/minio-go/v6/pkg/tags"
|
||||||
bucketsse "github.com/minio/minio/pkg/bucket/encryption"
|
bucketsse "github.com/minio/minio/pkg/bucket/encryption"
|
||||||
"github.com/minio/minio/pkg/bucket/lifecycle"
|
"github.com/minio/minio/pkg/bucket/lifecycle"
|
||||||
objectlock "github.com/minio/minio/pkg/bucket/object/lock"
|
|
||||||
"github.com/minio/minio/pkg/bucket/policy"
|
"github.com/minio/minio/pkg/bucket/policy"
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/madmin"
|
"github.com/minio/minio/pkg/madmin"
|
||||||
@ -205,35 +204,6 @@ func (a GatewayUnsupported) GetMetrics(ctx context.Context) (*Metrics, error) {
|
|||||||
return &Metrics{}, NotImplemented{}
|
return &Metrics{}, NotImplemented{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBucketTagging - not implemented
|
|
||||||
func (a GatewayUnsupported) SetBucketTagging(ctx context.Context, bucket string, t *tags.Tags) error {
|
|
||||||
logger.LogIf(ctx, NotImplemented{})
|
|
||||||
return NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetBucketObjectLockConfig - not implemented
|
|
||||||
func (a GatewayUnsupported) GetBucketObjectLockConfig(ctx context.Context, bucket string) (*objectlock.Config, error) {
|
|
||||||
logger.LogIf(ctx, NotImplemented{})
|
|
||||||
return nil, NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBucketObjectLockConfig - not implemented
|
|
||||||
func (a GatewayUnsupported) SetBucketObjectLockConfig(ctx context.Context, bucket string, _ *objectlock.Config) error {
|
|
||||||
logger.LogIf(ctx, NotImplemented{})
|
|
||||||
return NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetBucketTagging - not implemented
|
|
||||||
func (a GatewayUnsupported) GetBucketTagging(ctx context.Context, bucket string) (*tags.Tags, error) {
|
|
||||||
return nil, NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteBucketTagging - not implemented.
|
|
||||||
func (a GatewayUnsupported) DeleteBucketTagging(ctx context.Context, bucket string) error {
|
|
||||||
logger.LogIf(ctx, NotImplemented{})
|
|
||||||
return NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PutObjectTags - not implemented.
|
// PutObjectTags - not implemented.
|
||||||
func (a GatewayUnsupported) PutObjectTags(ctx context.Context, bucket, object string, tags string) error {
|
func (a GatewayUnsupported) PutObjectTags(ctx context.Context, bucket, object string, tags string) error {
|
||||||
logger.LogIf(ctx, NotImplemented{})
|
logger.LogIf(ctx, NotImplemented{})
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
objectlock "github.com/minio/minio/pkg/bucket/object/lock"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -122,16 +121,6 @@ type nasObjects struct {
|
|||||||
minio.ObjectLayer
|
minio.ObjectLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBucketObjectLockConfig - not implemented
|
|
||||||
func (n *nasObjects) GetBucketObjectLockConfig(ctx context.Context, bucket string) (*objectlock.Config, error) {
|
|
||||||
return nil, minio.NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBucketObjectLockConfig - not implemented
|
|
||||||
func (n *nasObjects) SetBucketObjectLockConfig(ctx context.Context, bucket string, _ *objectlock.Config) error {
|
|
||||||
return minio.NotImplemented{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsReady returns whether the layer is ready to take requests.
|
// IsReady returns whether the layer is ready to take requests.
|
||||||
func (n *nasObjects) IsReady(ctx context.Context) bool {
|
func (n *nasObjects) IsReady(ctx context.Context) bool {
|
||||||
si, _ := n.StorageInfo(ctx, false)
|
si, _ := n.StorageInfo(ctx, false)
|
||||||
|
@ -114,8 +114,7 @@ type ObjectLayer interface {
|
|||||||
IsNotificationSupported() bool
|
IsNotificationSupported() bool
|
||||||
IsListenBucketSupported() bool
|
IsListenBucketSupported() bool
|
||||||
IsEncryptionSupported() bool
|
IsEncryptionSupported() bool
|
||||||
|
IsTaggingSupported() bool
|
||||||
// Compression support check.
|
|
||||||
IsCompressionSupported() bool
|
IsCompressionSupported() bool
|
||||||
|
|
||||||
// Backend related metrics
|
// Backend related metrics
|
||||||
@ -124,9 +123,6 @@ type ObjectLayer interface {
|
|||||||
// Check Readiness
|
// Check Readiness
|
||||||
IsReady(ctx context.Context) bool
|
IsReady(ctx context.Context) bool
|
||||||
|
|
||||||
// Object Tagging Support check.
|
|
||||||
IsTaggingSupported() bool
|
|
||||||
|
|
||||||
// ObjectTagging operations
|
// ObjectTagging operations
|
||||||
PutObjectTags(context.Context, string, string, string) error
|
PutObjectTags(context.Context, string, string, string) error
|
||||||
GetObjectTags(context.Context, string, string) (*tags.Tags, error)
|
GetObjectTags(context.Context, string, string) (*tags.Tags, error)
|
||||||
|
@ -429,9 +429,7 @@ func serverMain(ctx *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set system resources to maximum.
|
// Set system resources to maximum.
|
||||||
if err = setMaxResources(); err != nil {
|
setMaxResources()
|
||||||
logger.Info("Unable to set system resources to maximum %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if globalIsXL {
|
if globalIsXL {
|
||||||
// Init global heal state
|
// Init global heal state
|
||||||
|
@ -18,13 +18,12 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
|
||||||
"crypto"
|
"crypto"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -409,19 +408,15 @@ const updateTimeout = 10 * time.Second
|
|||||||
|
|
||||||
func getUpdateTransport(timeout time.Duration) http.RoundTripper {
|
func getUpdateTransport(timeout time.Duration) http.RoundTripper {
|
||||||
var updateTransport http.RoundTripper = &http.Transport{
|
var updateTransport http.RoundTripper = &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
DialContext: xhttp.NewCustomDialContext(timeout, timeout),
|
||||||
dialer := &net.Dialer{
|
|
||||||
Timeout: timeout,
|
|
||||||
KeepAlive: timeout,
|
|
||||||
DualStack: true,
|
|
||||||
}
|
|
||||||
return dialer.DialContext(ctx, network, addr)
|
|
||||||
},
|
|
||||||
IdleConnTimeout: timeout,
|
IdleConnTimeout: timeout,
|
||||||
TLSHandshakeTimeout: timeout,
|
TLSHandshakeTimeout: timeout,
|
||||||
ExpectContinueTimeout: timeout,
|
ExpectContinueTimeout: timeout,
|
||||||
DisableCompression: true,
|
TLSClientConfig: &tls.Config{
|
||||||
|
RootCAs: globalRootCAs,
|
||||||
|
},
|
||||||
|
DisableCompression: true,
|
||||||
}
|
}
|
||||||
return updateTransport
|
return updateTransport
|
||||||
}
|
}
|
||||||
@ -502,7 +497,9 @@ func doUpdate(updateURL, sha256Hex, mode string) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clnt := &http.Client{Transport: getUpdateTransport(30 * time.Second)}
|
clnt := &http.Client{
|
||||||
|
Transport: getUpdateTransport(30 * time.Second),
|
||||||
|
}
|
||||||
req, err := http.NewRequest(http.MethodGet, updateURL, nil)
|
req, err := http.NewRequest(http.MethodGet, updateURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return AdminError{
|
return AdminError{
|
||||||
|
Loading…
Reference in New Issue
Block a user