r = cls_client::mirror_image_get_finish(&iter, &m_mirror_image);
}
- if (r == 0) {
+ if (r == 0 && m_mirror_image.state == cls::rbd::MIRROR_IMAGE_STATE_CREATING &&
+ !m_non_primary_global_image_id.empty()) {
+ // special case where rbd-mirror injects a disabled record to record the
+ // local image id prior to creating ther image
+ r = -ENOENT;
+ } else if (r == 0) {
if (m_mirror_image.mode != m_mode) {
lderr(m_cct) << "invalid current image mirror mode" << dendl;
r = -EINVAL;
}
finish(r);
return;
- }
-
- if (r != -ENOENT) {
+ } else if (r != -ENOENT) {
lderr(m_cct) << "failed to retrieve mirror image: " << cpp_strerror(r)
<< dendl;
finish(r);
r = cls_client::get_snapcontext_finish(&it, &m_snapc);
}
- if (r < 0) {
+ if (r == -ENOENT &&
+ m_mirror_image->state == cls::rbd::MIRROR_IMAGE_STATE_CREATING) {
+ // image doesn't exist but we have a mirror image record for it
+ ldout(m_cct, 10) << "image does not exist for mirror image id "
+ << m_image_id << dendl;
+ *m_promotion_state = PROMOTION_STATE_UNKNOWN;
+ *m_primary_mirror_uuid = "";
+ finish(0);
+ return;
+ } else if (r < 0) {
lderr(m_cct) << "failed to get snapcontext: " << cpp_strerror(r)
<< dendl;
finish(r);
for (auto it = snap_info.rbegin(); it != snap_info.rend(); it++) {
auto mirror_ns = boost::get<cls::rbd::MirrorSnapshotNamespace>(
&it->second.snap_namespace);
+
if (mirror_ns != nullptr) {
switch (mirror_ns->state) {
case cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY: