template <typename I>
void PromoteRequest<I>::refresh_image() {
if (!m_image_ctx->state->is_refresh_required()) {
- create_promote_snapshot();
+ handle_refresh_image(0);
return;
}
return;
}
- if (!util::can_create_primary_snapshot(m_image_ctx, false, m_force,
+ if (!util::can_create_primary_snapshot(m_image_ctx, false, true,
&m_rollback_snap_id)) {
lderr(cct) << "cannot promote" << dendl;
finish(-EINVAL);
return;
}
+ if (!m_force) {
+ lderr(cct) << "cannot promote: needs rollback and force not set" << dendl;
+ finish(-EINVAL);
+ return;
+ }
+
create_orphan_snapshot();
}
finish(r);
return;
}
-
+
scheduler_unregister_update_watcher();
}
expect_refresh_image(mock_image_ctx, true, 0);
MockUtils mock_utils;
- expect_can_create_primary_snapshot(mock_utils, force, CEPH_NOSNAP, true);
+ expect_can_create_primary_snapshot(mock_utils, true, CEPH_NOSNAP, true);
MockCreatePrimaryRequest mock_create_primary_request;
expect_create_promote_snapshot(mock_image_ctx, mock_create_primary_request,
0);
C_SaferCond ctx;
- auto req = new MockPromoteRequest(&mock_image_ctx, false, &ctx);
+ auto req = new MockPromoteRequest(&mock_image_ctx, force, &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}
expect_refresh_image(mock_image_ctx, true, 0);
MockUtils mock_utils;
- expect_can_create_primary_snapshot(mock_utils, force, 123, true);
+ expect_can_create_primary_snapshot(mock_utils, true, 123, true);
MockCreateNonPrimaryRequest mock_create_non_primary_request;
expect_create_orphan_snapshot(mock_image_ctx, mock_create_non_primary_request,
0);
MockListWatchersRequest mock_list_watchers_request;
expect_list_watchers(mock_image_ctx, mock_list_watchers_request, {}, 0);
expect_acquire_lock(mock_image_ctx, 0);
-
+
SnapInfo snap_info = {"snap", cls::rbd::MirrorPrimarySnapshotNamespace{}, 0,
{}, 0, 0, {}};
expect_rollback(mock_image_ctx, 123, &snap_info, 0);
expect_refresh_image(mock_image_ctx, true, 0);
MockUtils mock_utils;
- expect_can_create_primary_snapshot(mock_utils, force, CEPH_NOSNAP, false);
+ expect_can_create_primary_snapshot(mock_utils, true, CEPH_NOSNAP, false);
C_SaferCond ctx;
auto req = new MockPromoteRequest(&mock_image_ctx, force, &ctx);