Commit Graph

152 Commits

Author SHA1 Message Date
Niels de Vos 9e7a1c444f rbd: add error checking in OpenImage*() functions
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Mudit Agarwal a2c1c2bb34 rbd: add wrapper for rbd_pool_metadata_remove()
Add wrapper for rbd_pool_metadata_remove() function which removes pool
metadata associated with a given key.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Mudit Agarwal d999f78e2e rbd: add tests for GetPoolMetadata() and SetPoolMetadata()
Added test cases for GetPoolMetadata() func and SetPoolMetadata() func.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Mudit Agarwal 7b56123e17 rbd: add wrapper for rbd_pool_metadata_set()
Add wrapper for rbd_pool_metadata_set() function which sets pool metadata
associated with the given key.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Mudit Agarwal f88a17dc64 rbd: add wrapper for rbd_pool_metadata_get()
Add wrapper for rbd_pool_metadata_get() function which returns pool metadata
associated with the given key.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Niels de Vos 6c5364f422 rbd: add RBD_IMAGE_OPTION_MIRROR_IMAGE_MODE for Octopus
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-09 08:54:33 -04:00
Niels de Vos 8235827b5a rbd: add RBD_IMAGE_OPTION_CLONE_FORMAT for Nautilus
Fixes: #295
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-09 08:54:33 -04:00
Niels de Vos ba93f46cb4 rbd: add RBD_IMAGE_OPTION_FLATTEN for Mimic
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-09 08:54:33 -04:00
Sven Anderson 217e502afa rbd: add better error when attempting to remove opened images
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-05-28 08:49:35 -04:00
root e89344cae1 fix typos 2020-05-01 09:37:09 -04:00
Sven Anderson 6072f41bd6 update more code to use the retry lib.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-04-20 15:08:36 -04:00
Sven Anderson e8da761769 update various parts of the code to use the retry lib.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-04-20 15:08:36 -04:00
John Mulligan 0faccb56e8 rbd: check that encode calls dont return error
Don't ignore the error returned by json encode func call.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-09 13:11:05 -04:00
John Mulligan 8ce5fa5fc7 rbd: remove a redundant else statement
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-09 13:11:05 -04:00
John Mulligan 054ae8ddff rbd: consolidate error types & values in an errors.go file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 17:10:09 -04:00
John Mulligan eee19d642f rbd: rename uses of RbdImageOptions to ImageOptions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-23 10:09:25 -04:00
John Mulligan a29025a893 rbd: drop the Rbd prefix from ImageOptions and ImageOption
Previously, the types were named RbdImageOptions and RbdImageOption.
Now they are named ImageOptions and ImageOption.
Type aliases have been added to prevent existing code from
breaking. As these types were new in v0.2, I suspect we can drop
the aliases post-v0.3.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-23 10:09:25 -04:00
John Mulligan 51827ead4e rbd: convert uses of RbdImageOptionX to ImageOptionX
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-23 10:09:25 -04:00
John Mulligan 6d77dc97dc rbd: remove Rbd prefix from constants and provide aliases
Image option constants are now named ImageOptionX, without an Rbd
prefix. Aliases to the old names are provided and doc comments for both.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-23 10:09:25 -04:00
John Mulligan c2d0bc90ef rbd: add comments to features go file to pass check tool
Make the features.go file clean to the revive checker tool.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-23 10:09:25 -04:00
John Mulligan 8f2671fee9 rbd: add doc comments for (Get|Set|Remove)Metadata funcs
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-23 10:09:25 -04:00
John Mulligan 53fd07425a rbd: add doc comment for GetSnapshotNames function
This function also happens to be mis-named.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan 644b7939d0 rbd: add doc comments for Flush function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan 51e9a080bb rbd: add doc comments for ReadAt and WriteAt
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan 223f1e01d7 rbd: add doc comment to Discard function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan d71fb3b2ea rbd: add a doc comment for the Seek function
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan c3e1a2d032 rbd: add doc comment for image type
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan eb1cccea2f rbd: add doc comment for Locker type
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan b98ecb12fc rbd: add doc comments for ImageInfo and SnapInfo types
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 09:43:15 -04:00
John Mulligan 96396d4fca rbd: temporarily disable revive caring about RBDError stuttering
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:56:49 -04:00
John Mulligan 4f2fc34445 rbd: add revive comments for disabling check on backwards-compat vars
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:15:24 +01:00
John Mulligan 149827c4e2 rbd: add doc comments to error values
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:15:24 +01:00
John Mulligan 5a35fc8643 rbd: add doc comment to error type
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:15:24 +01:00
John Mulligan 002ffc8c91 rbd: doc comments for Seek constants
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:15:24 +01:00
John Mulligan 560d6ccd2c rbd: properly format the doc comment for Copy2
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:15:24 +01:00
John Mulligan fa3bce7234 rbd: hide ioctx.Pointer incantations in a function
A previous change improved our use of pointers such that go vet no
longer had an issue with these lines but if we ever need to change the
interaction between rbd and rados like that again we can now rely on a
single call site `cephIoctx` that will return our ceph/c type given the
public Go-language level type from the rados pkg.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 09:02:53 +01:00
John Mulligan 1abd1423c1 rbd: prevent a go vet error by doing type-casting in C
The void * is (ab)used in C for passing arbitrary data to the callback,
which in our case is a integer index. However, Go tools can not tell
this is OK and throws an error running go vet. Change the wrapper
function to take a uintptr_t and cast that to void* only in the
(unchecked) C layer.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 09:02:53 +01:00
John Mulligan 6b396f70b2 errutil: move errutil pkg into internal subdir
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>
2020-03-10 08:41:44 +01:00
John Mulligan d9ce9ad799 rbd: add well-formed doc comments to the rbd snapshot functions.
No functionality change, just comments.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-10 07:47:59 +01:00
John Mulligan 4fc730ad39 rbd: move snapshot test funcs to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-10 07:47:59 +01:00
John Mulligan f0dba686df rbd: move snapshot related functions to a snapshot.go file
No functionality change. Move various snapshot related functions to
their own file. This helps logically group these related funcs in one
place.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-10 07:47:59 +01:00
John Mulligan 9841283344 rbd: add DiffIterate wrapper for rbd_diff_iterate2
The DiffIterate call accepts a data structure argument containing the
parameters of the image to "diff" and a callback function. This callback
is called in the C code, making use of the recently added callbacks
helper.

The callback itself is called with the offset and length of the
differing area in the image as well as a data parameter so that
a common function can distinguish or update different data for
different calls if needed (compare to a void* in C).

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-04 08:10:48 -05:00
Niels de Vos d0943906f7 rbd: add minimal support for listing watchers on an RBD image
Checking if there are other clients interested in changes to an RBD
image is important for certain actions. For example, the Ceph-CSI
project would not want to remove an image in case it is still mounted
somewhere.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-26 13:04:25 -05:00
Niels de Vos a65e39ca3d rbd/features: add test for FeatureSet
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos d6a88f65b7 rbd/features: add FeatureSet for mapping features between bits and names
Applications will mostly want to show names of features to their users,
and not just a few bits. With the FeatureSet functions it becomes simple
for applications to map the name of a feature to bits, and the other way
around

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos e671d63892 rbd: add support for RBD_FEATURE_MIGRATING in Nautilus
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos 368ed4d838 rbd: add support for RBD_FEATURE_OPERATIONS in Mimic
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos 897c4b8683 rbd/features: add test for Image.UpdateFeatures
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos 6284986e01 rbd/features: add Image.UpdateFeatures()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos 20031cf70f rbd/features: add test for Image.GetFeatures()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00