Skip to content

Commit 7025cf6

Browse files
committed
feat(topology): restrict from deleting create-by label on pools
Signed-off-by: sinhaashish <[email protected]>
1 parent 848bcd5 commit 7025cf6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

control-plane/agents/src/bin/core/pool/pool_operations.rs

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use stor_port::{
1616
transport::{CreatePool, CtrlPoolState, DestroyPool, Pool},
1717
},
1818
};
19+
use utils::dsp_created_by_key;
1920

2021
#[async_trait::async_trait]
2122
impl ResourceLifecycle for OperationGuardArc<PoolSpec> {
@@ -169,6 +170,12 @@ impl ResourceLabel for OperationGuardArc<PoolSpec> {
169170
registry: &Registry,
170171
label_key: String,
171172
) -> Result<Self::UnlabelOutput, SvcError> {
173+
if label_key == dsp_created_by_key() {
174+
return Err(SvcError::InvalidLabelCreatedBy {
175+
labels: label_key,
176+
resource_kind: ResourceKind::Pool,
177+
});
178+
}
172179
let cloned_pool_spec = self.lock().clone();
173180
let spec_clone = self
174181
.start_update(

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

+11
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ pub enum SvcError {
208208
labels: String,
209209
resource_kind: ResourceKind,
210210
},
211+
#[snafu(display("Invalid {}, labels: {} . Cannot delete `created-by` label as it is used for identifying mayastor pools", resource_kind, labels))]
212+
InvalidLabelCreatedBy {
213+
labels: String,
214+
resource_kind: ResourceKind,
215+
},
211216
#[snafu(display("Multiple nexuses not supported"))]
212217
MultipleNexuses {},
213218
#[snafu(display("Storage Error: {}", source))]
@@ -801,6 +806,12 @@ impl From<SvcError> for ReplyError {
801806
source,
802807
extra,
803808
},
809+
SvcError::InvalidLabelCreatedBy { resource_kind, .. } => ReplyError {
810+
kind: ReplyErrorKind::InvalidArgument,
811+
resource: resource_kind,
812+
source,
813+
extra,
814+
},
804815
SvcError::MultipleNexuses { .. } => ReplyError {
805816
kind: ReplyErrorKind::InvalidArgument,
806817
resource: ResourceKind::Unknown,

0 commit comments

Comments
 (0)