Commit Graph

331 Commits

Author SHA1 Message Date
Sven Anderson
530af708c9 go-ceph: promote mature APIs to stable
Signed-off-by: Sven Anderson <sven@redhat.com>
2024-08-13 09:00:47 +00:00
Niels de Vos
a9ce294dbb rbd: let CloneImageByID check for rbd_clone4 at runtime
Some versions of librbd provide the rbd_clone4 function, and others do
not. Squid will have the function backported in the 1st update, the
initial release of Squid does not have it. This makes checking for the
function based on the named Ceph version impractical.

With the new dlsym.LookupSymbol() function, it is now possible to check
the availability of rbd_clone4 during runtime. If the symbol is not
found ErrNotImplemented is returned, which can be used to detect the
unavailability of the function.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
2024-07-25 12:03:15 +00:00
Niels de Vos
8bced26404 rbd: fix cleanup of CloneFromGroupSnap test case
When there is a failure during the CloneFromGroupSnap test case, the
rbd-group snapshot was not removed, preventing images from being deleted
as well.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
2024-07-25 12:03:15 +00:00
Niels de Vos
ee25db94c6 rbd: add support for CloneImageByID()
RBD image groups can be used to create consistent snapshots of all
images that are part of the group. The new rbd_clone4() API makes it
possible to create a new RBD image from a single snapshot that was
created as part of the group snapshot.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
2024-06-25 20:40:23 +00:00
John Mulligan
0a787041f3 rbd: promote Image.Resize2 api to stable
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2024-04-09 13:13:56 +00:00
zxysilent
2146f1af0c rbd: trigger an error on invalid max snaps value
In file include from rbd.go:931
var cMaxSnaps C.int
ret := C.rbd_snap_list(image.image, nil, &cMaxSnaps)
cSnaps := make([]C.rbd_snap_info_t, cMaxSnaps)
It is necessary to determine whether cMaxSnaps is a large 0. Otherwise, the following code will panic
ret = C.rbd_snap_list(image.image,&cSnaps[0], &cMaxSnaps)

Signed-off-by: zxysilent <zxysilent@outlook.com>
2024-04-05 17:33:05 +00:00
Jose A. Rivera
cfae965d25 rbd: remove features_nautilus.go
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
2024-04-05 14:05:43 +00:00
Niels de Vos
8d71b1f760 rbd: prevent warning about redefining _POSIX_C_SOURCE
While building an application with the latest version of go-ceph, the
following warning is spit out:

In file included from _cgo_export.c:4:
resize.go:7: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdlib.h:26,
                 from _cgo_export.c:3:
/usr/include/features.h:292: note: this is the location of the previous definition
  292 | # define _POSIX_C_SOURCE        200809L

When _POSIX_C_SOURCE is already defined, ther is no need to define it
again.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
2024-03-21 16:13:54 +00:00
John Mulligan
bb2a449faf rbd: add a test to verify that encrypted volumes can be resized
Add a test to verify that an encrypted volume can be resized to
the desired unencrypted size similar to how the rbd command line
tool is documented as able to do.

Fixes: #972

Original-Version-By: Will Gorman <will.gorman@gmail.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2024-03-21 15:52:09 +00:00
Niels de Vos
947b7d312f rbd: add GetSnapGroupNamespace() to get details about group snapshots
rbd_snap_get_group_namespace() can be used to get details about
snapshots of an image, that were created as part of a group.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
2024-03-06 12:42:29 +00:00
Manish
6f90ce139c Code Lint: Fix lint errors caused by revive check for unused parameters
revive v1.3.7 added https://github.com/mgechev/revive/pull/966 which
checks for unused parameters in function literals. This caused several
lint errors in go-ceph code.

Signed-off-by: Manish <myathnal@redhat.com>
2024-02-13 07:22:13 +00:00
Anoop C S
90ae26adce rbd: Fix a typo in comment for Image.Resize2
Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
2023-12-11 18:45:44 +00:00
Khayyam Saleem
51b8287148 librbd exposes rbd_resize2, which allows clients to pass in a boolean controlling
whether or not the allocation should be allowed to shrink, and a progress-tracking
callback. This contribution extends go-ceph to be able to call rbd_resize2.

Closes #933

