From d351e84306f334a7b82ef85fbe7707b82e1e1541 Mon Sep 17 00:00:00 2001 From: Bhavana Ramaram Date: Mon, 7 Aug 2023 12:10:17 -0700 Subject: [PATCH] fix:admin with no backend role on AOS unable to create restricted model group Signed-off-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 d9fc0a9742..ee08608abd 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)) {