diff --git a/go.mod b/go.mod index 26b794106..40f20834b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.18.3 github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000 // TODO: API for managing subvolume metadata and snapshot metadata requires `ceph_ci_untested` build-tag - github.com/ceph/go-ceph v0.19.0 + github.com/ceph/go-ceph v0.20.0 github.com/container-storage-interface/spec v1.7.0 github.com/csi-addons/replication-lib-utils v0.2.0 github.com/csi-addons/spec v0.1.2-0.20221101132540-98eff76b0ff8 diff --git a/go.sum b/go.sum index 2bb27c44d..3ab1f0098 100644 --- a/go.sum +++ b/go.sum @@ -171,8 +171,8 @@ github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8 github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE= -github.com/ceph/go-ceph v0.19.0 h1:cl5apHt98pCWSoUStiLdl7Mlk3ke8fUGF4HI66Nxy/A= -github.com/ceph/go-ceph v0.19.0/go.mod h1:sdTcqdDeIPWX3TaR5HCi5YtT+BliI6fFvvWP6Io7VQE= +github.com/ceph/go-ceph v0.20.0 h1:weYE7zoVrIBk9bIVq8jS9z3RukGlnZwFGCth7Tu1ssU= +github.com/ceph/go-ceph v0.20.0/go.mod h1:/4iZyaN5wTpIFMEKO6GU3xX3vHnyvd2Fcdf05n9VuD0= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -363,7 +363,7 @@ github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/gocql/gocql v0.0.0-20190402132108-0e1d5de854df/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/uuid v4.3.1+incompatible h1:0/KbAdpx3UXAx1kEOWHJeOkpbgRFGHVgv+CFIY7dBJI= +github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= diff --git a/vendor/github.com/ceph/go-ceph/cephfs/admin/metadata.go b/vendor/github.com/ceph/go-ceph/cephfs/admin/metadata.go index 7eabc71db..29444cb9a 100644 --- a/vendor/github.com/ceph/go-ceph/cephfs/admin/metadata.go +++ b/vendor/github.com/ceph/go-ceph/cephfs/admin/metadata.go @@ -1,5 +1,5 @@ -//go:build !(nautilus || octopus) && ceph_preview && ceph_pre_quincy -// +build !nautilus,!octopus,ceph_preview,ceph_pre_quincy +//go:build !(nautilus || octopus || pacific) && ceph_preview +// +build !nautilus,!octopus,!pacific,ceph_preview package admin diff --git a/vendor/github.com/ceph/go-ceph/cephfs/admin/snapshot_metadata.go b/vendor/github.com/ceph/go-ceph/cephfs/admin/snapshot_metadata.go index 6f1c60f9b..e4c641cb0 100644 --- a/vendor/github.com/ceph/go-ceph/cephfs/admin/snapshot_metadata.go +++ b/vendor/github.com/ceph/go-ceph/cephfs/admin/snapshot_metadata.go @@ -1,5 +1,5 @@ -//go:build !(nautilus || octopus) && ceph_preview && ceph_pre_quincy -// +build !nautilus,!octopus,ceph_preview,ceph_pre_quincy +//go:build !(nautilus || octopus || pacific) && ceph_preview +// +build !nautilus,!octopus,!pacific,ceph_preview package admin diff --git a/vendor/github.com/ceph/go-ceph/common/admin/nfs/export.go b/vendor/github.com/ceph/go-ceph/common/admin/nfs/export.go index 6b981b724..9b29761d0 100644 --- a/vendor/github.com/ceph/go-ceph/common/admin/nfs/export.go +++ b/vendor/github.com/ceph/go-ceph/common/admin/nfs/export.go @@ -4,6 +4,8 @@ package nfs import ( + "errors" + "github.com/ceph/go-ceph/internal/commands" ) @@ -26,6 +28,10 @@ const ( Unspecifiedquash SquashMode = "" ) +var ( + errNoExportInfo = errors.New("No export info found") +) + // SecType indicates the kind of security/authentication to be used by an export. type SecType string @@ -115,6 +121,11 @@ func parseExportsList(res commands.Response) ([]ExportInfo, error) { func parseExportInfo(res commands.Response) (ExportInfo, error) { i := ExportInfo{} + // different versions of ceph may return nothing or empty json. + // detect these cases and return a specific error + if res.NoStatus().EmptyBody().Ok() { + return i, errNoExportInfo + } if err := res.NoStatus().Unmarshal(&i).End(); err != nil { return i, err } diff --git a/vendor/github.com/ceph/go-ceph/rados/alloc_hint_flags.go b/vendor/github.com/ceph/go-ceph/rados/alloc_hint_flags.go index dd468da20..1fd51cdb6 100644 --- a/vendor/github.com/ceph/go-ceph/rados/alloc_hint_flags.go +++ b/vendor/github.com/ceph/go-ceph/rados/alloc_hint_flags.go @@ -1,6 +1,3 @@ -//go:build ceph_preview -// +build ceph_preview - package rados // #cgo LDFLAGS: -lrados diff --git a/vendor/github.com/ceph/go-ceph/rbd/migration.go b/vendor/github.com/ceph/go-ceph/rbd/migration.go new file mode 100644 index 000000000..f7c13031a --- /dev/null +++ b/vendor/github.com/ceph/go-ceph/rbd/migration.go @@ -0,0 +1,219 @@ +//go:build !(octopus || nautilus) && ceph_preview +// +build !octopus,!nautilus,ceph_preview + +package rbd + +// #cgo LDFLAGS: -lrbd +// #include +// #include +// #include +import "C" + +import ( + "unsafe" + + "github.com/ceph/go-ceph/rados" +) + +// MigrationImageState denotes the current migration status of a given image. +type MigrationImageState int + +const ( + // MigrationImageUnknown is the representation of + // RBD_IMAGE_MIGRATION_STATE_UNKNOWN from librbd. + MigrationImageUnknown = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_UNKNOWN) + // MigrationImageError is the representation of + // RBD_IMAGE_MIGRATION_STATE_ERROR from librbd. + MigrationImageError = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_ERROR) + // MigrationImagePreparing is the representation of + // RBD_IMAGE_MIGRATION_STATE_PREPARING from librbd. + MigrationImagePreparing = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_PREPARING) + // MigrationImagePrepared is the representation of + // RBD_IMAGE_MIGRATION_STATE_PREPARED from librbd. + MigrationImagePrepared = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_PREPARED) + // MigrationImageExecuting is the representation of + // RBD_IMAGE_MIGRATION_STATE_EXECUTING from librbd. + MigrationImageExecuting = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_EXECUTING) + // MigrationImageExecuted is the representation of + // RBD_IMAGE_MIGRATION_STATE_EXECUTED from librbd. + MigrationImageExecuted = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_EXECUTED) + // MigrationImageAborting is the representation of + // RBD_IMAGE_MIGRATION_STATE_ABORTING from librbd. + MigrationImageAborting = MigrationImageState(C.RBD_IMAGE_MIGRATION_STATE_ABORTING) +) + +// MigrationImageStatus provides information about the +// live migration progress of an image. +type MigrationImageStatus struct { + SourcePoolID int + SourcePoolNamespace string + SourceImageName string + SourceImageID string + DestPoolID int + DestPoolNamespace string + DestImageName string + DestImageID string + State MigrationImageState + StateDescription string +} + +// MigrationPrepare prepares a migration +// creating a target image with a link +// to source and making source read-only. +// +// Implements: +// int rbd_migration_prepare(rados_ioctx_t ioctx, +// const char *image_name, +// rados_ioctx_t dest_ioctx, +// const char *dest_image_name, +// rbd_image_options_t opts); +// +func MigrationPrepare(ioctx *rados.IOContext, sourceImageName string, destIoctx *rados.IOContext, destImageName string, rio *ImageOptions) error { + cSourceImageName := C.CString(sourceImageName) + cDestImageName := C.CString(destImageName) + defer func() { + C.free(unsafe.Pointer(cSourceImageName)) + C.free(unsafe.Pointer(cDestImageName)) + }() + + ret := C.rbd_migration_prepare( + cephIoctx(ioctx), + cSourceImageName, + cephIoctx(destIoctx), + cDestImageName, + C.rbd_image_options_t(rio.options)) + + return getError(ret) +} + +// MigrationPrepareImport prepares a migration for import +// from a specified source to a new target image. +// +// Implements: +// int rbd_migration_prepare_import(const char *source_spec, +// rados_ioctx_t dest_ioctx, +// const char *dest_image_name, +// rbd_image_options_t opts); +// +func MigrationPrepareImport(sourceSpec string, ioctx *rados.IOContext, destImageName string, rio *ImageOptions) error { + cSourceSpec := C.CString(sourceSpec) + cDestImageName := C.CString(destImageName) + defer func() { + C.free(unsafe.Pointer(cSourceSpec)) + C.free(unsafe.Pointer(cDestImageName)) + }() + + ret := C.rbd_migration_prepare_import( + cSourceSpec, + cephIoctx(ioctx), + cDestImageName, + C.rbd_image_options_t(rio.options)) + + return getError(ret) +} + +// MigrationExecute starts copying the image blocks +// from the source image to the target image. +// +// Implements: +// int rbd_migration_execute(rados_ioctx_t ioctx, +// const char *image_name); +// +func MigrationExecute(ioctx *rados.IOContext, name string) error { + cName := C.CString(name) + + defer func() { + C.free(unsafe.Pointer(cName)) + }() + + ret := C.rbd_migration_execute( + cephIoctx(ioctx), + cName) + return getError(ret) +} + +// MigrationCommit commits a migration after execution +// breaking the relationship of image to the source. +// +// Implements: +// int rbd_migration_commit(rados_ioctx_t ioctx, +// const char *image_name); +// +func MigrationCommit(ioctx *rados.IOContext, name string) error { + cName := C.CString(name) + + defer func() { + C.free(unsafe.Pointer(cName)) + }() + + ret := C.rbd_migration_commit( + cephIoctx(ioctx), + cName) + return getError(ret) +} + +// MigrationAbort aborts a migration in progress +// breaking the relationship of image to the source. +// +// Implements: +// int rbd_migration_abort(rados_ioctx_t ioctx, +// const char *image_name); +// +func MigrationAbort(ioctx *rados.IOContext, name string) error { + cName := C.CString(name) + + defer func() { + C.free(unsafe.Pointer(cName)) + }() + + ret := C.rbd_migration_abort( + cephIoctx(ioctx), + cName) + return getError(ret) +} + +// MigrationStatus retrieve status of a live migration +// for the specified image. +// +// Implements: +// int rbd_migration_status(rados_ioctx_t ioctx, +// const char *image_name, +// rbd_image_migration_status_t *status, +// size_t status_size); +// +func MigrationStatus(ioctx *rados.IOContext, name string) (*MigrationImageStatus, error) { + cName := C.CString(name) + + defer func() { + C.free(unsafe.Pointer(cName)) + }() + + var status C.rbd_image_migration_status_t + ret := C.rbd_migration_status( + cephIoctx(ioctx), + cName, + &status, + C.sizeof_rbd_image_migration_status_t) + + if ret != 0 { + return nil, getError(ret) + } + + defer func() { + C.rbd_migration_status_cleanup(&status) + }() + + return &MigrationImageStatus{ + SourcePoolID: int(status.source_pool_id), + SourcePoolNamespace: C.GoString(status.source_pool_namespace), + SourceImageName: C.GoString(status.source_image_name), + SourceImageID: C.GoString(status.source_image_id), + DestPoolID: int(status.dest_pool_id), + DestPoolNamespace: C.GoString(status.dest_pool_namespace), + DestImageName: C.GoString(status.dest_image_name), + DestImageID: C.GoString(status.dest_image_id), + State: MigrationImageState(status.state), + StateDescription: C.GoString(status.state_description), + }, nil + +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 8cdb6c6ea..a9454736c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -119,7 +119,7 @@ github.com/cenkalti/backoff/v4 github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd github.com/ceph/ceph-csi/api/deploy/ocp -# github.com/ceph/go-ceph v0.19.0 +# github.com/ceph/go-ceph v0.20.0 ## explicit; go 1.17 github.com/ceph/go-ceph/cephfs/admin github.com/ceph/go-ceph/common/admin/manager