Skip to content

Commit f93e789

Browse files
zane-neoylwu-amzn
andauthored
fix no permission to update model group index (opensearch-project#948) (opensearch-project#1253)
Signed-off-by: Yaliang Wu <ylwu@amazon.com> Co-authored-by: Yaliang Wu <ylwu@amazon.com>
1 parent aad0b3f commit f93e789

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

plugin/src/main/java/org/opensearch/ml/action/model_group/TransportUpdateModelGroupAction.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,19 @@ private void updateModelGroup(
140140

141141
UpdateRequest updateModelGroupRequest = new UpdateRequest();
142142
updateModelGroupRequest.index(ML_MODEL_GROUP_INDEX).id(modelGroupId).doc(source);
143-
client
144-
.update(
145-
updateModelGroupRequest,
146-
ActionListener.wrap(r -> { listener.onResponse(new MLUpdateModelGroupResponse("Updated")); }, e -> {
147-
log.error("Failed to update Model Group", e);
148-
throw new MLException("Failed to update Model Group", e);
149-
})
150-
);
143+
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
144+
client
145+
.update(
146+
updateModelGroupRequest,
147+
ActionListener.wrap(r -> { listener.onResponse(new MLUpdateModelGroupResponse("Updated")); }, e -> {
148+
log.error("Failed to update Model Group", e);
149+
throw new MLException("Failed to update Model Group", e);
150+
})
151+
);
152+
} catch (Exception e) {
153+
logException("Failed to Update model group ", e, log);
154+
listener.onFailure(e);
155+
}
151156
}
152157

153158
private void validateRequestForAccessControl(MLUpdateModelGroupInput input, User user, MLModelGroup mlModelGroup) {

0 commit comments

Comments
 (0)