... instead of ENOENT when mirroring is not enabled for the image.
The PromoteRequest async state machine returns ENOENT when mirroring is
not enabled for the image. Instead, make it return EINVAL similar to
DemoteRequest's behavior, which is more appropriate. This also causes
the public facing C, C++, and Python APIs that promote 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_get_mode()`, and Python `Image.mirror_image_get_mode()`
-- will return EINVAL when mirroring is disabled.
+* RBD: Promoting an image is invalid if the image is not enabled for mirroring.
+ The public APIs -- C++ `mirror_image_promote()`,
+ C `rbd_mirror_image_promote()`, and Python `Image.mirror_image_promote()` --
+ 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
CephContext *cct = m_image_ctx.cct;
ldout(cct, 20) << "r=" << r << dendl;
- if (r < 0) {
+ if (r < 0 && r != -ENOENT) {
lderr(cct) << "failed to retrieve mirroring state: " << cpp_strerror(r)
<< dendl;
finish(r);
ASSERT_EQ(0, image.mirror_image_demote());
ASSERT_EQ(0, image.mirror_image_promote(false));
+ ASSERT_EQ(0, image.mirror_image_disable(false));
+ ASSERT_EQ(-EINVAL, image.mirror_image_promote(false));
+ ASSERT_EQ(-EINVAL, image.mirror_image_demote());
+
ASSERT_EQ(0, image.close());
ASSERT_EQ(0, m_rbd.remove(m_ioctx, image_name.c_str()));
ASSERT_EQ(0, m_rbd.mirror_peer_site_remove(m_ioctx, peer_uuid));
info = self.image.mirror_image_get_info()
self.check_info(info, '', RBD_MIRROR_IMAGE_DISABLED, False)
assert_raises(InvalidArgument, self.image.mirror_image_get_mode)
+ 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)
self.image.mirror_image_enable()
info = self.image.mirror_image_get_info()