forked from TrueCloudLab/frostfs-s3-gw
Fixes for S3 API router
This commit is contained in:
parent
48d8138474
commit
45d31752a9
2 changed files with 27 additions and 5 deletions
|
@ -4,9 +4,11 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
minio "github.com/minio/minio/legacy"
|
minio "github.com/minio/minio/legacy"
|
||||||
|
"github.com/minio/minio/legacy/config"
|
||||||
"github.com/minio/minio/neofs/layer"
|
"github.com/minio/minio/neofs/layer"
|
||||||
"github.com/minio/minio/neofs/pool"
|
"github.com/minio/minio/neofs/pool"
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
|
@ -106,9 +108,19 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Info("credentials",
|
{ // Temporary solution, to resolve problems with MinIO GW access/secret keys:
|
||||||
zap.String("AccessKey", uid.String()),
|
if err = os.Setenv(config.EnvAccessKey, uid.String()); err != nil {
|
||||||
zap.String("SecretKey", wif))
|
l.Fatal("could not set "+config.EnvAccessKey,
|
||||||
|
zap.Error(err))
|
||||||
|
} else if err = os.Setenv(config.EnvSecretKey, wif); err != nil {
|
||||||
|
l.Fatal("could not set "+config.EnvSecretKey,
|
||||||
|
zap.Error(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
l.Info("used credentials",
|
||||||
|
zap.String("AccessKey", uid.String()),
|
||||||
|
zap.String("SecretKey", wif))
|
||||||
|
}
|
||||||
|
|
||||||
if obj, err = layer.NewLayer(cli, auth.Credentials{AccessKey: uid.String(), SecretKey: wif}); err != nil {
|
if obj, err = layer.NewLayer(cli, auth.Credentials{AccessKey: uid.String(), SecretKey: wif}); err != nil {
|
||||||
l.Fatal("could not prepare ObjectLayer",
|
l.Fatal("could not prepare ObjectLayer",
|
||||||
|
@ -167,7 +179,7 @@ func (a *App) Server(ctx context.Context) {
|
||||||
attachProfiler(router, a.cfg, a.log)
|
attachProfiler(router, a.cfg, a.log)
|
||||||
|
|
||||||
// Attach S3 API:
|
// Attach S3 API:
|
||||||
minio.AttachS3API(router, a.obj)
|
minio.AttachS3API(router, a.obj, a.log)
|
||||||
|
|
||||||
// Use mux.Router as http.Handler
|
// Use mux.Router as http.Handler
|
||||||
srv.Handler = router
|
srv.Handler = router
|
||||||
|
|
|
@ -2,9 +2,10 @@ package legacy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AttachS3API(r *mux.Router, obj ObjectLayer) {
|
func AttachS3API(r *mux.Router, obj ObjectLayer, l *zap.Logger) {
|
||||||
// Add healthcheck router
|
// Add healthcheck router
|
||||||
registerHealthCheckRouter(r)
|
registerHealthCheckRouter(r)
|
||||||
|
|
||||||
|
@ -34,4 +35,13 @@ func AttachS3API(r *mux.Router, obj ObjectLayer) {
|
||||||
globalObjLayerMutex.Lock()
|
globalObjLayerMutex.Lock()
|
||||||
globalSafeMode = false
|
globalSafeMode = false
|
||||||
globalObjLayerMutex.Unlock()
|
globalObjLayerMutex.Unlock()
|
||||||
|
|
||||||
|
// Handle gateway specific env
|
||||||
|
gatewayHandleEnvVars()
|
||||||
|
|
||||||
|
// Set system resources to maximum.
|
||||||
|
if err := setMaxResources(); err != nil {
|
||||||
|
l.Warn("could not set max resources",
|
||||||
|
zap.Error(err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue