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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
These functions wrap rados_mon_command_target and allow the user to send
"command JSON" to specific MONs.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
These private functions with names like monCommand and pgCommand were no
different from the public xxxCommandWithInputBuffer commands. Thus the
redundant private functions are removed to simplify the file. As private
functions these can be added back later w/o fuss if the behavior of
the xxxCommand and xxxCommandWithInputBuffer calls need to differ more
in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>