As rbd.go is very long, and the get-/set-/remove- metadata functions in
rbd.go make a nice logical unit, move them to a new metadata.go file.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>