From 444050570ca925d4998a98949d277ac95c4121be Mon Sep 17 00:00:00 2001 From: Mudit Agarwal Date: Tue, 1 Jun 2021 15:28:28 +0530 Subject: [PATCH] rados: add SetPoolFullTry() and UnsetPoolFullTry() SetPoolFullTry() implements rados_set_pool_full_try() and UnsetPoolFullTry() implements rados_unset_pool_full_try() octopus onwards. Signed-off-by: Mudit Agarwal --- rados/ioctx_octopus.go | 37 +++++++++++++++++++++++++++++++++++++ rados/ioctx_octopus_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 rados/ioctx_octopus.go create mode 100644 rados/ioctx_octopus_test.go diff --git a/rados/ioctx_octopus.go b/rados/ioctx_octopus.go new file mode 100644 index 0000000..5cf4d0c --- /dev/null +++ b/rados/ioctx_octopus.go @@ -0,0 +1,37 @@ +// +build !nautilus + +package rados + +// #cgo LDFLAGS: -lrados +// #include +// +import "C" + +// Ceph octopus deprecates rados_set_osdmap_full_try() and implements rados_set_pool_full_try() +// Ceph octopus deprecates rados_unset_osdmap_full_try() and implements rados_unset_pool_full_try() + +// SetPoolFullTry makes sure to send requests to the cluster despite +// the cluster or pool being marked full; ops will either succeed(e.g., delete) +// or return EDQUOT or ENOSPC. +// +// Implements: +// void rados_set_pool_full_try(rados_ioctx_t io); +func (ioctx *IOContext) SetPoolFullTry() error { + if err := ioctx.validate(); err != nil { + return err + } + C.rados_set_pool_full_try(ioctx.ioctx) + return nil +} + +// UnsetPoolFullTry unsets the flag set by SetPoolFullTry() +// +// Implements: +// void rados_unset_pool_full_try(rados_ioctx_t io); +func (ioctx *IOContext) UnsetPoolFullTry() error { + if err := ioctx.validate(); err != nil { + return err + } + C.rados_unset_pool_full_try(ioctx.ioctx) + return nil +} diff --git a/rados/ioctx_octopus_test.go b/rados/ioctx_octopus_test.go new file mode 100644 index 0000000..7f9b0c8 --- /dev/null +++ b/rados/ioctx_octopus_test.go @@ -0,0 +1,30 @@ +// +build !nautilus + +package rados + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func (suite *RadosTestSuite) TestSetUnsetPoolFullTry() { + suite.SetupConnection() + suite.T().Run("invalidIOContext", func(t *testing.T) { + ioctx := &IOContext{} + err := ioctx.SetPoolFullTry() + assert.Error(t, err) + err = ioctx.UnsetPoolFullTry() + assert.Error(t, err) + }) + + suite.T().Run("validIOContext", func(t *testing.T) { + ioctx, err := suite.conn.OpenIOContext(suite.pool) + require.NoError(suite.T(), err) + err = ioctx.SetPoolFullTry() + assert.NoError(t, err) + err = ioctx.UnsetPoolFullTry() + assert.NoError(t, err) + }) +}