From 312d30c50fd005fcf9894453d4f510df8aea45a3 Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Fri, 18 Aug 2023 11:04:13 -0700 Subject: [PATCH] fix:admin with no backend role on AOS unable to create restricted model group (#1188) (#1218) Signed-off-by: Bhavana Ramaram Co-authored-by: Bhavana Ramaram --- .../main/java/org/opensearch/ml/model/MLModelGroupManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelGroupManager.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelGroupManager.java index fac5db25c8..52e9e6d2b7 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelGroupManager.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelGroupManager.java @@ -167,7 +167,7 @@ private void validateRequestForAccessControl(MLRegisterModelGroupInput input, Us if (modelAccessControlHelper.isAdmin(user) && Boolean.TRUE.equals(isAddAllBackendRoles)) { throw new IllegalArgumentException("Admin users cannot add all backend roles to a model group."); } - if (CollectionUtils.isEmpty(user.getBackendRoles())) { + if (!modelAccessControlHelper.isAdmin(user) && CollectionUtils.isEmpty(user.getBackendRoles())) { throw new IllegalArgumentException("You must have at least one backend role to register a restricted model group."); } if (CollectionUtils.isEmpty(input.getBackendRoles()) && !Boolean.TRUE.equals(isAddAllBackendRoles)) {