Skip to content

Commit

Permalink
S3 blobstore implementation (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
jontro authored and andrewjdawson2016 committed May 21, 2019
1 parent e7151c2 commit ffa6a99
Show file tree
Hide file tree
Showing 13 changed files with 8,132 additions and 5 deletions.
57 changes: 57 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,7 @@ ignored = ["github.com/uber/cadence/.gen"]
[[constraint]]
name = "github.com/valyala/fastjson"
version = "1.4.1"

[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "1.19.31"
14 changes: 13 additions & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/uber/cadence/client"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/blobstore/filestore"
"github.com/uber/cadence/common/blobstore/s3store"
"github.com/uber/cadence/common/elasticsearch"
"github.com/uber/cadence/common/log/loggerimpl"
"github.com/uber/cadence/common/log/tag"
Expand Down Expand Up @@ -184,7 +185,18 @@ func (s *server) startService() common.Daemon {
params.PublicClient = workflowserviceclient.New(dispatcher.ClientConfig(common.FrontendServiceName))

if params.ClusterMetadata.ArchivalConfig().ConfiguredForArchival() {
params.BlobstoreClient, err = filestore.NewClient(&s.cfg.Archival.Filestore)
if s.cfg.Archival.Filestore != nil && s.cfg.Archival.S3store != nil {
log.Fatalf("cannot config both filestore and s3store")
}
if s.cfg.Archival.Filestore != nil {
params.BlobstoreClient, err = filestore.NewClient(s.cfg.Archival.Filestore)
}
if s.cfg.Archival.S3store != nil {
s3cli, err := s3store.ClientFromConfig(s.cfg.Archival.S3store)
if err != nil {
params.BlobstoreClient = s3store.NewClient(s3cli)
}
}
if err != nil {
log.Fatalf("error creating blobstore: %v", err)
}
Expand Down
4 changes: 1 addition & 3 deletions common/blobstore/filestore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ var (
ErrDeleteFile = &shared.BadRequestError{Message: "could not delete file"}
// ErrListFiles could not list files
ErrListFiles = &shared.BadRequestError{Message: "could not list files"}
// ErrConstructKey could not construct key
ErrConstructKey = &shared.BadRequestError{Message: "could not construct key"}
// ErrBucketConfigDeserialization bucket config could not be deserialized
ErrBucketConfigDeserialization = &shared.BadRequestError{Message: "bucket config could not be deserialized"}
)
Expand Down Expand Up @@ -192,7 +190,7 @@ func (c *client) ListByPrefix(_ context.Context, bucket string, prefix string) (
if strings.HasPrefix(f, prefix) {
key, err := blob.NewKeyFromString(f)
if err != nil {
return nil, ErrConstructKey
return nil, blobstore.ErrConstructKey
}
matchingKeys = append(matchingKeys, key)
}
Expand Down
2 changes: 2 additions & 0 deletions common/blobstore/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var (
ErrBlobSerialization = &shared.BadRequestError{Message: "failed to serialize blob"}
// ErrBlobDeserialization indicates that a failure occurred in deserializing blob
ErrBlobDeserialization = &shared.BadRequestError{Message: "failed to deserialize blob"}
// ErrConstructKey could not construct key
ErrConstructKey = &shared.BadRequestError{Message: "could not construct key"}
)

// BucketMetadataResponse contains information relating to a bucket's configuration
Expand Down
22 changes: 22 additions & 0 deletions common/blobstore/s3store/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Amazon S3 blobstore

## Using localstack for local development
1. Install awscli from [here][https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html]
2. Install localstack from [here][https://github.com/localstack/localstack#installing]
3. Launch localstack with `SERVICES=s3 localstack start`
4. Create a bucket using `aws --endpoint-url=http://localhost:4572 s3 mb s3://cadence-development`
5. Configure archival with the following configuration
```
archival:
status: "enabled"
enableReadFromArchival: true
defaultBucket: "cadence-development"
s3store:
region: "us-east-1"
endpoint: "http://127.0.0.1:4572"
s3ForcePathStyle: true
```




Loading

0 comments on commit ffa6a99

Please sign in to comment.