Commit Graph

397 Commits

Author SHA1 Message Date
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
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
John Mulligan
fa5bb0fd69 cephfs: add GetFsCid to implement ceph_get_fs_cid
This function can be used to uniquely id the file system that the
mount object is connecting to.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-24 10:18:48 +01:00
John Mulligan
8948b20f5a cephfs: add MountWithRoot to implement the root arg to ceph_mount
The existing Mount() method did not provide a way to access the root
path argument to ceph_mount. This new function allows the caller to
specify an alternate root dir for the mount.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-24 10:18:48 +01:00
Sven Anderson
d2e8f936b2 rbd: fix some tests that ignore error results.
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-02-21 13:23:47 -05:00
John Mulligan
9b53a23d14 docs: document the release process
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-17 09:44:18 -05:00
John Mulligan
522142665b cephfs: improve doc comments for mount, unmount, release funcs
Try to improve the doc comments for clarity and less redundancy.
Add "implements" subsections for the three functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-17 08:22:04 +01:00
John Mulligan
0c1b895566 cephfs: add doc comments to error type and func
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-17 08:22:04 +01:00
John Mulligan
dc289754c8 readme: update doc link to pkg.go.dev
The older godoc.org encourages the user to use pkg.go.dev instead.
Change our link to point directly there (and use https).

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-13 07:28:33 +01: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
Niels de Vos
58b4237aa9 travis: pass CEPH_VERSION as argument to 'docker build'
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-12 13:48:21 -05:00
Niels de Vos
86a3a66849 tests: parameterize Ceph version for container build and build-tags
Pass `CEPH_VERSION=minic` (or 'luminous') on the `make test-docker`
command to select building a container with a different Ceph version and
running the tests in it.

This passes the given CEPH_VERSION on to the `docker build` command as a
--build-arg, which gets used for selecting the Ceph repository during
container build.

It also sets the environment variable CEPH_VERSION, which in turn is
consumed by `entrypoint.sh` to set the `go build -tags ${CEPH_VERSION}`
option that includes/excludes certain *.go files.

See-also: https://golang.org/pkg/go/build/#hdr-Build_Constraints
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-02-12 13:48:21 -05:00
Niels de Vos
7e3a5850f3 README: add requirement for build-tags when using non-current Ceph libraries
In order to selectively exclude/include certain .go files while building
and testing with the standard `go` tools, build-tags can be used.
Because go-ceph aims to support multiple Ceph versions, some functions
might not be available in the C libraries, or have been marked
deprecated in the header files. By selectively excluding/including some
of the .go files, warnings and errors can be prevented.

See-also: https://golang.org/pkg/go/build/#hdr-Build_Constraints
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
ea016c420a makefile: add targets for test binaries
The go test command's -c switch builds the test binary but does not
execute it. It is convenient to do quick compile checks of the libraries
and test code at once without having to bring up the ceph instance in
the test container. This change allows one to run 'make test-bins' or
'make rbd.test' to compile but not run the test & library code.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-12 08:35:22 +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
2240c56614 cephfs: update TestCreateMountWithId to check custom id is used
Now that we have mds command function, we can use it to check for the id
we passed to CreateMountWithId appears in the session list.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 14:01:33 +01:00
John Mulligan
34f1507992 cephfs: add wrapper funcs for ceph_mds_command
Adding a wrapper for ceph_mds_command allows the client to make
queries against the mds server.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 14:01:33 +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
2f7493bed1 entrypoint: make var references consistently use curly braces
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
ee2c26906e entrypoint: support disabling code coverage
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
b7ea1de2e2 entrypoint: add options to run cpu and mem profiling on tests
Add options --cpuprofile and --memprofile which enables the respective
profile options for the go test command.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
7d12f0bbcd entrypoint: highlight important commands in script output
Add a small wrapper function 'show' that prints a prefix and the
command that will be run. Helps the reader jump to important parts of
the script output.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
7790594ee4 entrypoint: fix pausing after test failure
The --pause option for the entrypoint script is useful for interactive
debugging after a test failure, but the script was not pausing if the
test suite failed. Add code to explicitly handle test failures including
pausing.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
691cd8d99b entrypoint: move pre- and post- test code into functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
3ca24f63c5 entrypoint: move go test setup an invocation into a function
A little refactoring to move the setup of the pkg test calls into a
function to ease future changes.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
25bd9f0bed entrypoint: wrap main code in a function
As preparation for upcoming changes, move the main code of entrypoint.sh
into functions. Best viewed by ignore whitespace.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 09:22:03 +01:00
John Mulligan
176e6cc198 rados: fix doc comments for object iter related functions
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>
2020-02-11 08:51:07 +01:00
John Mulligan
9efbfd8518 rados: move object iter(ation) related functions into their own file
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>
2020-02-11 08:51:07 +01:00
John Mulligan
970300d25a rados: fix doc comments for omap related functions
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>
2020-02-11 08:51:07 +01:00
John Mulligan
f29d760894 rados: move omap related functions into their own file
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>
2020-02-11 08:51:07 +01:00
John Mulligan
f1f46a95bf rbd: replace most uses of Create in rbd test suite
Replace most uses of Create() in the rbd test suite with a wrapper
around CreateImage named quickCreate. quickCreate retains most of
the argument signature of Create for easier refactoring of the tests
over time. New uses of quickCreate should not be added to the suite if
you can help it.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
bd0b8d5678 rdb: disentangle and update TestImageCopy function
Update the TestImageCopy function to establish clear subsections and use
the new CreateImage and OpenImage functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
4691e0cb4c rbd: update TestReadAt to use new approach for create & open
Update the TestReadAt function to use the new CreateImage and OpenImage
functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
1842bd74e6 rbd: in TestRemoveImage ensure options are destroyed
The resources of the rbd image options must be cleaned up or we leak.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
fc29c7f30a rbd: replace repeated "magic" literal values with vars
Throughout rbd_test.go the values of 1<<22 and 22 are repeated when
created rbd images. For the common cases, replace these with variables.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05: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
13028061e7 rbd: update tests to use new open image functions
Replace uses of the deprecated img.Open(...) pattern with the new open
image functions where applicable.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00
John Mulligan
0239a8469d rbd: update test case for "old" deprecated open
Rename test case to mark the "old" deprecated open func as such.
This also adds a missing bit of coverage to the test.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-31 14:32:38 -05:00