Signed-off-by: Khayyam Saleem <khayyam.saleem@gmail.com>
2023-11-08 19:51:30 +00:00
John Mulligan
70ddb1dbea rbd: promote lock apis to stable
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-10-05 11:22:38 +00:00
DanWritesCode
e1731150a5 rbd: test for image GlobalID inequality
Signed-off-by: Daniel R <github@dann.me>
2023-10-02 13:48:12 +00:00
DanWritesCode
d5c981d9cb rbd: get mirror image status from correct array element
Signed-off-by: Daniel R <github@dann.me>
2023-10-02 13:48:12 +00:00
Sven Anderson
5f757453ab rbd: promote preview API for release v0.23.0
Signed-off-by: Sven Anderson <sven@redhat.com>
2023-08-14 14:43:57 +00:00
Niels de Vos
1257d817db rbd: include details for parent image in the trash
When a parent image has been removed, it will linger in the trash until
all siblings are gone. The image is not accessible through it's name
anymore, only through its ID.

The ImageSpec that is returned by Image.GetParent() now contains the
Trash boolean and the ImageID to identify if the image is in the trash,
and use OpenImageById() to access the removed parent image.

Related-to: ceph/ceph-csi#4013
Signed-off-by: Niels de Vos <ndevos@ibm.com>
2023-08-02 13:56:45 +00:00
Anoop C S
aefa1dc858 rbd: Make migration APIs stable
Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
2023-06-08 17:35:55 +00:00
Nikhil-Ladha
7476da2582 rbd: Remove redundant LastSeen property from MirrorPeerSite struct
Removed the `LastSeen` property of MirrorPeerSite struct as it is not being set/updated anywhere by the ceph API.

Fixes: #870

Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
2023-04-28 09:02:57 +00:00
Nikhil-Ladha
9041276dd9 rbd: Add locking rbd APIs
Added new locking APIs for the rbd component named
`rbd_lock_acquire`, `rbd_lock_break`, `rbd_lock_release`, `rbd_lock_get_owners`,
`rbd_is_exclusive_lock_owner` along with supporting TCs.

Fixes: #275

Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
2023-04-13 14:29:53 +00:00
John Mulligan
743c43be54 rbd: rename recently formed files to remove redundant prefix
We overlooked this in review, before this makes it into a release let's
remove the referential redundancy with rapidity.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-04-05 13:43:53 +00:00
John Mulligan
eaf74cbebd rbd: document SparsifyWithProgress callback's arguments
As discussed in #851, we wanted to fully document the arguments the
callback function is expected to be called with.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-04-05 13:43:53 +00:00
Nikhil-Ladha
3d986f2bd3 rbd: Add rbd_sparsify_with_progress rbd API
Added a new rbd API `rbd_sparsify_with_progress`, and supporting
tests.

Fixes: #281

Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
2023-04-04 15:14:01 +00:00
Nikhil-Ladha
fcd2fcd6f6 rbd: Add mirror peer site API components
**Description:**
Added some API components of mirror peer site

Fixes: #486

Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
2023-03-27 08:39:12 +00:00
John Mulligan
1feedf3bfc rbd: remove stray debugging prints from mirror tests
It is doubtful that these Print(f)s have been useful to any one for a
long time.  Remove them.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-03-17 18:10:53 +00:00
John Mulligan
ab7955a236 rbd: add tests for DescriptionReplayStatus and UnmarshalDescriptionJSON
Add unit and simplistic functional tests for new JSON/status description
extraction functions.  Because these are preview functions we also add a
stub file to add a no-op function to be built on non-preview builds.
This avoids having to reimplement large parts of the existing mirroring
tests just to validate this small aspect of the SiteMirrorImageStatus
struct.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-03-17 18:10:53 +00:00
John Mulligan
f4f0d6dd9a rbd: add functions to parse json in mirroring status description field
Add UnmarshalDescriptionJSON method to SiteMirrorImageStatus
Add DescriptionReplayStatus method to SiteMirrorImageStatus

Both these functions are meant to help extract the JSON object that is
some times appended to the Description field in the
SiteMirrorImageStatus struct. I have only seen the JSON appear after
"replaying, " but there's little docs for this and I skimmed to code to
even find out what fields the JSON might include.  As such, the
UnmarshalDescriptionJSON tries to unmarshal the appended JSON into an
object the caller provides in case skimming the code was insufficient or
the caller has other needs. For most cases, DescriptionReplayStatus can
be used to parse the JSON into a struct containing known fields.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-03-17 18:10:53 +00:00
Sven Anderson
87041ee7d8 gofmt: reformat everything with new gofmt of go 1.19
Signed-off-by: Sven Anderson <sven@redhat.com>
2023-02-20 20:50:24 +00:00
Omid Yoosefi
a6a42e9c7b rbd: implement live migration functions
Signed-off-by: Omid Yoosefi <omidyoosefi@ibm.com>
2023-01-11 05:35:52 +00:00
John Mulligan
b956ad18da rbd: increase maximum number of trash entries listable
Work around an issue reported that due to a large number of items in the
rbd trash the function fails rather than listing the items as desired.
This short term fix simply increases the limit rather than doing
anything long term.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2022-11-17 12:26:27 +00:00
John Mulligan
f2f7e1c51d rbd: make Snapshot.Remove stable
As per the api stability doc, Snapshot.Remove is due to be stable in
0.18.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2022-10-17 17:18:49 +00:00
Sanford Miller
15d71fe192 rbd: add mirroring support for nautilus
The librbd API for mirroring-related operations changed substantially between
Nautilus and Octopus. Due to this, go-ceph had previously only implemented
mirroring functionality if built against Octopus client libraries. This patch
implements equivalent functionality for use with Nautilus clients.

