... when mirroring is not enabled for the image.
Mirror::image_resync() returns ENOENT when mirroring is disabled for the
image. Instead, make it return EINVAL indicating that the call is
invalid when mirroring is not enabled for the image. This also causes
the public facing C, C++, and Python APIs that resync an image to
return EINVAL or raise an equivalent exception when mirroring is not
enabled for the image.
Signed-off-by: Ramana Raja <rraja@redhat.com>
C `rbd_mirror_image_promote()`, and Python `Image.mirror_image_promote()` --
will return EINVAL instead of ENOENT when mirroring is not enabled.
+* RBD: Requesting a resync on an image is invalid if the image is not enabled
+ for mirroring. The public APIs -- C++ `mirror_image_resync()`,
+ C `rbd_mirror_image_resync()`, and Python `Image.mirror_image_resync()` --
+ will return EINVAL instead of ENOENT when mirroring is not enabled.
+
>=19.2.1
* CephFS: Command `fs subvolume create` now allows tagging subvolumes through option
req->send();
r = get_info_ctx.wait();
- if (r < 0) {
+ if (r < 0 && r != -ENOENT) {
+ lderr(cct) << "failed to retrieve mirroring state, cannot resync: "
+ << cpp_strerror(r) << dendl;
return r;
- }
-
- if (promotion_state == mirror::PROMOTION_STATE_PRIMARY) {
+ } else if (mirror_image.state != cls::rbd::MIRROR_IMAGE_STATE_ENABLED) {
+ lderr(cct) << "mirroring is not enabled, cannot resync" << dendl;
+ return -EINVAL;
+ } else if (promotion_state == mirror::PROMOTION_STATE_PRIMARY) {
lderr(cct) << "image is primary, cannot resync to itself" << dendl;
return -EINVAL;
}
assert_raises(InvalidArgument, self.image.mirror_image_promote, False)
assert_raises(InvalidArgument, self.image.mirror_image_promote, True)
assert_raises(InvalidArgument, self.image.mirror_image_demote)
+ assert_raises(InvalidArgument, self.image.mirror_image_resync)
self.image.mirror_image_enable()
info = self.image.mirror_image_get_info()