-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add Huawei Cloud OBS Object Storage Support #50
Conversation
Signed-off-by: setoru <[email protected]>
Signed-off-by: setoru <[email protected]>
Signed-off-by: setoru <[email protected]>
Signed-off-by: setoru <[email protected]>
Signed-off-by: setoru <[email protected]>
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.
Thanks for this! For now I skimmed through the PR, few suggestions. It also looks like the tests and lint are failing for now.
objtesting/foreach.go
Outdated
@@ -4,6 +4,7 @@ | |||
package objtesting | |||
|
|||
import ( | |||
"github.com/thanos-io/objstore/providers/obs" |
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.
nit: Can we keep imports grouping? i.e. move this down to the last group.
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.
sure can,I will fix it.
scripts/cfggen/main.go
Outdated
@@ -5,6 +5,7 @@ package main | |||
|
|||
import ( | |||
"fmt" | |||
"github.com/thanos-io/objstore/providers/obs" |
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.
Nit: same as previous (import grouping)
client/factory.go
Outdated
@@ -6,6 +6,7 @@ package client | |||
import ( | |||
"context" | |||
"fmt" | |||
"github.com/thanos-io/objstore/providers/obs" |
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.
Nit: Import ordering
providers/obs/obs.go
Outdated
_, err := b.client.PutObject(input) | ||
return errors.Wrap(err, "fail to upload object") |
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.
If find doing if err != nil { return errors.Wrap(...) }
to be a readable a bit better rather than returning directly errors.Wrap
.
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 will fix it
providers/obs/obs.go
Outdated
initOutput, err := b.client.InitiateMultipartUpload(initInput) | ||
return initOutput, errors.Wrap(err, "fail to init multipart upload job") |
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.
Same as previous comment (Doing if err != nil { return errors.Wrap(...) }
rather than directly returning wrap).
Signed-off-by: setoru <[email protected]>
Signed-off-by: setoru <[email protected]>
Signed-off-by: setoru <[email protected]>
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.
This is looking good, thank you! I have added couple more suggestions after second review.
providers/obs/obs.go
Outdated
if length != -1 { | ||
input.RangeEnd = off + length - 1 | ||
} else { | ||
input.RangeEnd = math.MaxInt64 | ||
} |
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.
Nit: Small readability improvement suggestion.
if length != -1 { | |
input.RangeEnd = off + length - 1 | |
} else { | |
input.RangeEnd = math.MaxInt64 | |
} | |
input.RangeEnd = math.MaxInt64 | |
if length != -1 { | |
input.RangeEnd = off + length - 1 | |
} |
providers/obs/obs.go
Outdated
Parts: parts, | ||
}) | ||
if err != nil { | ||
return errors.Wrap(err, "fail to complete multipart upload") |
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.
Nit: Could we make all comments say failed
instead of fail
return errors.Wrap(err, "fail to complete multipart upload") | |
return errors.Wrap(err, "failed to complete multipart upload") |
providers/obs/obs.go
Outdated
} | ||
for _, content := range output.Contents { | ||
if err := f(content.Key); err != nil { | ||
return errors.Wrap(err, "fail to call f for object") |
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 make this a bit more user friendly, something along to lines failed to call iter function for object X
?
README.md
Outdated
@@ -640,6 +641,41 @@ config: | |||
|
|||
You can also include any of the optional configuration just like the example in `Default Provider`. | |||
|
|||
##### HuaweiCloud OBS | |||
|
|||
To use HuaweiCloud OBS as storage store, you should apply a HuaweiCloud Account to create an object storage bucket at first. |
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.
To use HuaweiCloud OBS as storage store, you should apply a HuaweiCloud Account to create an object storage bucket at first. | |
To use HuaweiCloud OBS as an object store, you should apply for a HuaweiCloud Account to create an object storage bucket at first. |
README.md
Outdated
##### HuaweiCloud OBS | ||
|
||
To use HuaweiCloud OBS as storage store, you should apply a HuaweiCloud Account to create an object storage bucket at first. | ||
Note that detailed from [HuaweiCloud OBS](https://support.huaweicloud.com/obs/index.html) |
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.
Note that detailed from [HuaweiCloud OBS](https://support.huaweicloud.com/obs/index.html) | |
More details: [HuaweiCloud OBS](https://support.huaweicloud.com/obs/index.html) |
README.md
Outdated
To use HuaweiCloud OBS as storage store, you should apply a HuaweiCloud Account to create an object storage bucket at first. | ||
Note that detailed from [HuaweiCloud OBS](https://support.huaweicloud.com/obs/index.html) | ||
|
||
To configure HuaweiCloud Account to use OBS as storage store you need to set these parameters in yaml format stored in a file: |
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.
To configure HuaweiCloud Account to use OBS as storage store you need to set these parameters in yaml format stored in a file: | |
To configure HuaweiCloud Account to use OBS as storage store you need to set these parameters in YAML format stored in a file: |
providers/obs/obs.go
Outdated
switch oriErr := errors.Cause(err).(type) { | ||
case obs.ObsError: | ||
if oriErr.Status == "404 Not Found" { |
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.
Since we have only one case, why not do oriErr, ok := errors.Cause(err).(obs.ObsError)
?
Signed-off-by: setoru <[email protected]>
providers/obs/obs.go
Outdated
} | ||
for _, content := range output.Contents { | ||
if err := f(content.Key); err != nil { | ||
return errors.Wrap(err, "fail to call f for object") | ||
return errors.Wrap(err, "failed to call iter function for object X") |
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 mean here instead of X, you could use content.Key
to signal which object the function failed for?
providers/obs/obs.go
Outdated
} | ||
} | ||
for _, topDir := range output.CommonPrefixes { | ||
if err := f(topDir); err != nil { | ||
return errors.Wrap(err, "fail to call f for top dir object") | ||
return errors.Wrap(err, "failed to call f for top dir object") |
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.
Can we adjust this the same way as my previous comment (don't say failed to call f ...
but rather failed to call iter function
)
Signed-off-by: setoru <[email protected]>
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.
This is looking good now, thank you @setoru! 🙇
Thank you for reviewing! |
Huawei Cloud is a public cloud provider in China, Its object storage product is OBS.
thanos is not supported OBS right now,This pr implements a OBS client and it seems to be ok.
I would like to become the maintainer for the OBS provider and keep development for Thanos.
Changes
Verification