diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..b9fae1d0 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,10 @@ +FROM alpine:3.10 + +COPY mc /usr/bin/ + +RUN \ + apk add --no-cache ca-certificates && \ + echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf \ + chmod +x /usr/bin/mc + +ENTRYPOINT ["mc"] diff --git a/Makefile b/Makefile index d2a0ccfd..43051175 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ GOOS := $(shell go env GOOS) BUILD_LDFLAGS := '$(LDFLAGS)' +VERSION ?= $(shell git describe --tags) +TAG ?= "minio/mc:$(VERSION)" + all: build checks: @@ -28,6 +31,9 @@ crosscompile: verifiers: getdeps vet fmt lint staticcheck spelling +docker: build + @docker build -t $(TAG) . -f Dockerfile.dev + vet: @echo "Running $@" @GO111MODULE=on go vet github.com/minio/mc/... diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 6d9f608a..fafa84e6 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -581,7 +581,6 @@ func (c *s3Client) Select(expression string, sse encrypt.ServerSide, selOpts Sel func (c *s3Client) watchOneBucket(bucket, prefix, suffix string, events []string, doneCh chan struct{}, eventChan chan EventInfo, errorChan chan *probe.Error) { // Start listening on all bucket events. eventsCh := c.api.ListenBucketNotification(bucket, prefix, suffix, events, doneCh) - for notificationInfo := range eventsCh { if notificationInfo.Err != nil { if nErr, ok := notificationInfo.Err.(minio.ErrorResponse); ok && nErr.Code == "APINotSupported" { @@ -601,7 +600,6 @@ func (c *s3Client) watchOneBucket(bucket, prefix, suffix string, events []string errorChan <- probe.NewError(e) continue } - u := *c.targetURL u.Path = path.Join(string(u.Separator), bucketName, key) if strings.HasPrefix(record.EventName, "s3:ObjectCreated:") { diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index 5f726a47..532547f0 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -19,7 +19,6 @@ package cmd import ( "context" "fmt" - "math/rand" "os" "path" "path/filepath" @@ -438,8 +437,11 @@ func (mj *mirrorJob) watchMirror(ctx context.Context, cancelMirror context.Cance if (event.Type == EventCreate) || (event.Type == EventCreatePutRetention) { mirrorURL := URLs{ - SourceAlias: sourceAlias, - SourceContent: &clientContent{URL: *sourceURL, Retention: event.Type == EventCreatePutRetention}, + SourceAlias: sourceAlias, + SourceContent: &clientContent{ + URL: *sourceURL, + Retention: event.Type == EventCreatePutRetention, + }, TargetAlias: targetAlias, TargetContent: &clientContent{URL: *targetURL}, encKeyDB: mj.encKeyDB, @@ -653,37 +655,6 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc mj.startMirror(ctx, cancelMirror, stopParallel) }() - // TODO: Remove this code when we fix - // and make ListenBucketNotification more - // performant. - if mj.multiMasterEnable { - // In multi-master mode make sure to - // continuously run startMirror periodically. - go func() { - // List source and target every 5secs - ticker := time.NewTicker(time.Second * 5) - defer ticker.Stop() - for { - select { - case <-mj.trapCh: - cancelMirror() - return - case <-mj.stopCh: - cancelMirror() - return - case <-ticker.C: - // Start with random sleep time, so as to avoid - // "synchronous checks" between servers - r := rand.New(rand.NewSource(time.Now().Unix())) - time.Sleep(time.Duration(r.Float64() * float64(time.Second*5))) - // startMirror blocks if there is already - // another mirror running. - mj.startMirror(ctx, cancelMirror, nil) - } - } - }() - } - // Close statusCh when both watch & mirror quits go func() { wg.Wait() diff --git a/go.mod b/go.mod index 009418fc..382e72db 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/mattn/go-runewidth v0.0.5 // indirect github.com/minio/cli v1.22.0 github.com/minio/minio v0.0.0-20191212015602-d266b3a06604 - github.com/minio/minio-go/v6 v6.0.45-0.20191209092716-97b0a62ed75d + github.com/minio/minio-go/v6 v6.0.45-0.20191213193129-a5786a9c2a5b github.com/minio/sha256-simd v0.1.1 github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/profile v1.3.0 diff --git a/go.sum b/go.sum index 5acff677..6e8af927 100644 --- a/go.sum +++ b/go.sum @@ -447,8 +447,6 @@ github.com/minio/minio v0.0.0-20190510004154-ac3b59645e92/go.mod h1:yFbQSwuA61mB github.com/minio/minio v0.0.0-20190903181048-8a71b0ec5a72/go.mod h1:H8OUaOxwJIALXHlfMpk2ESvk81dW+F7tSnrZi7rln/k= github.com/minio/minio v0.0.0-20190927193314-1c5b05c130fa/go.mod h1:47wx8w7yKTFAPw/hbmYPL4prsPivh6QuUqjTykftGgg= github.com/minio/minio v0.0.0-20191001201215-ff5bf519522f/go.mod h1:+vpJpzImdz4NCQto3r6/vF/24jWeEs5i3lsDfRmEcl4= -github.com/minio/minio v0.0.0-20191205124742-d8e3de0cae46 h1:6Oyny/iVD88fCrp3g4WbBjQJRdnzPZZO8aYI8tdONkY= -github.com/minio/minio v0.0.0-20191205124742-d8e3de0cae46/go.mod h1:3bY3lz9Uby83qOp5RsnPu4JJwiskVK088E7F4CRSdxI= github.com/minio/minio v0.0.0-20191212015602-d266b3a06604 h1:yAGvlmBRoK2F0xcAsQZ/yVd/gX/ZJHMX1xNXSPKskiM= github.com/minio/minio v0.0.0-20191212015602-d266b3a06604/go.mod h1:KL1MXxEmFjP6z0Sj4810GLRW9X01wrnQoIQCtFRl4PM= github.com/minio/minio-go v0.0.0-20190227180923-59af836a7e6d h1:gptD0/Hnam7h4Iq9D/33fscRpHfzOOUqUbH2nPw9HcU= @@ -461,8 +459,8 @@ github.com/minio/minio-go/v6 v6.0.29/go.mod h1:vaNT59cWULS37E+E9zkuN/BVnKHyXtVGS github.com/minio/minio-go/v6 v6.0.37/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= github.com/minio/minio-go/v6 v6.0.39 h1:9qmKCTBpQpMdGlDAbs3mbb4mmL45/lwRUvHL1VLhYUk= github.com/minio/minio-go/v6 v6.0.39/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= -github.com/minio/minio-go/v6 v6.0.45-0.20191209092716-97b0a62ed75d h1:jA5ctd5rmMlByojOIIk3FbYL3l4Ihu0JSUI7Smi5lTs= -github.com/minio/minio-go/v6 v6.0.45-0.20191209092716-97b0a62ed75d/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= +github.com/minio/minio-go/v6 v6.0.45-0.20191213193129-a5786a9c2a5b h1:mzW6HUPIw2tUQsUx7x4z4RPWABWFKnI6j47DIZNl53A= +github.com/minio/minio-go/v6 v6.0.45-0.20191213193129-a5786a9c2a5b/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg= github.com/minio/parquet-go v0.0.0-20190318185229-9d767baf1679 h1:OMKaN/82sBHUZPvjYNBFituHExa1OGY63eACDGtetKs= github.com/minio/parquet-go v0.0.0-20190318185229-9d767baf1679/go.mod h1:J+goXSuzlte5imWMqb6cUWC/tbYYysUHctwmKXomYzM= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=