Skip to content
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

rgw: use maintained github.com/aws/aws-sdk-go-v2 module instead of v1 #1057

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
module github.com/ceph/go-ceph

go 1.19
go 1.21

require (
github.com/aws/aws-sdk-go v1.55.5
github.com/aws/aws-sdk-go-v2 v1.32.7
github.com/aws/aws-sdk-go-v2/config v1.28.7
github.com/aws/aws-sdk-go-v2/credentials v1.17.48
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0
github.com/aws/smithy-go v1.22.1
github.com/gofrs/uuid/v5 v5.3.0
github.com/stretchr/testify v1.10.0
golang.org/x/sys v0.28.0
)

require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
46 changes: 36 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,24 +1,50 @@
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw=
github.com/aws/aws-sdk-go-v2 v1.32.7/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc=
github.com/aws/aws-sdk-go-v2/config v1.28.7 h1:GduUnoTXlhkgnxTD93g1nv4tVPILbdNQOzav+Wpg7AE=
github.com/aws/aws-sdk-go-v2/config v1.28.7/go.mod h1:vZGX6GVkIE8uECSUHB6MWAUsd4ZcG2Yq/dMa4refR3M=
github.com/aws/aws-sdk-go-v2/credentials v1.17.48 h1:IYdLD1qTJ0zanRavulofmqut4afs45mOWEI+MzZtTfQ=
github.com/aws/aws-sdk-go-v2/credentials v1.17.48/go.mod h1:tOscxHN3CGmuX9idQ3+qbkzrjVIx32lqDSU1/0d/qXs=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 h1:kqOrpojG71DxJm/KDPO+Z/y1phm1JlC8/iT+5XRmAn8=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22/go.mod h1:NtSFajXVVL8TA2QNngagVZmUtXciyrHOt7xgz4faS/M=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26/go.mod h1:3o2Wpy0bogG1kyOPrgkXA8pgIfEEv0+m19O9D5+W8y8=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 h1:GeNJsIFHB+WW5ap2Tec4K6dzcVTsRbsT1Lra46Hv9ME=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26/go.mod h1:zfgMpwHDXX2WGoG84xG2H+ZlPTkJUU4YUvx2svLQYWo=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 h1:tB4tNw83KcajNAzaIMhkhVI2Nt8fAZd5A5ro113FEMY=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7/go.mod h1:lvpyBGkZ3tZ9iSsUIcC2EWp+0ywa7aK3BLT+FwZi+mQ=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 h1:8eUsivBQzZHqe/3FE+cqwfH+0p5Jo8PFM/QYQSmeZ+M=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7/go.mod h1:kLPQvGUmxn/fqiCrDeohwG33bq2pQpGeY62yRO6Nrh0=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEHWM0bJ1QcBzxLrL/k2DHvGYhb8+W1w=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c=
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0 h1:SAfh4pNx5LuTafKKWR02Y+hL3A+3TX8cTKG1OIAJaBk=
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0/go.mod h1:r+xl5yzMk9083rMR+sJ5TYj9Tihvf/l1oxzZXDgGj2Q=
github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 h1:CvuUmnXI7ebaUAhbJcDy9YQx8wHR69eZ9I7q5hszt/g=
github.com/aws/aws-sdk-go-v2/service/sso v1.24.8/go.mod h1:XDeGv1opzwm8ubxddF0cgqkZWsyOtw4lr6dxwmb6YQg=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 h1:F2rBfNAL5UyswqoeWv9zs74N/NanhK16ydHW1pahX6E=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7/go.mod h1:JfyQ0g2JG8+Krq0EuZNnRwX0mU0HrwY/tG6JNfcqh4k=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 h1:Xgv/hyNgvLda/M9l9qxXc4UFSgppnRczLxlMs5Ae/QY=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3/go.mod h1:5Gn+d+VaaRgsjewpMvGazt0WfcFO+Md4wLOuBfGR9Bc=
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10 changes: 5 additions & 5 deletions internal/retry/sizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ type SizeFunc func(size int) (hint Hint)
// DoubleSize or indicating a size not greater than the current size, the size
// is doubled. If the hint or next size is greater than the max size, the max
// size is used for a last retry.
func WithSizes(size int, max int, f SizeFunc) {
if size > max {
func WithSizes(size int, maxSize int, f SizeFunc) {
if size > maxSize {
return
}
for {
hint := f(size)
if hint == nil || size == max {
if hint == nil || size == maxSize {
break
}
if hint.size() > size {
size = hint.size()
} else {
size *= 2
}
if size > max {
size = max
if size > maxSize {
size = maxSize
}
}
}
48 changes: 24 additions & 24 deletions rbd/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,23 +666,23 @@ var iterBufSize = 64
// const char *start_id, size_t max, char **image_ids,
// rbd_mirror_image_status_t *images, size_t *len)
func MirrorImageGlobalStatusList(
ioctx *rados.IOContext, start string, max int) ([]GlobalMirrorImageIDAndStatus, error) {
ioctx *rados.IOContext, start string, maxItems int) ([]GlobalMirrorImageIDAndStatus, error) {
var (
result []GlobalMirrorImageIDAndStatus
fetchAll bool
)
if max <= 0 {
max = iterBufSize
if maxItems <= 0 {
maxItems = iterBufSize
fetchAll = true
}
chunk := make([]GlobalMirrorImageIDAndStatus, max)
chunk := make([]GlobalMirrorImageIDAndStatus, maxItems)
for {
length, err := mirrorImageGlobalStatusList(ioctx, start, chunk)
if err != nil {
return nil, err
}
result = append(result, chunk[:length]...)
if !fetchAll || length < max {
if !fetchAll || length < maxItems {
break
}
start = chunk[length-1].ID
Expand All @@ -700,15 +700,15 @@ func mirrorImageGlobalStatusList(
defer C.free(unsafe.Pointer(cStart))

var (
max = C.size_t(len(results))
length = C.size_t(0)
ids = make([]*C.char, len(results))
images = make([]C.rbd_mirror_image_global_status_t, len(results))
maxItems = C.size_t(len(results))
length = C.size_t(0)
ids = make([]*C.char, len(results))
images = make([]C.rbd_mirror_image_global_status_t, len(results))
)
ret := C.rbd_mirror_image_global_status_list(
cephIoctx(ioctx),
cStart,
max,
maxItems,
&ids[0],
&images[0],
&length)
Expand Down Expand Up @@ -807,23 +807,23 @@ type MirrorImageInfoItem struct {
// rbd_mirror_image_info_t *info_entries, size_t *num_entries)
func MirrorImageInfoList(
ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter, start string,
max int) ([]MirrorImageInfoItem, error) {
maxItems int) ([]MirrorImageInfoItem, error) {
var (
result []MirrorImageInfoItem
fetchAll bool
)
if max <= 0 {
max = iterBufSize
if maxItems <= 0 {
maxItems = iterBufSize
fetchAll = true
}
chunk := make([]MirrorImageInfoItem, max)
chunk := make([]MirrorImageInfoItem, maxItems)
for {
length, err := mirrorImageInfoList(ioctx, start, modeFilter, chunk)
if err != nil {
return nil, err
}
result = append(result, chunk[:length]...)
if !fetchAll || length < max {
if !fetchAll || length < maxItems {
break
}
start = chunk[length-1].ID
Expand All @@ -838,7 +838,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string,
defer C.free(unsafe.Pointer(cStart))

var (
max = C.size_t(len(results))
maxItems = C.size_t(len(results))
length = C.size_t(0)
ids = make([]*C.char, len(results))
modes = make([]C.rbd_mirror_image_mode_t, len(results))
Expand All @@ -853,7 +853,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string,
cephIoctx(ioctx),
modeFilterPtr,
cStart,
max,
maxItems,
&ids[0],
&modes[0],
&infos[0],
Expand Down Expand Up @@ -949,23 +949,23 @@ type MirrorImageInstanceIDItem struct {
// size_t *len)
func MirrorImageInstanceIDList(
ioctx *rados.IOContext, start string,
max int) ([]MirrorImageInstanceIDItem, error) {
maxItems int) ([]MirrorImageInstanceIDItem, error) {
var (
result []MirrorImageInstanceIDItem
fetchAll bool
)
if max <= 0 {
max = iterBufSize
if maxItems <= 0 {
maxItems = iterBufSize
fetchAll = true
}
chunk := make([]MirrorImageInstanceIDItem, max)
chunk := make([]MirrorImageInstanceIDItem, maxItems)
for {
length, err := mirrorImageInstanceIDList(ioctx, start, chunk)
if err != nil {
return nil, err
}
result = append(result, chunk[:length]...)
if !fetchAll || length < max {
if !fetchAll || length < maxItems {
break
}
start = chunk[length-1].ID
Expand All @@ -980,15 +980,15 @@ func mirrorImageInstanceIDList(ioctx *rados.IOContext, start string,
defer C.free(unsafe.Pointer(cStart))

var (
max = C.size_t(len(results))
maxItems = C.size_t(len(results))
length = C.size_t(0)
ids = make([]*C.char, len(results))
instanceIDs = make([]*C.char, len(results))
)
ret := C.rbd_mirror_image_instance_id_list(
cephIoctx(ioctx),
cStart,
max,
maxItems,
&ids[0],
&instanceIDs[0],
&length,
Expand Down
17 changes: 12 additions & 5 deletions rgw/admin/radosgw.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (

"errors"

"github.com/aws/aws-sdk-go/aws/credentials"
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/credentials"
)

const (
Expand Down Expand Up @@ -78,14 +79,20 @@ func (api *API) call(ctx context.Context, httpMethod, path string, args url.Valu
}

// Build S3 authentication
cred := credentials.NewStaticCredentials(api.AccessKey, api.SecretKey, "")
signer := v4.NewSigner(cred)
credCache := aws.NewCredentialsCache(credentials.NewStaticCredentialsProvider(api.AccessKey, api.SecretKey, ""))
creds, err := credCache.Retrieve(ctx)
if err != nil {
return nil, err
}

signer := v4.NewSigner()
// This was present in https://github.com/IrekFasikhov/go-rgwadmin/ but it seems that the lib works without it
// Let's keep it here just in case something shows up
// signer.DisableRequestBodyOverwrite = true

// Sign in S3
_, err = signer.Sign(request, nil, service, authRegion, time.Now())
const emptyPayloadHash = "UNSIGNED-PAYLOAD"
err = signer.SignHTTP(ctx, creds, request, emptyPayloadHash, service, authRegion, time.Now())
if err != nil {
return nil, err
}
Expand Down
Loading
Loading