Add functions for issuing commands to ceph mgrs with
MgrCommand and MgrCommandWithInputBuffer, implemented simliarly
to the other *Command style functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Organize the rados package a bit more by moving functions that wrap
rados_xyz_command functions into a dedicated file. Move related test to
a separate file as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Clean up the temporary file using a defer and make sure that the
errors returned by the functions in the defer func are checked.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
For more consisistency use getError where possible.
Changes produced using `gofmt -r 'RadosError(int(x)) -> getError(x)`,
followed by a few manual fixups.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
It appears that ceph octopus (currently testing as master) is stricter
about some inputs and the old formatting in the test was failing.
Use formatting that all versions should be happy with.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This improves the code in two ways: first, it makes the function name and the
return type match. Second, it avoids issues found by go vet converting
from uintptr to unsafe.Pointer without any obvious pointer math.
(See: https://pkg.go.dev/unsafe)
Technically, this is an API breaking change but this function is only
public to exchange the internal ceph structure between the rados and
rbd modules. This had the smallest delta and doesn't feel any more
hacky than what already existed in the code. If someone was using this
function externally then too bad.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Moving the errutil pkg to "internal/errutil" makes errutil private-like
and accessible to only other go-ceph packages. The functions it provided
were always meant to be used only by go-ceph, this just makes it more
official. This is a breaking change but it was only available to
outside users for 1 release and it is somewhat doubtful users outside
of go-ceph would have reached for these functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This is a minor cleanup that only stops the checker from complaining
rather than actually improving the documentation.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Create an object_iter.go from the Iter related functions that were
formerly in ioctx.go. This makes ioctx a little less of a giant wall of
code as well as making things easier to work on in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This is a minor cleanup that only stops the checker from complaining
rather than actually improving the documentation.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Create an omap.go from the omap functions that were formerly in
ioctx.go. This makes ioctx a little less of a giant wall of code
as well as making things easier to work on in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
RadosError-prefixes are not recommended, instead just Err as prefix is
used.
Also, errors are constants, not variables.
For existing users, backwards compatible constants are available. These
will need to be removed in a future go-ceph release.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
The cephfs function ceph_create_from_rados requires the cluster_t
value, which is current private to the Conn type. Alias the cluster_t
type and allow other pkgs to get it if needed.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The code path where the pools result buffer was increased in size
then re-fetched was not being tested. Test it.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Testfiy's assert and require libs have helpful functions for
checking values. Use them to reduce a bunch of boilerplate code in the
TestGetPoolByName function.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
A number of the error handling checks do not seem to need to check
for specific non-zero error returns so we should be able to
convert to getRadosError rather than a lot of boiler-plate.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
A number of the functions in rados do not use the simple error
conversion function where is obviously applies. Convert them to use it.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
There is no good reason why the internal error handling support should
be exposed outside the rados package. Make the function lower-cased and
thus private.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
When working on the previous rbd change it was determined that the
connection setup code would block forever if the ceph config was missing
or bad when running the tests. Adjust the connection setup in the rados
pkg such that the tests will not block forever.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Keeping the _test.go code in the same package allows for the testing
of private functions. AFAIK it is more conventional as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>