Commit Graph

584 Commits

Author SHA1 Message Date
John Mulligan a50c60be49 rados: add a more direct argv config wrapper ParseConfigArgv
Previously, ParseCmdLineArgs was the function directly wrapping the
ceph rados_conf_parse_argv function. This function has the improper
(IMO) behavior of assuming you didn't know your own argv[0] and just
always stuck "placeholder" in argv[0]. This function adds a more
direct wrapper ParseConfigArgv that allows the caller to pass an
full argv, and they can put any placholder value desired if they want.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan 8b16f804a3 rados: add error for function args that must have data
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan 08bb0096c4 rados: convert ListPools to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan bfe4adfd2d rbd: convert ListChildren for mimic to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 2a62588181 rbd: convert NamespaceList for nautilus to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 4d2d6493af rbd: convert GetImageNames for mimic to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 3d5741301d rbd: convert uses of split function to use cutil.SplitSparseBuffer
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan e5d1a53060 cutil: add SplitBuffer and SplitSparseBuffer helper functions
Add SplitBuffer and SplitSparseBuffer functions for extracting a list
of strings from a single buffer, typically returned in C code, from
a single Go buffer. The SplitBuffer variant will return empty strings
if multiple nulls are found in sequence, assuming that the C code
packs data between on single null byte (expect the final byte).
The SplitSparseBuffer variant assumes that the C code may not
tightly pack the data with single null bytes and thus will not
return any empty strings (unless the input buffer is empty
or only contains nulls).
Most of the code in the go-ceph codebase is doing the latter but
probably should have been doing the former. Thus both approaches
are provided.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 16:38:39 -04:00
John Mulligan 97732ac885 rbd: add a UpdateWatch test case with multiple watches and go channels
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 13:19:57 -04:00
John Mulligan f3f2180e66 rbd: add Watch type and watch callbacks support
Add UpdateWatch function implementing rbd_update_watch.
Add Unwatch function implementing rbd_update_unwatch.
Add a higher level Watch type to encapsulate watching
the image and the watch handle.
Add basic tests to validate the callback behavior.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-23 13:19:57 -04:00
John Mulligan d3f8f0cf70 cephfs: add StatFS implementing ceph_statfs
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-20 13:36:53 -04:00
Sven Anderson 8b45a01b7d cephfs: make CephFSError type unexported
In order to avoid external dependencies on implementation details,
this change replaces CephFSError with the unexported cephFSError. 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>
2020-07-17 13:47:32 -04:00
Sven Anderson e77ecf68f6 rados: make RadosError type unexported
In order to avoid external dependencies on implementation details,
this change replaces RadosError with the unexported radosError. 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>
2020-07-17 13:47:32 -04:00
Sven Anderson 6c944e8b65 rbd: make RBDError type unexported
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>
2020-07-17 13:47:32 -04:00
John Mulligan 5ee762c586 testing: update container packages before installing new ones
On octopus taking in the -devel packages causes *some* of the packages
to be updated but not all. This apparently makes ceph-fuse fail to
start correctly by blocking forever. This works around that issue.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-07 13:26:04 -04:00
Niels de Vos d4440eb8c2 rbd: add simple test for Image.GetModifyTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 491f7827a8 rbd: add Image.GetModifyTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 048ed11e63 rbd: add simple test for Image.GetAccessTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 0d9f802732 rbd: add Image.GetAccessTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 8ef910e0c5 rbd: add simple test for Image.GetCreateTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos 5b45db6803 rbd: add Image.GetCreateTimestamp()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
Niels de Vos c4714165a6 timespec: move to internal pkg
There are functions from librbd that can use the Timespec type too.
Instead of consuming 'cephfs.Timespec' in the rbd package, create an
internal type that can be exposed through both packages.

This looks a bit like duplication, but it does not break the current
users of Timespec in the cephfs package.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-22 09:22:18 -04:00
John Mulligan 3a0bacb039 makefile: remove check-ceph-version which is no longer neeeded
The per-ceph-version buildfiles remove the need for this rule.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-16 16:02:13 -04:00
John Mulligan d213fb3e02 makefile: pass -tags to go test lines too
I noticed that the make target I use for smoke testing things locally
was failing due to new octopus related vars. This was due to the go test
lines in the makefile not passing tags for the maximum ceph version.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-16 16:02:13 -04:00
John Mulligan 610c37f05e makefile: remove trailing whitespace
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-16 16:02:13 -04:00
John Mulligan 38e9b9a260 makefile: automatically select docker or podman container tools
After having forgot to explicitly pass CONTAINER_CMD for the millionth
time I figured copying ceph-csi a smidgen and automatically selecting
podman or docker based on availability would be save me some typing.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-16 16:02:13 -04:00
John Mulligan 68f8ce2fee makefile: support using multiple base images at one time
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-16 16:02:13 -04:00
John Mulligan 3a561218d4 cephfs: add Rename function
Rename, it does what it says on the tin. Tests included.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-15 13:59:27 -04:00
Mudit Agarwal 3c416e264a rbd: minor fixes in error.go
1. Generalize the message for ErrNoIOContext
2. Fixed a typo

