Remove the logic previously ported over to internal/commands and just
leave the functions in place as to not have to excessively touch the
existing code.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Now that we have shared support working with "command json" we attempt
a minimal conversion, using aliases where appropriate, to the
new commands.Response type.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The json key sent to retain snapshots on subvolume remove was misspelled
and had a dash in it rather than an underscore. Fix the incorrect key
and add a test, that needs to be able to run on version of cephfs w/o
snapshot retention, and verifies that flag does the correct thing.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Now that the new year has arrived this test assertion has started to
fail. This is because, although I anticipated the year would eventually
change and used GreaterOrEqual, the argument order is wrong. My excuse
is that I find the argument order in testify's Equal function confusing,
it causes me to assume other functions in testify are also confusing
(even when it's the "normal" order) and/or I copy and pasted from an
Equal line and didn't change the args (both are true!).
Instead of allowing any old year, we assume that the clocks where the
test are run are in sync enough that the current year is correct for
the assertion (thanks for the suggestion Sven).
Happy new year, go-ceph!
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This flagSet type allows the user to also set the value of the retain
snapshots flag, something unique to subvolume removal (all others had
the force flag only).
Signed-off-by: John Mulligan <jmulligan@redhat.com>
To prepare for multiple flags types, we create a flagSet interface and
break out the functionality that was in Update into a per-type method
and then the common "merger" function.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Due to a new ceph nautilus the workflow test was breaking because the
existing code failed to anticipate the "subvolume uuid" in the path
to the snapshot data. This is the curse of writing code without anything
to test it against. I also add a very short delay just to give us
a chance to avoid issues in the future in case the snapshot creation
is not quite synchronous.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Apparently, this feature is being removed from all active ceph versions
and will not be present in future versions. Since we won't be able to
test it any more, and the api is provisional still, we just remove it
entirely.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This doesn't touch every call in cephfs admin, but does try to act like
a real application, or set of applications would: reading and writing
data as well as using the api to create and manage subvolumes,
snapshots, and clones.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Some versions of ceph return a list of supported features for a
subvolume. On versions that don't return this field the list will always
be empty.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
For users who need to know the pools (by name) as well as the files
systems, we add ListFileSystems which is similar to 'ceph fs ls', rather
than the existing ListVolumes as that function is simlar to 'ceph fs
volume ls' and that does not return pool information.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Return not implemented errors when "older" versions of ceph return
formatted text for output instead of JSON, even tho we asked for json.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Rather than compile things in and out, which really should only be for
the client version of the ceph libs, add vars that tests can use to
check the server. Also, a "sentinel" test is added to make sure the
tests are being fed a version it understands.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Previously, I was sort of abusing the build tags system to just get our
tests working. That was incorrect because you could be building go-ceph
against nautilus libs but using an octopus server and vice versa. In
addition, I've learned that some of the snapshot and clone behaviors are
being changed as items are backported in ceph. This means that build
tags themselves are not good indicators of what a particular version of
ceph supports.
This patch is the first step to removing these restrictions and making
cephfs admin work more smoothly across more versions of ceph.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This test is added after we add force delete functions as deleting a
canceled clone requires a force remove function.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The response type simplifies the error handling as a "pipeline" of
checks that are applied one after another.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add the new to octopus call for subvolume snapshot info. Two fields
appear to return strings "yes"/"no", so could possibly have been
converted to booleans. In the chance that other string values get
returned and simplicity I left them as strings. If we need to, we can add
convenience funcs to return bools later.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a SubVolumeInfo function that works like the `ceph fs subvolume
info` command. This function returns a SubVolumeInfo type from parsing
the response JSON.
In order to re-use the existing QuotaSize type, which is an interface
and thus can't be unmarshaled directly, we use a non-exported wrapper
type for the unmarshaling and then we fix up the BytesQuota field so
that users of the library don't need to directly deal with the quota
size placeholder type, which can unmarshal the value.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The date & time format used by ceph differs from the default used by Go
for time.Time types. Define a new type, embedding time.Time, that can
parse and expressing date+time strings the ceph way.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a new quotaSizePlaceholder type which is a non-interface type that
can unmarshal JSON with a varying type into one of our types that meets
the QuotaSize interface.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This clarifies what the size values are for when this interface is used
and hopefully clarifies what the size actually does to a subvolume. This
also generalizes the type a bit in preparation for it being used in
other upcoming functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The SubVolumeGroupPath function maps the subvolumegroup to a path from
the root of the cephfs, and works like `ceph fs subvolumegroup getpath
...`.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The SubVolumePath function maps the subvolume to a path from the root
of the cephfs, and works like `ceph fs subvolume getpath ...`.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The EnumerateVolumes function returns a list of Name & ID pairs,
to identify the file systems in the cluster. The enumeration is based
on `ceph fs dump` like JSON, but for implementation only. The dump
feature itself is not currently exported in a raw form.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Some of the queries we need to make are not mgr commands but (still?)
mon commands. Extend the interface and helper funcs to support issuing
mon commands.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Removes some old reminder comments.
Adds doc comments with the keyword "Similar To" followed by block quoted
text that shows a cli command the function will behave similarly to.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The environment variable to turn on tracing will now be parsed using
strconv.ParseBool rather than just a quick-n-dirty str compare.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The volume status command does not appear to be able to return JSON
on nautilus. Disable it on anything other than octopus for now.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
When the ceph client code has not yet (asynchronously) gotten the mgr
map, it can return -EACCES when we run the MgrCommand function. We
before continuing with the test function to get the fsadmin we delay a
bit so that we are more likely to have the mgr map before continuing.
This change also fixes the caching of the fs admin.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add a function for resizing a subvolume as well as types needed to
create the JSON command and parse the response JSON. The newSize
argument can be passed a numeric value (as a ByteCount) or the special
constant `Infinite` much like the ceph cli command. This is accomplished
using the interface type `NewSize`.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Allow the environment variable GO_CEPH_TEST_DEBUG_TRACE=yes to enable
tracing of the input & output json from the manager commands. This is
both useful for debugging the tests themselves and demonstrates the use
of something other than rados.Conn meeting the interface required by
FSAdmin.
Signed-off-by: John Mulligan <jmulligan@redhat.com>