jerryshao commented on code in PR #15000:
URL: https://github.com/apache/gravitino/pull/15000#discussion_r4596241004


##########
plugins/maintenance/src/main/java/org/apache/gravitino/maintenance/MaintenanceJobManager.java:
##########
@@ -123,4 +137,41 @@ public Optional<Long> submitAndBind(
       return Optional.empty();
     }
   }
+
+  /**
+   * Runs the Iceberg maintenance template. When ownership is enabled, submits 
as the metalake owner
+   * USER so {@link org.apache.gravitino.job.JobManager} does not attach 
{@code anonymous}.
+   */
+  private JobEntity runIcebergMaintenanceJob(String metalake, Map<String, 
String> jobConf) {
+    if (ownerDispatcher == null) {
+      // Ownership disabled: JobManager skips setOwner.
+      return jobOperationDispatcher.runJob(
+          metalake, MaintenanceJobTemplates.ICEBERG_MAINTENANCE_TEMPLATE, 
jobConf);
+    }
+    Owner owner =
+        ownerDispatcher
+            .getOwner(metalake, MetadataObjects.of(null, metalake, 
MetadataObject.Type.METALAKE))
+            .orElseThrow(
+                () ->
+                    new IllegalStateException(
+                        "Metalake " + metalake + " has no owner for TMS job 
submit"));
+    Preconditions.checkState(
+        owner.type() == Owner.Type.USER && owner.name() != null && 
!owner.name().trim().isEmpty(),

Review Comment:
   [P1] When a metalake is owned by a GROUP, this check rejects every cron and 
commit maintenance submission before runJob, and submitAndBind releases the 
claims without launching maintenance. Group-owned metalakes are supported by 
OwnerOperations and explicitly covered by TestOwnerManager. Please define a 
valid submission identity or ownership strategy for this case instead of 
requiring the metalake owner to be a USER, and add a regression test exercising 
the real MaintenanceJobManager submission path.



-- 
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]

Reply via email to