Commit Graph

94 Commits

Author SHA1 Message Date
Mudit Agarwal
7a387654c5 rbd: remove deprecated fields from ImageInfo struct
Corresponding fields for Parent_pool and Parent_name have been deprecated from
ceph's rbd_image_info_t stuct, removing the same from go-ceph's ImageInfo struct.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-08-04 12:48:01 -04:00
John Mulligan
3d5741301d rbd: convert uses of split function to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
Sven Anderson
6c944e8b65 rbd: make RBDError type unexported
In order to avoid external dependencies on implementation details,
this change replaces RBDError with the unexported rbdError. In case
some application really needs access to the integer value, it can use
the pattern
  var errno interface{ Errno() int }
  if errors.As(err, errno) { ... errno.Errno() ... }

Signed-off-by: Sven Anderson <sven@redhat.com>
2020-07-17 13:47:32 -04:00
Niels de Vos
5b45db6803 rbd: add Image.GetCreateTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos
ec822aa3a9 rbd: add error checking in CreateImage()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Niels de Vos
3fc893bc0f rbd: add error checking in RemoveImage()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
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
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
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
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
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
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
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
Niels de Vos
8b58ab92c4 rbd: move features to its own file
By splitting up the features from the main rbd.go file, it becomes
easier to support new features added by newer versions of Ceph.

This also drops the Rbd-prefix from the constants, and adds backwards
compatible references.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-24 16:28:03 -05:00
Niels de Vos
80dc7c279b rbd: replace deprecated rbd_list_children() with rbd_list_children3()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-12 13:48:21 -05:00
Niels de Vos
92fc7ac0bf rbd: replace deprecated rbd_get_parent_info() with rbd_get_parent()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-12 13:48:21 -05:00
Niels de Vos
efe2f6b97c rbd: replace deprecated rbd_list() with rbd_list2()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-12 13:48:21 -05:00
John Mulligan
c662d6fb2e rbd: add CloneImage as a wrapper for rbd_clone3 func
Add a new CloneImage that makes use of rbd_clone3 and thus behaves like
the new CreateImage function.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-12 14:59:47 +01:00
John Mulligan
f72828c5b2 rbd: add OpenImageById and OpenImageByIdReadOnly functions
Add OpenImageById and OpenImageByIdReadOnly that wrap rbd_open_by_id and
rbd_open_by_id_read_only respectively.
The added test case can not currently test trivial error conditions due
to a known bug in ceph, these tests are skipped for meanwhile.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 19:54:58 +01:00
John Mulligan
a1f2aefcf9 rbd: add GetId wrapper for rbd_get_id function
Add a GetId function to the Image type that will fetch the id of the rdb
image. Comes with a test case.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 19:54:58 +01:00
John Mulligan
dd041586ba rbd: rename error handling helper func to make it private
Similar to recent changes for rados (df46476e) there is no good reason
for the errorno to go-style error function to be exported from the
package. Decapitalize it.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 10:01:25 +01:00
John Mulligan
2a74b02c2b rbd: create a standalone RemoveImage function
Currently, the code only provides a .Remove function on the Image type.
But this is unnecessary as the underlying api only requires an io
context and name. Make a function that matches the underlying api
better.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
635ca3cdb2 rbd: rename Create4 to CreateImage
In the future, CreateImage should be the canonical way one creates an
rbd image. Like the underlying ceph apis CreateImage does not return an
Image, only an error code. Open image handles should be acquired through
the OpenImage functions.

Because Create4 was fairly recently added to library there should not be
consumers in the wild. Thus we don't retain the current version for
backwards compatibility.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
674d0e4041 rbd: reimplement Image Open function in terms of simpler functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
20a458a614 rbd: add new more idomatic functions for opening rbd images
Create new OpenImage & OpenImageReadOnly functions to replace the use of
Open() on image types. This function more closely matches the underlying
of the librbd function calls.

The third argument to the functions is a snapshot name but we also
create a new constant to clearly indicate that an image should be opened
w/o a snapshot. Internally, this also ensures that a null string is
passed to the C api.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
Niels de Vos
522182cbc3 rbd: Read() should return io.EOF on short reads
The case of a short read is not detected correctly. This causes Read()
to not return io.EOF where it is expected.

By comparing 'len(data)' instead of unassigned 'n' (set to 0), the
number of bytes that have been read can be compared to the number of
bytes that were requested.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-01-23 08:05:34 +01:00
Niels de Vos
508f808017 rbd: WriteAt() should return io.EOF on short reads
The case of a short read is not detected correctly. This causes ReadAt()
to not return io.EOF where it is expected.

By comparing 'len(data)' instead of unassigned 'n' (set to 0), the
number of bytes that have been read can be compared to the number of
bytes that were requested.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-01-22 16:48:18 +01:00
John Mulligan
66acf226dc rbd: improve doc comment style for locking functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00
John Mulligan
0e3b60b14d rbd: improve doc comment style for ListChildren
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00
John Mulligan
f7cfbac80c rbd: improve doc comment style for flatten
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00
John Mulligan
8253568174 rbd: improve doc comment style for copy functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00
John Mulligan
f671a8f8e5 rbd: improve doc comment style for various image status calls
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00
John Mulligan
98d1543070 rbd: improve doc comment style for resize
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00
John Mulligan
317feb322a rbd: improve doc comment style for close
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-21 17:21:10 +01:00