-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
objstore : implement Aliyun OSS #1573
Conversation
@wujinhu What is the status now? This guy shaulboozhiao has deleted the code he had... |
@woodliu Sorry for the delay, will update this week. |
I have try and merge the history code from your repo, it works, there's not much files changed, it seems that merge manually is a better way.
I have try and merge the history code from your repo, it works, there's not much files changed, it seems that merge manually is a better way. |
Any luck? (: Feel free to squash the original commits into one. |
revert commits and apply patch! |
Sth is wrong with the patch, I am fixing! |
d39ca1c
to
406cb76
Compare
@bwplotka @jojohappy Please help review this PR, thanks!😆 |
bucket *alioss.Bucket | ||
} | ||
|
||
func NewTestBucket(t testing.TB) (objstore.Bucket, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code should be in *_test.go files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, this is the idiom for now. This is because _test.go files even exported methods are not exported between packages.
On the other hand this method is really the same across objectstores so we might want to refactor it to one (:
return NewTestBucketFromConfig(t, c, false) | ||
} | ||
|
||
func calculateChunks(name string, r io.Reader) (int, int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't do this type castin, let's just take an interface which has io.Reader
& Size()
methods instead of supporting only os.File
& strings.Reader
types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little ambiguous about this. We take S3 as an example, could you please give me comments in more details. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do this in another PR. As this would require quite a lot of refactoring.
If we change the interface in https://github.com/thanos-io/thanos/blob/master/pkg/objstore/objstore.go#L26
from:
Upload(ctx context.Context, name string, r io.Reader) error
to
type ReadSizer interface{
io.Reader
Size() int64
}
Upload(ctx context.Context, name string, r ReadSizer) error
We would avoid this hack entirely.
@bwplotka what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there is no way to have this working without knowing the size beforehand? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could change interface, but the S3 example is bad - we should never rely on size as it block streaming case. However the truth is there is no case we need streaming currently for write (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to actually read all the bytes into memory and then we would know the size, which sucks for memory requirements.
I would prefer to have ReadSizer
, it actually helps upload case, as the uploader client can split the object into chunks, make it parallel, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's the thing, for streaming purposes you buffer let's say 128KB then if you buffer more you know you need multipart. While you traverse the file you stream parts until end of the reader (: I think that's what GCS is doing for example. Essentially you can implement this without knowing size beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact this will be required if we would like to have this: #1673
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you are right. Actually in this case we shouldn't need a Size() method, we can just do what you said and upload parts the way you described.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this discussion here: #678
return nil | ||
} | ||
|
||
func NewTestBucketFromConfig(t testing.TB, c Config, reuseBucket bool) (objstore.Bucket, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code should be in *_test.go files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@povilasv could we refactor obj testing in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Signed-off-by: wujinhu <wujinhu920@126.com>
Signed-off-by: wujinhu <wujinhu920@126.com>
Signed-off-by: wujinhu <wujinhu920@126.com>
Signed-off-by: wujinhu <wujinhu920@126.com>
@povilasv @jojohappy Thanks for your comments, they are very helpful, and I updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, generally LGTM, some minor comments only. Very clean code, thanks!
It's sad OSS SDK does not have multipart logic without file size. It indeed gives another reason to change our interface and add size to it. Not for this PR for sure though.
Can you confirm the acceptance e2e is successfully working with this provider? (
func TestObjStore_AcceptanceTest_e2e(t *testing.T) { |
bucket *alioss.Bucket | ||
} | ||
|
||
func NewTestBucket(t testing.TB) (objstore.Bucket, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, this is the idiom for now. This is because _test.go files even exported methods are not exported between packages.
On the other hand this method is really the same across objectstores so we might want to refactor it to one (:
@@ -60,6 +60,7 @@ Current object storage client implementations: | |||
| [Azure Storage Account](./storage.md#azure) | Stable (production usage) | yes | @vglafirov | | |||
| [OpenStack Swift](./storage.md#openstack-swift) | Beta (working PoCs, testing usage) | no | @sudhi-vm | | |||
| [Tencent COS](./storage.md#tencent-cos) | Beta (testing usage) | no | @jojohappy | | |||
| [AliYun OSS](./storage.md#aliyun-oss) | Beta (testing usage) | no | @shaulboozhiao,@wujinhu | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -336,3 +337,20 @@ config: | |||
``` | |||
|
|||
Set the flags `--objstore.config-file` to reference to the configuration file. | |||
|
|||
## AliYun OSS Configuration | |||
In order to use AliYun OSS object storage, you should first create a bucket with proper Storage Class , ACLs and get the access key on the AliYun cloud. Go to [https://www.alibabacloud.com/product/oss](https://www.alibabacloud.com/product/oss) for more detail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What proper Storage Class
means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same meaning with S3 https://aws.amazon.com/s3/storage-classes/?nc1=h_ls
It defines the storage type of data.
return NewTestBucketFromConfig(t, c, false) | ||
} | ||
|
||
func calculateChunks(name string, r io.Reader) (int, int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea ok it looks like for multipart need to do on our own: https://github.com/aliyun/aliyun-oss-go-sdk/blob/d0a2d03230103776946b757cbc05aeecb523d9c9/oss/multipart_test.go#L180
Signed-off-by: wujinhu <wujinhu920@126.com>
Signed-off-by: wujinhu <wujinhu920@126.com>
=== RUN TestObjStore_AcceptanceTest_e2e Process finished with exit code 0 |
=== RUN TestBucketStore_e2e Process finished with exit code 0
=== RUN TestBucketStore_TimePartitioning_e2e Process finished with exit code 0 |
@bwplotka acceptance_e2e_test.go and bucket_e2e_test.go both are ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! We can wait @povilasv to review the next round.
pkg/objstore/oss/oss.go
Outdated
return nil, err | ||
} | ||
|
||
if _, err := resp.Read(nil); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we reading nil bytes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I ran oss and s3 tests and there is no need here because oss sdk is not same with s3 sdk.
// NotFoundObject error is revealed only after first Read. This does the initial GetRequest. Prefetch this here
// for convenience.
if _, err := r.Read(nil); err != nil {
runutil.CloseWithLogOnErr(b.logger, r, "s3 get range obj close")
// First GET Object request error.
return nil, err
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment other than that LGTM 👍
Signed-off-by: wujinhu <wujinhu920@126.com>
@bwplotka @povilasv @jojohappy I think each comment has been addressed. 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work, thanks!
return NewTestBucketFromConfig(t, c, false) | ||
} | ||
|
||
func calculateChunks(name string, r io.Reader) (int, int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this discussion here: #678
* add oss support Signed-off-by: wujinhu <wujinhu920@126.com> * fix docs Signed-off-by: wujinhu <wujinhu920@126.com> * fix Makefile Signed-off-by: wujinhu <wujinhu920@126.com> * review comments Signed-off-by: wujinhu <wujinhu920@126.com> * fix style Signed-off-by: wujinhu <wujinhu920@126.com> * review comments Signed-off-by: wujinhu <wujinhu920@126.com> * review comments Signed-off-by: wujinhu <wujinhu920@126.com> * review comments Signed-off-by: wujinhu <wujinhu920@126.com> * review comments Signed-off-by: wujinhu <wujinhu920@126.com> Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Open this PR as discussed in #1234 , will update soon.