Skip to content

Commit 37a3d84

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

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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::ForbiddenUnlabelKey {
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

+15
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ pub enum SvcError {
208208
labels: String,
209209
resource_kind: ResourceKind,
210210
},
211+
#[snafu(display(
212+
"Forbidden {}, cannot delete internal labels: {} ",
213+
resource_kind,
214+
labels
215+
))]
216+
ForbiddenUnlabelKey {
217+
labels: String,
218+
resource_kind: ResourceKind,
219+
},
211220
#[snafu(display("Multiple nexuses not supported"))]
212221
MultipleNexuses {},
213222
#[snafu(display("Storage Error: {}", source))]
@@ -801,6 +810,12 @@ impl From<SvcError> for ReplyError {
801810
source,
802811
extra,
803812
},
813+
SvcError::ForbiddenUnlabelKey { resource_kind, .. } => ReplyError {
814+
kind: ReplyErrorKind::InvalidArgument,
815+
resource: resource_kind,
816+
source,
817+
extra,
818+
},
804819
SvcError::MultipleNexuses { .. } => ReplyError {
805820
kind: ReplyErrorKind::InvalidArgument,
806821
resource: ResourceKind::Unknown,

0 commit comments

Comments
 (0)