mehakmeet commented on code in PR #10834:
URL: https://github.com/apache/gravitino/pull/10834#discussion_r3166799222
##########
core/src/main/java/org/apache/gravitino/hook/ModelHookDispatcher.java:
##########
@@ -69,13 +74,23 @@ public Model registerModel(NameIdentifier ident, String
comment, Map<String, Str
Model model = dispatcher.registerModel(ident, comment, properties);
// Set the creator as owner of the model.
- OwnerDispatcher ownerManager =
GravitinoEnv.getInstance().ownerDispatcher();
- if (ownerManager != null) {
- ownerManager.setOwner(
- ident.namespace().level(0),
- NameIdentifierUtil.toMetadataObject(ident, Entity.EntityType.MODEL),
- PrincipalUtils.getCurrentUserName(),
- Owner.Type.USER);
+ try {
+ OwnerDispatcher ownerManager =
GravitinoEnv.getInstance().ownerDispatcher();
+ if (ownerManager != null) {
+ // The inner NormalizeDispatcher case-folds the model name based on
catalog capabilities,
+ // so the entity is stored under the normalized identifier. Apply the
same normalization
+ // here so the owner is attached to the same identifier the manager
sees.
+ NameIdentifier normalizedIdent =
+ CapabilityHelpers.applyCapabilities(
+ ident, Capability.Scope.MODEL,
GravitinoEnv.getInstance().catalogManager());
+ ownerManager.setOwner(
+ normalizedIdent.namespace().level(0),
+ NameIdentifierUtil.toMetadataObject(normalizedIdent,
Entity.EntityType.MODEL),
+ PrincipalUtils.getCurrentUserName(),
+ Owner.Type.USER);
+ }
+ } catch (Exception e) {
+ LOG.warn("Failed to set owner for model {}, model exists without owner",
ident, e);
Review Comment:
Ideally, we should propagate some sort of warning or response that isn't
similar to full success but that requires changes to the Response classes and
for Iceberg rest server it's even trickier. This we could handle in a separate
PR?
But, we should also not propagate an exception as the entity gets created
but the owner setting fails, if the user sees an error for this and tries to
recreate the same entity they will see entityAlreadyExists exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]