Skip to content

Commit

Permalink
Upgrade the gateway to support more complete functionality (#4030)
Browse files Browse the repository at this point in the history
Use juicefs as an implementation of minio's ObjectLayer, running it as a
minio server rather than a minio gateway pattern

- [x] User Manage
  - [x] JuiceFS Backend
ETCD Backend: After discussion we decided not to support etcd because
minio/minio#17995 (comment)
- [x] Access Manage
  - [x] Bucket Policy
  - [x] Object Policy
- [x] Bucket Notification
  - [x] WebHooks
  - [x] Redis
  - [x] MySQL
  - [x] PostgreSQL
 - [x] Object Cache

close #3537
#3375
#3107








depend on juicedata/minio#47
  • Loading branch information
zhijian-pro authored Nov 21, 2023
1 parent 78ec032 commit 0e2c8a3
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 118 deletions.
68 changes: 29 additions & 39 deletions cmd/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (

mcli "github.com/minio/cli"
minio "github.com/minio/minio/cmd"
"github.com/minio/minio/pkg/auth"
)

func cmdGateway() *cli.Command {
Expand Down Expand Up @@ -74,6 +73,10 @@ func cmdGateway() *cli.Command {
Value: "022",
Usage: "umask for new files and directories in octal",
},
&cli.BoolFlag{
Name: "object-tag",
Usage: "enable object tagging api",
},
}

return &cli.Command{
Expand Down Expand Up @@ -114,10 +117,30 @@ func gateway(c *cli.Context) error {
logger.Fatalf("MINIO_ROOT_PASSWORD should be specified as an environment variable with at least 8 characters")
}

address := c.Args().Get(1)
gw = &GateWay{c}
metaAddr := c.Args().Get(0)
listenAddr := c.Args().Get(1)
conf, jfs := initForSvc(c, "s3gateway", metaAddr)

umask, err := strconv.ParseUint(c.String("umask"), 8, 16)
if err != nil {
logger.Fatalf("invalid umask %s: %s", c.String("umask"), err)
}

jfsGateway, err = jfsgateway.NewJFSGateway(
jfs,
conf,
&jfsgateway.Config{
MultiBucket: c.Bool("multi-buckets"),
KeepEtag: c.Bool("keep-etag"),
Umask: uint16(umask),
ObjTag: c.Bool("object-tag"),
},
)
if err != nil {
return err
}

args := []string{"gateway", "--address", address, "--anonymous"}
args := []string{"server", "--address", listenAddr, "--anonymous"}
if c.Bool("no-banner") {
args = append(args, "--quiet")
}
Expand Down Expand Up @@ -146,46 +169,13 @@ func gateway(c *cli.Context) error {
return app.Run(args)
}

var gw *GateWay
var jfsGateway minio.ObjectLayer

func gateway2(ctx *mcli.Context) error {
minio.StartGateway(ctx, gw)
minio.ServerMainForJFS(ctx, jfsGateway)
return nil
}

type GateWay struct {
ctx *cli.Context
}

func (g *GateWay) Name() string {
return "JuiceFS"
}

func (g *GateWay) Production() bool {
return true
}

func (g *GateWay) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
c := g.ctx
addr := c.Args().Get(0)
conf, jfs := initForSvc(c, "s3gateway", addr)

umask, err := strconv.ParseUint(c.String("umask"), 8, 16)
if err != nil {
logger.Fatalf("invalid umask %s: %s", c.String("umask"), err)
}

return jfsgateway.NewJFSGateway(
jfs,
conf,
&jfsgateway.Config{
MultiBucket: c.Bool("multi-buckets"),
KeepEtag: c.Bool("keep-etag"),
Umask: uint16(umask),
},
)
}

func initForSvc(c *cli.Context, mp string, metaUrl string) (*vfs.Config, *fs.FileSystem) {
removePassword(metaUrl)
metaConf := getMetaConf(c, mp, c.Bool("read-only"))
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func startGateway(t *testing.T) {
ResetHttp()

go func() {
if err := Main([]string{"", "gateway", gatewayMeta, gatewayAddr, "--multi-buckets", "--keep-etag", "--no-usage-report"}); err != nil {
if err := Main([]string{"", "gateway", gatewayMeta, gatewayAddr, "--multi-buckets", "--keep-etag", "--object-tag", "--no-usage-report"}); err != nil {
t.Errorf("gateway failed: %s", err)
}
}()
Expand Down
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
github.com/hungys/go-lz4 v0.0.0-20170805124057-19ff7f07f099
github.com/jackc/pgx/v5 v5.3.1
github.com/jcmturner/gokrb5/v8 v8.4.4
github.com/json-iterator/go v1.1.12
github.com/juicedata/godaemon v0.0.0-20210629045518-3da5144a127d
github.com/juicedata/gogfapi v0.0.0-20230626071140-fc28e5537825
github.com/juju/ratelimit v1.0.2
Expand All @@ -39,7 +40,7 @@ require (
github.com/mattn/go-sqlite3 v1.14.16
github.com/minio/cli v1.24.2
github.com/minio/minio v0.0.0-20210206053228-97fe57bba92c
github.com/minio/minio-go v6.0.14+incompatible
github.com/minio/minio-go/v7 v7.0.10
github.com/ncw/swift/v2 v2.0.1
github.com/pingcap/log v1.1.1-0.20221015072633-39906604fb81
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -71,7 +72,7 @@ require (
golang.org/x/crypto v0.14.0
golang.org/x/net v0.17.0
golang.org/x/oauth2 v0.7.0
golang.org/x/sync v0.1.0
golang.org/x/sync v0.2.0
golang.org/x/sys v0.13.0
golang.org/x/term v0.13.0
golang.org/x/text v0.13.0
Expand Down Expand Up @@ -129,7 +130,7 @@ require (
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.0.0 // indirect
Expand Down Expand Up @@ -161,9 +162,8 @@ require (
github.com/jcmturner/goidentity/v6 v6.0.1 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.13.4 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.3 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
Expand All @@ -174,9 +174,8 @@ require (
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.41 // indirect
github.com/minio/highwayhash v1.0.1 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/minio/md5-simd v1.1.1 // indirect
github.com/minio/minio-go/v7 v7.0.10 // indirect
github.com/minio/selfupdate v0.3.1 // indirect
github.com/minio/sha256-simd v0.1.1 // indirect
github.com/minio/simdjson-go v0.2.1 // indirect
Expand All @@ -198,7 +197,7 @@ require (
github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 // indirect
github.com/pingcap/kvproto v0.0.0-20221129023506-621ec37aac7a // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/pyroscope-io/godeltaprof v0.1.2 // indirect
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
Expand All @@ -220,7 +219,7 @@ require (
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tidwall/sjson v1.0.4 // indirect
github.com/tikv/pd/client v0.0.0-20221031025758-80f0d8ca4d07 // indirect
github.com/tinylib/msgp v1.1.3 // indirect
github.com/tinylib/msgp v1.1.6 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
Expand All @@ -233,7 +232,7 @@ require (
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220810155839-1856144b1d9c // indirect
Expand All @@ -245,7 +244,7 @@ require (
xorm.io/builder v0.3.7 // indirect
)

replace github.com/minio/minio v0.0.0-20210206053228-97fe57bba92c => github.com/juicedata/minio v0.0.0-20221113011458-8866d5c9df8c
replace github.com/minio/minio v0.0.0-20210206053228-97fe57bba92c => github.com/juicedata/minio v0.0.0-20231117063727-ebb12c63dc3d

replace github.com/hanwen/go-fuse/v2 v2.1.1-0.20210611132105-24a1dfe6b4f8 => github.com/juicedata/go-fuse/v2 v2.1.1-0.20230726081302-124dbfa991d7

Expand Down
Loading

0 comments on commit 0e2c8a3

Please sign in to comment.