Signed-off-by: Sanford Miller <smiller@digitalocean.com>
2022-07-13 13:00:48 +00:00
Sanford Miller
133e675c8d rbd: refactor GetImageNames to use a for loop instead of recursion
This is done because using a for loop is more idiomatic in Go code.

Signed-off-by: Sanford Miller <smiller@digitalocean.com>
2022-06-14 16:33:29 +00:00
Sanford Miller
36d5c4498e rbd: don't cap the buffer size used in GetImageNames
This removes the limit on the max buffer size GetImageNames is willing to pass
to rbd_list2, which is somewhat arbitrary and is too small for large clusters.
GetImageNames will continue to start with a small buffer size and retry with a
larger buffer if rbd_list2 returns ERANGE (just without a cap on the max buffer
size it's willing to go to).

Signed-off-by: Sanford Miller <smiller@digitalocean.com>
2022-06-14 16:33:29 +00:00
John Mulligan
0722af5375 rbd admin: enable TestMirrorSnapshotScheduleStatus on quincy
The issue has (probably) been fixed in ceph v17.2.0 images.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2022-06-14 12:39:59 +00:00
Sven Anderson
f4fb583252 docs: remove all PREVIEW comments
Signed-off-by: Sven Anderson <sven@redhat.com>
2022-06-06 14:42:04 +00:00
Sanford Miller
68ebb0520a rbd: expose rbd_snap_rename to Go clients
This implements the following method:
	(snapshot *Snapshot) Rename(destName string) error

Signed-off-by: Sanford Miller <smiller@digitalocean.com>
2022-05-17 14:40:07 +00:00
John Mulligan
68eff5d9e4 rbd admin: disable TestMirrorSnapshotScheduleStatus on qunicy
Will need to be properly debugged later.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2022-05-02 14:14:25 +00:00
John Mulligan
dae56d0c65 rbd: update doc comments for rbd image Read and Write funcs
The comments above Read and Write were very old and not up to our
current standards. Update them to be accurate and note that the
offset internal to the image type is not concurrency safe.
This also cleans up some old and unhelpful todos.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2022-02-09 15:59:48 +00:00
John Mulligan
69c8750e96 rbd admin: use the new admintest module to set up tests
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2022-02-08 15:55:02 +00:00
Rakshith R
7d881032a6 rbd/admin: promote ImageSpec & tasks api to stable
Promoting ImageSpec & task apis to stable so
they can be release in v0.13.0.

Signed-off-by: Rakshith R <rar@redhat.com>
2021-11-29 15:07:06 +00:00
Seena Fallah
bae93ac4ab rbd: export image name
Signed-off-by: Seena Fallah <seenafallah@gmail.com>
2021-11-09 02:31:09 +00:00
John Mulligan
cc9f4d6b39 rbd: remove luminous and mimic build tags
Luminous and mimic have not been supported for a few releases now.
There's no need to keep these build tags any more.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-11-09 01:24:01 +00:00
Sven Anderson
87f4563118 format: run gofmt on all files
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-10-04 18:58:35 +00:00
Sven Anderson
26fd846da1 docs: update comments of preview and deprecated APIs
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-10-04 18:58:35 +00:00
John Mulligan
f015cc36ca rbd: clearly mark Set as deprecated
Use the notation described in the new API stability doc.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-09-30 13:27:01 +00:00
John Mulligan
7f74708d5b rbd: clearly mark open function as deprecated
Use the notation described in the new API stability doc.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2021-09-30 13:27:01 +00:00
Rakshith R
126d6f5747 rbd admin: add rbd task [list|cancel|remove|trash remove|flatten]` apis
These functions let one add various rbd tasks that are done
asynchronously in the background. Also added tests for the same.

Signed-off-by: Rakshith R <rar@redhat.com>
2021-09-28 13:13:07 +00:00
Rakshith R
890b3619db rbd admin: add type ImageSpec to work with rbd task api
ImageSpec type has been added to work with rbd task api.
It consists of optional pool & namespace and image name/id.
[pool/][namespace/]image[Name/id].
Added unit tests.

Signed-off-by: Rakshith R <rar@redhat.com>
2021-09-28 13:13:07 +00:00