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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add options --cpuprofile and --memprofile which enables the respective
profile options for the go test command.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Update the TestImageCopy function to establish clear subsections and use
the new CreateImage and OpenImage functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
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>
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>
Replace uses of the deprecated img.Open(...) pattern with the new open
image functions where applicable.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
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>
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>
When building the container image for running tests take the older of
the two current releases from Go upstream. We use the older version
in order to make sure we are testing with something supported but maybe
not everyone is on 1.13 yet.
This also enables the use of go modules to ensure we get the proper
versions of dependencies.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
RadosError-prefixes are not recommended, instead just Err as prefix is
used.
Also, errors are constants, not variables.
For existing users, backwards compatible constants are available. These
will need to be removed in a future go-ceph release.
Signed-off-by: Niels de Vos <ndevos@redhat.com>