rebase: use go-ceph v0.3.0

v0.3.0 adds support for rbd.FeatureSet that can be used to parse the
features of an RBD image. This will be used in the followup commit that
adds rbdVolume.getImageInfo().

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2020-05-08 16:07:31 +02:00
committed by mergify[bot]
parent 323cc0e3bb
commit 772d1dfa77
23 changed files with 990 additions and 375 deletions

View File

@ -7,37 +7,15 @@ package rados
import "C"
import (
"fmt"
"runtime"
"unsafe"
"github.com/ceph/go-ceph/errutil"
)
// RadosError represents an error condition returned from the Ceph RADOS APIs.
type RadosError int
// Error returns the error string for the RadosError type.
func (e RadosError) Error() string {
errno, s := errutil.FormatErrno(int(e))
if s == "" {
return fmt.Sprintf("rados: ret=%d", errno)
}
return fmt.Sprintf("rados: ret=%d, %s", errno, s)
}
const (
// AllNamespaces is used to reset a selected namespace to all
// namespaces. See the IOContext SetNamespace function.
AllNamespaces = C.LIBRADOS_ALL_NSPACES
// ErrNotFound indicates a missing resource.
ErrNotFound = RadosError(-C.ENOENT)
// ErrPermissionDenied indicates a permissions issue.
ErrPermissionDenied = RadosError(-C.EPERM)
// ErrObjectExists indicates that an exclusive object creation failed.
ErrObjectExists = RadosError(-C.EEXIST)
// FIXME: for backwards compatibility
// RadosAllNamespaces is used to reset a selected namespace to all
@ -45,23 +23,8 @@ const (
//
// Deprecated: use AllNamespaces instead
RadosAllNamespaces = AllNamespaces
// RadosErrorNotFound indicates a missing resource.
//
// Deprecated: use ErrNotFound instead
RadosErrorNotFound = ErrNotFound
// RadosErrorPermissionDenied indicates a permissions issue.
//
// Deprecated: use ErrPermissionDenied instead
RadosErrorPermissionDenied = ErrPermissionDenied
)
func getRadosError(err int) error {
if err == 0 {
return nil
}
return RadosError(err)
}
// Version returns the major, minor, and patch components of the version of
// the RADOS library linked against.
func Version() (int, int, int) {
@ -79,7 +42,7 @@ func newConn(user *C.char) (*Conn, error) {
ret := C.rados_create(&conn.cluster, user)
if ret != 0 {
return nil, RadosError(int(ret))
return nil, getError(ret)
}
runtime.SetFinalizer(conn, freeConn)
@ -112,7 +75,7 @@ func NewConnWithClusterAndUser(clusterName string, userName string) (*Conn, erro
conn := makeConn()
ret := C.rados_create2(&conn.cluster, c_cluster_name, c_name, 0)
if ret != 0 {
return nil, RadosError(int(ret))
return nil, getError(ret)
}
runtime.SetFinalizer(conn, freeConn)