Commit Graph

589 Commits

Author SHA1 Message Date
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
5b76299c40 entrypoint: allow configuring ceph config source
This further improves the ability to use the script outside the
container itself and against alternate ceph cluster configs.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-20 11:06:25 +01:00
John Mulligan
953a22bd12 rados: temporarily disable revive caring about RadosError stuttering
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:56:49 -04:00
John Mulligan
2e5a2c3b9e cephfs: temporarily disable revive caring about CephFSError stuttering
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-17 09:56:49 -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
3f92504a00 travis: enable testing with ceph "octopus"
Currently there's no container image named "octopus" but its imminent.
Once ceph container starts tagging images with "latest-octopus" we
should switch to that.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
1bd65c6f20 rados: fix test for mon command with input buffer on ceph octopus
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>
2020-03-12 13:33:16 +01:00
John Mulligan
01b38c2e42 testing: move ubuntu xenial based Dockerfile to a subdir
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
825f07583e makefile: use ceph based containers by default
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
a61cc3f13d testing: add Dockerfile based on ceph containers
Ceph containers [1] are built by the ceph team and for our purposes,
only lack build tools and Go making the delta we need to do smaller.

1: https://github.com/ceph/ceph-container

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
e1cab82587 makefile: support selecting alternate container builds
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
86945c70db travis: use makefile rules in travis configuration
Instead of duplicating some of the actions in the travis yaml file and
the Makefile, have travis rules make use of the Makefile.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
68cdcc3b4e makefile: add rules for explicitly creating the ci container image
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
0b6bc6e4dd travis: update to use bionic for travis
Our use of the base os is pretty minimal as the tests mainly rely on
what happens inside the container. Might as well not use something old.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 13:33:16 +01:00
John Mulligan
3afcc68ac7 entrypoint: enable go vet checking on packages
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-12 09:02:53 +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
754d744ac8 rados: return an unsafe.Pointer from ioctx Pointer call
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>
2020-03-12 09:02:53 +01:00
John Mulligan
944510bd8c entrypoint: add a --results option for alternate results dir
This can be useful when running the script outside of the
container or doing other sneaky things. :-)

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-11 13:31:22 +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
33422fc2cb cephfs: add SetConfigOption and GetConfigOption functions
These are implemented similarly to the rados equivalents.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-10 08:15:16 +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
John Mulligan
b3f7c6af15 callbacks: create a helper type for managing callbacks between C and Go
As per the Go Wiki page on cgo [1] passing callback with data between C
and Go is non-trivial due to the pointer passing rules [2]. This change
creates a new helper type, based on the examples on the wiki, that uses
opaque indexes to exchange between C and Go.

For now, this type is simple as we're only going to have a few callbacks
initially but this could easily be improved and made more general in the
future as needed. Because we anticipate having to use this type in all
of our core packages (rados and cephfs as well as rbd) we are creating
the type in an "internal" package so that we don't treat the new type
as public despite the capitalized method names.

[1]: https://github.com/golang/go/wiki/cgo
[2]: https://golang.org/cmd/cgo/#hdr-Passing_pointers

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