fix(admin): replicate empty site groups (#2528)

Co-authored-by: loverustfs <hello@rustfs.com>
Co-authored-by: houseme <housemecn@gmail.com>
Co-authored-by: GatewayJ <835269233@qq.com>
This commit is contained in:
cxymds
2026-04-15 14:21:40 +08:00
committed by GitHub
parent fa793237fb
commit c11efce1e4
+17 -9
View File
@@ -1779,6 +1779,10 @@ async fn apply_bucket_meta_item(item: SRBucketMeta) -> S3Result<()> {
Ok(())
}
fn group_info_requires_upsert(update: &rustfs_madmin::GroupAddRemove) -> bool {
!update.is_remove
}
async fn apply_iam_item(item: SRIAMItem) -> S3Result<()> {
let Some(iam_sys) = get_global_iam_sys() else {
return Err(s3_error!(InvalidRequest, "iam not init"));
@@ -1811,7 +1815,7 @@ async fn apply_iam_item(item: SRIAMItem) -> S3Result<()> {
return Err(s3_error!(InvalidRequest, "groupInfo is required"));
};
let update = group_info.update_req;
if update.is_remove {
if !group_info_requires_upsert(&update) {
iam_sys
.remove_users_from_group(&update.group, update.members)
.await
@@ -1819,14 +1823,6 @@ async fn apply_iam_item(item: SRIAMItem) -> S3Result<()> {
return Ok(());
}
if update.members.is_empty() {
iam_sys
.set_group_status(&update.group, matches!(update.status, GroupStatus::Enabled))
.await
.map_err(ApiError::from)?;
return Ok(());
}
iam_sys
.add_users_to_group(&update.group, update.members)
.await
@@ -2973,4 +2969,16 @@ mod tests {
assert_eq!(data, expected);
}
#[test]
fn test_group_info_with_empty_members_still_requires_group_upsert() {
let update = rustfs_madmin::GroupAddRemove {
group: "empty-group".to_string(),
members: vec![],
status: GroupStatus::Enabled,
is_remove: false,
};
assert!(group_info_requires_upsert(&update));
}
}