ncw/swift

Adjust Connection.QueryInfo method to compatible for Ceph's rgw

mlmhl opened this issue · 2 comments

mlmhl commented

In my environment, We use Ceph's rgw as a backend Storage. Its StorageUrl is /swift/v1. In current implement, the Connection.QueryInfo method will parse the infoUrl as /info due the code as follows:

infoUrl, err := url.Parse(c.StorageUrl)
if err != nil {
	return nil, err
}
infoUrl.Path = path.Join(infoUrl.Path, "..", "..", "info")

But the correct infoUrl for rgw is /swift/info, and this will make a mistake. That's probably because rgw supports more than one interface types(such as s3, swift, etc.), so it cannot just support a /info for all interface types.

I'm not sure if we need to be compatible with this situation, something just like this:

infoUrl, err := url.Parse(c.StorageUrl)
if err != nil {
	return nil, err
}
infoUrl.Path = path.Join(infoUrl.Path, "..", "..", "info")
resp, err := http.Get(infoUrl.String())
if err != nil {
	// Compatible for rgw.
	infoUrl.Path = path.Join(infoUrl.Path, "..", "info")
	resp, err = http.Get(infoUrl.String())
}

If we need to be compatible with this situation, I will submit a PR later.

ncw commented

We use Ceph's rgw as a backend Storage. Its StorageUrl is /swift/v1

I think that is the problem...

The storage URL should be /swift/v1/account_name which that construction turns in to /swift/info.

I've tested this library with several CEPH clusters so I'm not sure what is going on here - could it be your config somehow?

mlmhl commented

Thanks @ncw , I'm not familiar with CEPH, so I will check my config and close this issue first.