You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "divinerapier (via GitHub)" <gi...@apache.org> on 2024/11/22 10:28:03 UTC
[PR] Feat: support aliyun oss backend. [iceberg-go]
divinerapier opened a new pull request, #216:
URL: https://github.com/apache/iceberg-go/pull/216
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Feat: support aliyun oss backend. [iceberg-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #216:
URL: https://github.com/apache/iceberg-go/pull/216#discussion_r1882673169
##########
catalog/catalog.go:
##########
@@ -32,6 +32,12 @@ type CatalogType string
type AwsProperties map[string]string
+type OSSConfig struct {
Review Comment:
Can we add a docstring comment to explain what this config is for?
##########
catalog/catalog.go:
##########
@@ -122,12 +128,32 @@ func WithPrefix(prefix string) Option[RestCatalog] {
}
}
+func WithOSSEndpoint(endpoint string) Option[RestCatalog] {
+ return func(o *options) {
+ o.ossConfig.Endpoint = endpoint
+ }
+}
+
+func WithOSSAccessKey(accessKey string) Option[RestCatalog] {
+ return func(o *options) {
+ o.ossConfig.AccessKey = accessKey
+ }
+}
+
+func WithOSSSecretKey(secretKey string) Option[RestCatalog] {
+ return func(o *options) {
+ o.ossConfig.SecretKey = secretKey
+ }
+}
Review Comment:
Should we just do `WithOSSConfig(cfg OSSConfig) Option[RestCatalog]` instead?
##########
io/oss.go:
##########
@@ -0,0 +1,153 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package io
+
+import (
+ "fmt"
+ "io"
+ "io/fs"
+ "net/url"
+ "os"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/aliyun/aliyun-oss-go-sdk/oss"
+)
+
+// Constants for OSS configuration options
+const (
+ OSSAccessKey = "client.oss-access-key"
+ OSSSecretKey = "client.oss-secret-key"
+ OSSEndpoint = "client.oss-endpoint"
+)
+
+func createOSSFileIO(parsed *url.URL, props map[string]string) (IO, error) {
+ endpoint, ok := props[OSSEndpoint]
+ if !ok {
+ endpoint = os.Getenv("OSS_ENDPOINT")
+ }
+ if endpoint == "" {
+ return nil, fmt.Errorf("oss endpoint must be specified")
+ }
+
+ accessKey := props[OSSAccessKey]
+ secretKey := props[OSSSecretKey]
+
+ client, err := oss.New(endpoint, accessKey, secretKey)
+ if err != nil {
+ return nil, err
+ }
+
+ bucketName := parsed.Host
+ bucket, err := client.Bucket(bucketName)
+ if err != nil {
+ return nil, err
+ }
+
+ ossFS := &ossFS{
+ bucket: bucket,
+ }
+
+ preprocess := func(n string) string {
+ _, after, found := strings.Cut(n, "://")
+ if found {
+ n = after
+ }
+ return strings.TrimPrefix(n, parsed.Host)
+ }
+
+ return FSPreProcName(ossFS, preprocess), nil
+}
+
+type ossFS struct {
+ bucket *oss.Bucket
+}
+
+// Open implements fs.FS
+func (o *ossFS) Open(name string) (fs.File, error) {
+ if !fs.ValidPath(name) {
+ return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrInvalid}
+ }
+ if name == "." {
+ return &ossFile{
+ name: name,
+ bucket: o.bucket,
+ }, nil
+ }
+ name = strings.TrimPrefix(name, "/")
+
+ obj, err := o.bucket.GetObject(name)
+ if err != nil {
+ return nil, err
+ }
+
+ return &ossFile{
+ reader: obj,
+ name: name,
+ bucket: o.bucket,
+ }, nil
+}
+
+type ossFile struct {
+ mutex sync.Mutex
+ reader io.ReadCloser
+ bucket *oss.Bucket
+ name string
+}
+
+func (f *ossFile) Read(p []byte) (int, error) {
+ f.mutex.Lock()
+ defer f.mutex.Unlock()
+
+ return f.reader.Read(p)
+}
Review Comment:
this needs to be updated to implement `io.ReadSeekCloser` and `io.ReaderAt` interfaces
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Feat: support aliyun oss backend. [iceberg-go]
Posted by "divinerapier (via GitHub)" <gi...@apache.org>.
divinerapier commented on PR #216:
URL: https://github.com/apache/iceberg-go/pull/216#issuecomment-2544416465
@zeroshade
Automated integration testing is indeed crucial. However, unfortunately, I haven't yet found a reasonable and convenient way to access OSS services in the integration testing environment.
I've tried the following approaches:
* Contacted Aliyun's customer service to inquire about recommended solutions. They suggested using OSS cloud services directly, but this raises questions about who would provide the account and access permissions.
* Attempted to simulate OSS using MinIO, but unfortunately, whether using v1 or v4 signatures, it always results in 400 errors. We suspect that OSS's signature scheme is incompatible with MinIO's.
* MinIO previously offered a project called [minio-gateway-oss](https://blog.min.io/deprecation-of-the-minio-gateway/), but it was deprecated in 2022.
Therefore, regarding OSS integration testing implementation, I haven't been able to identify other viable solutions.
Since this modification is being used in our company's actual project, the good news is that we haven't encountered any issues in production so far.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Feat: support aliyun oss backend. [iceberg-go]
Posted by "divinerapier (via GitHub)" <gi...@apache.org>.
divinerapier closed pull request #216: Feat: support aliyun oss backend.
URL: https://github.com/apache/iceberg-go/pull/216
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Feat: support aliyun oss backend. [iceberg-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #216:
URL: https://github.com/apache/iceberg-go/pull/216#issuecomment-2542403956
This seems generally good to me. Does Aliyun have something similar to how MinIO works for S3 that can be added to the integration tests to have CI testing the backend? i.e. is there any way to use a docker image to run something that simulates the Aliyun backend for testing?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Feat: support aliyun oss backend. [iceberg-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #216:
URL: https://github.com/apache/iceberg-go/pull/216#issuecomment-2546599302
the Java iceberg impl has some mocking and test setups for Aliyun as seen [here](https://github.com/apache/iceberg/tree/main/aliyun/src/test/java/org/apache/iceberg/aliyun/oss) would it make sense to create a similar utility in Go? or is it not worth that effort there?
Is there *any* sort of testing we could add here for this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Feat: support aliyun oss backend. [iceberg-go]
Posted by "divinerapier (via GitHub)" <gi...@apache.org>.
divinerapier commented on PR #216:
URL: https://github.com/apache/iceberg-go/pull/216#issuecomment-2540608798
@zeroshade Fixed, PTAL
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org