Skip to content

Commit a6902de

Browse files
mayastor-borsAbhinandan-Purkait
andcommitted
chore(bors): merge pull request #671
671: Cherry pick #669 r=Abhinandan-Purkait a=Abhinandan-Purkait FIX: The error variant for multi replica snapshot clone/restore creation was the same as multi replica snapshot operations. Add a specific variant for the same. Co-authored-by: Abhinandan Purkait <[email protected]>
2 parents 594f3d5 + 8d6758b commit a6902de

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

control-plane/agents/src/bin/core/volume/clone_operations.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ impl CreateVolumeExeVal for SnapshotCloneOp<'_> {
101101
let new_volume = self.0.params();
102102
let snapshot = self.1.as_ref();
103103

104-
snafu::ensure!(new_volume.replicas == 1, errors::NReplSnapshotNotAllowed {});
104+
snafu::ensure!(
105+
new_volume.replicas == 1,
106+
errors::NReplSnapshotCloneCreationNotAllowed {}
107+
);
105108
snafu::ensure!(
106109
new_volume.allowed_nodes().is_empty()
107110
|| new_volume.allowed_nodes().len() >= new_volume.replicas as usize,
@@ -171,7 +174,7 @@ impl SnapshotCloneOp<'_> {
171174
None | Some([]) => Err(SvcError::NoHealthyReplicas {
172175
id: new_volume.uuid_str(),
173176
}),
174-
_ => Err(SvcError::NReplSnapshotNotAllowed {}),
177+
_ => Err(SvcError::NReplSnapshotCloneCreationNotAllowed {}),
175178
}?;
176179

177180
let mut pools = CloneVolumeSnapshot::builder_with_defaults(registry, new_volume, snapshot)
@@ -181,7 +184,7 @@ impl SnapshotCloneOp<'_> {
181184
let pool = match pools.pop() {
182185
Some(pool) if pools.is_empty() => Ok(pool),
183186
// todo: support more than 1 replica snapshots
184-
Some(_) => Err(SvcError::NReplSnapshotNotAllowed {}),
187+
Some(_) => Err(SvcError::NReplSnapshotCloneCreationNotAllowed {}),
185188
// todo: filtering should keep invalid pools/resources and tag them with a reason
186189
// why they cannot be used!
187190
None => Err(SvcError::NoSnapshotPools {

control-plane/agents/src/common/errors.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ pub enum SvcError {
298298
},
299299
#[snafu(display("Snapshots for multi-replica volumes are not allowed"))]
300300
NReplSnapshotNotAllowed {},
301+
#[snafu(display(
302+
"Cannot create a multi-replica volume from a snapshot of a single-replica volume"
303+
))]
304+
NReplSnapshotCloneCreationNotAllowed {},
301305
#[snafu(display("Replica's {} snapshot was unexpectedly skipped", replica))]
302306
ReplicaSnapSkipped { replica: String },
303307
#[snafu(display("Replica's {} snapshot was unexpectedly not taken", replica))]
@@ -830,6 +834,12 @@ impl From<SvcError> for ReplyError {
830834
source,
831835
extra,
832836
},
837+
SvcError::NReplSnapshotCloneCreationNotAllowed {} => ReplyError {
838+
kind: ReplyErrorKind::InvalidArgument,
839+
resource: ResourceKind::VolumeSnapshotClone,
840+
source,
841+
extra,
842+
},
833843
SvcError::ReplicaSnapSkipped { .. } => ReplyError {
834844
kind: ReplyErrorKind::Aborted,
835845
resource: ResourceKind::VolumeSnapshot,

0 commit comments

Comments
 (0)