After discussion we decided to entirely drop logging from the library.
Future users should rely instead of the error types and values the
function calls return.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Translate the return value (errno) from the C rbd_*() functions into the
standardized strerror() error message.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Revive is a tool similar to golint but can be configured. Add an initial
configuration for revive.
This configuration reduces the initial issue list to something more
manageable and that can be worked on incrementally rather than trying to
boil to ocean to make the checker happy.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Make it possible to easily validate the *Image and *Snapshot objects
before using them. This makes the use of go-ceph for RBD functions more
stable, and it is less likely that incorrect use causes Go panics.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
The package imports in doc.go were not accomplishing anything and also
were not complete (missing cephfs). This removes them.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Make the doc comment in doc.go a bit more fleshed out with pointers
to the real functionality of the library.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Oddly, probably a historical artifact, the .go files in the root of the
go-ceph tree were named "rados". As rados is one of our sub-packages it
seemed more correct to call the package "ceph". This was chosen as
"go-ceph" is not a valid identifier in go and since this is already go
code prefixing with "go" seems a bit redundant.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This allows to set additional options while creating RBD images.
Ceph-CSI will initially consume this to configure an optionally
different pool for data.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
There are several RbdImageOptions that can be used to configure features
of an RBD image while creating, cloning, migrating and copying. A
follow-up patch will add Create4() where the RbdImageOptions can be
used.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Prepare for adding support for RbdImageOptions with
RBD_IMAGE_OPTION_FLATTEN that has been introduced in Ceph Mimic.
Nautilus is the most recent supported versions, so use that for testing.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
The C library offers rbd_create2() and rbd_create3() and does not try to
cover all options with rbd_create(). For users that are familiar with
the C API, the Create2() and Create3() functions have been added.
The existing Create() API still handles the complete set of
rbd_create*() functions, so backwards compatibility is covered.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Previously, the tests were shelling out to run 'uuidgen' which
is not particularly efficient and a bit ugly. Switch this test
to use the same uuid library already in use by the rados test code.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This change replaces a couple of functions from the "assert" package
with the corresponding functions from the "require", where the
following code relies on a non-nil object.
Signed-off-by: Sven Anderson <sven@redhat.com>
According to the 'go test' help, "The idiomatic way to disable test
caching explicitly is to use -count=1." This removes GOCACHE=off in
favor of using -count=1 as GOCACHE=off breaks other tooling including
the use of go modules.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Adds cli parsing to the entrypoint script allowing for:
1. Custom path to micro-osd script
This allows easier testing of the script itself or quick
and dirty customization for special one-off tests
2. Selecting tests to run (or "ALL" or "NONE")
This allows the user to run only a subset of the tests as needed.
3. Option to pause indefinitely after tests complete
This keeps the containerized environment alive after tests
have run for debugging or just for creating a quick and dirty
ceph environment for playing around.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Fedora based distributions don't use AppArmor but SELinux instead.
This change detects the distribution and sets the --security-opts
accordingly.
Signed-off-by: Sven Anderson <sven@redhat.com>
Release resources that are allocated while configuring the connection to
the cluster. rados_shutdown() should only be needed after a successful
call to rados_connect(), however if the connection has been configured
with non-default parameters, some of the parameters may be allocated
before connecting. rados_shutdown() will free the allocated resources,
even if there has not been a connection yet.
Note that the finalizers get executed during garbage collection, which
can be forced by calling runtime.GC() for testing.
Fixes: #109
Signed-off-by: Niels de Vos <ndevos@redhat.com>
When running 'make test-docker' on Fedora with SElinux in Enforcing
mode, fetching dependencies for the project fails. It seems the volume
is not accessible to the container. Enabling SElinux for the volume (by
passing the :z flag) makes it work.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
A blocking message is shown when running 'make test-docker':
STEP 6: RUN add-apt-repository ppa:gophers/archive
Co-installable packages of Go 1.4 through 1.11 for supported versions
of Ubuntu -- currently Trusty, Xenial, Bionic, Cosmic and Disco.
Installing golang-1.X installs the latest point release of Go 1.X. I add
the odd patch to keep older versions of Go building with new toolchains,
but I do *not* make any effort to backport security fixes to Go releases
that are not supported by upstream. Buyer beware!
I aim to start uploading a release when its first beta is released, so
e.g. I uploaded a golang-1.7 package after 1.7 beta 1 was released. But
I don't always keep up with this.
So that these packages can be co-installable, they do not install
anything to /usr/bin. Once you have installed the golang-1.X package,
you will need to add /usr/lib/go-1.X/bin (or maybe /usr/lib/go-tip/bin)
to your $PATH, or you can just invoke /usr/lib/go-1.X/bin/go directly.
The packages all Recommend: appropriate versions of the runtime race
detector support on amd64, which are also built in this PPA
(eventually).
More info: https://launchpad.net/~gophers/+archive/ubuntu/archive
Press [ENTER] to continue or ctrl-c to cancel adding it
By passing the -y switch to add-apt-repository, this message is ignored
and the process continues.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Add ceph nautilus to the test matrix as well as simplifying the setup
script in the travis yaml file.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Apparently 'rados mkpool' and 'rados rmpool' no longer function when
using nautilus.
Switch to ceph osd pool subcommands.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
When tests are run generate a coverage report.
To access this coverage report mount any directory to /results in the
container. Coverage output files will be written to /results/coverage
w/in the container.
Later we can do other interesting things with the coverage detected
such as a test pass/fail criteria or submitted to a service such as
coveralls, etc.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add new variables to the Makefile that allow the use of other container
runtimes (that have a docker compatible cli) and allow setting extra
opts to work on platforms that don't run apparmor.
All defaults continue to be the same as before.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit adds the following cephfs functions:
* Unmount // Unmounting is necessary to cleanup mounts
* Release // Release destroys the cmount ~ end of transaction
* RemoveDir // inverse of MakeDir
* Chown // change ownership of file or directory
* Chmod // change permissions of file or directory
Tests are included for each function.
In addition to these changes modifications to:
.travis.yml, Dockerfile, and Makefile
were made to accomodate tests to mount the ceph volume. Tests use
fuse to mount the volume which requires adding:
--device /dev/fuse --cap-add SYS_ADMIN --security-opt \
apparmor:unconfined
to the docker container (alternatively --privileged works but adds
additional permissions).
Changes to README add the above docker changes as well as point
users to the necessary ceph development libraries.
* CephError uses syscall for string version of error
* Add error logging for every function
* Add RemoveDir() function
* Add Unmount() function
* Add Release() function
* Add Chown() function
* Add Chmod() function