diff --git a/cmd/common-main.go b/cmd/common-main.go index 9fb2fbd00..86baf12a5 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -38,6 +38,25 @@ import ( xnet "github.com/minio/minio/pkg/net" ) +func verifyObjectLayerFeatures(name string, objAPI ObjectLayer) { + if (globalAutoEncryption || GlobalKMS != nil) && !objAPI.IsEncryptionSupported() { + logger.Fatal(errInvalidArgument, + "Encryption support is requested but '%s' does not support encryption", name) + } + + if strings.HasPrefix(name, "gateway") { + if GlobalGatewaySSE.IsSet() && GlobalKMS == nil { + uiErr := uiErrInvalidGWSSEEnvValue(nil).Msg("MINIO_GATEWAY_SSE set but KMS is not configured") + logger.Fatal(uiErr, "Unable to start gateway with SSE") + } + } + + if globalIsCompressionEnabled && !objAPI.IsCompressionSupported() { + logger.Fatal(errInvalidArgument, + "Compression support is requested but '%s' does not support compression", name) + } +} + // Check for updates and print a notification message func checkUpdate(mode string) { // Its OK to ignore any errors during doUpdate() here. diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index c17dcd30d..dce7e46b4 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -278,23 +278,14 @@ func StartGateway(ctx *cli.Context, gw Gateway) { // Create new notification system. globalNotificationSys = NewNotificationSys(globalServerConfig, globalEndpoints) - if globalEtcdClient != nil && newObject.IsNotificationSupported() { + if enableConfigOps && newObject.IsNotificationSupported() { logger.LogIf(context.Background(), globalNotificationSys.Init(newObject)) } - // Encryption support checks in gateway mode. - { - - if (globalAutoEncryption || GlobalKMS != nil) && !newObject.IsEncryptionSupported() { - logger.Fatal(errInvalidArgument, - "Encryption support is requested but (%s) gateway does not support encryption", gw.Name()) - } - - if GlobalGatewaySSE.IsSet() && GlobalKMS == nil { - logger.Fatal(uiErrInvalidGWSSEEnvValue(nil).Msg("MINIO_GATEWAY_SSE set but KMS is not configured"), - "Unable to start gateway with SSE") - } - } + // Verify if object layer supports + // - encryption + // - compression + verifyObjectLayerFeatures("gateway "+gatewayName, newObject) // Once endpoints are finalized, initialize the new object api. globalObjLayerMutex.Lock() diff --git a/cmd/server-main.go b/cmd/server-main.go index 7d8da3e79..b0b455453 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -19,7 +19,6 @@ package cmd import ( "context" "encoding/gob" - "errors" "fmt" "net/http" "os" @@ -380,9 +379,11 @@ func serverMain(ctx *cli.Context) { if err = globalNotificationSys.Init(newObject); err != nil { logger.LogIf(context.Background(), err) } - if globalAutoEncryption && !newObject.IsEncryptionSupported() { - logger.Fatal(errors.New("Invalid KMS configuration"), "auto-encryption is enabled but server does not support encryption") - } + + // Verify if object layer supports + // - encryption + // - compression + verifyObjectLayerFeatures("server", newObject) if globalIsXL { initBackgroundHealing()