Signed-off-by: Mudit Agarwal muagarwa@redhat.com
2020-06-15 13:43:26 -04:00
Mudit Agarwal 5b6c599176 rbd: add wrapper for rbd_namespace_list() function.
Added wrapper for rbd_namespace_list() function which returns the names of all the namespaces
present for a given IOContext.

Signed-off-by: Mudit Agarwal muagarwa@redhat.com
2020-06-15 13:43:26 -04:00
Mudit Agarwal 08536b9d93 rbd: add wrappers for rbd_namespace_create(), rbd_namespace_exists() and rbd_namespace_remove().
rbd_namespace_create() function creates namespace for a given iocontext.
rbd_namespace_exists() function checks whether the given namespace exists or not.
rbd_namespace_remove() function removes the given namespace.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-15 13:43:26 -04:00
Mudit Agarwal 7be8bbfe81 rbd: additional error checking in GetPoolMetadata, SetPoolMetadata and RemovePoolMetadata
added a check to validate ioctx in all the three *PoolMetadata functions

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-15 13:20:37 -04:00
John Mulligan 624230cdbd cephfs: add Fsync and Sync calls for open files
Add wrappers for ceph_fsync. The Fsync call directly wraps ceph_fsync
which provides options to behave more like fsync or more like fdatasync.
Add Sync, a simpler wrapper over Fsync, to match any interfaces that
make use of `File.Sync` from Go's os package.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-11 11:21:11 -04:00
Niels de Vos ec822aa3a9 rbd: add error checking in CreateImage()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Niels de Vos 3fc893bc0f rbd: add error checking in RemoveImage()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Niels de Vos 9e7a1c444f rbd: add error checking in OpenImage*() functions
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-11 10:42:57 -04:00
Mudit Agarwal a2c1c2bb34 rbd: add wrapper for rbd_pool_metadata_remove()
Add wrapper for rbd_pool_metadata_remove() function which removes pool
metadata associated with a given key.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Mudit Agarwal d999f78e2e rbd: add tests for GetPoolMetadata() and SetPoolMetadata()
Added test cases for GetPoolMetadata() func and SetPoolMetadata() func.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Mudit Agarwal 7b56123e17 rbd: add wrapper for rbd_pool_metadata_set()
Add wrapper for rbd_pool_metadata_set() function which sets pool metadata
associated with the given key.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Mudit Agarwal f88a17dc64 rbd: add wrapper for rbd_pool_metadata_get()
Add wrapper for rbd_pool_metadata_get() function which returns pool metadata
associated with the given key.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
2020-06-10 11:58:51 -04:00
Niels de Vos 6c5364f422 rbd: add RBD_IMAGE_OPTION_MIRROR_IMAGE_MODE for Octopus
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-09 08:54:33 -04:00
Niels de Vos 8235827b5a rbd: add RBD_IMAGE_OPTION_CLONE_FORMAT for Nautilus
Fixes: #295
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-09 08:54:33 -04:00
Niels de Vos ba93f46cb4 rbd: add RBD_IMAGE_OPTION_FLATTEN for Mimic
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-06-09 08:54:33 -04:00
John Mulligan b76c077b3c workflows: on octopus test runs archive the 'implements' output
Only octopus containers will have castxml available for now.
Conditionally grab the files generated by 'implements' and
make it available for later examination.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-05 11:35:03 -04:00
John Mulligan 7bec335c31 containers: add castxml to container if it is available
Currently, this tool is only readily available on centos8 based
containers (octopus). But as it is being requested by binary name
it will be taken in if any repo used by the container makes it
available.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-05 11:35:03 -04:00
John Mulligan 792f8cf02b entrypoint: get api implementation coverage when possible
When castxml is available, run the implements tool to generate
text and json implements output that can be later examined to
see what go-ceph does and does not cover in the ceph apis.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-05 11:35:03 -04:00
John Mulligan a4785fceb6 implements: add cli arguments to run multiple reports if requested
Add new arguments to 'implements' that allow for specifying one or more
report type and either a dash ('-' meaning stdout) or a file name to
control where the report is written.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-05 11:35:03 -04:00
John Mulligan 3e15044962 implements: add io.Writer argument when creating text report
This io.Writer will be the destination for writes from the report.
This better matches with what the JSON report was doing.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-06-05 11:35:03 -04:00
Sven Anderson 217e502afa rbd: add better error when attempting to remove opened images
Signed-off-by: Sven Anderson <sven@redhat.com>
2020-05-28 08:49:35 -04:00
John Mulligan 861747663b rados: test functions for MonCommandTarget
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-05-27 13:38:07 -04:00