lasdf1234 commented on code in PR #15000:
URL: https://github.com/apache/gravitino/pull/15000#discussion_r4596792647
##########
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:
Thanks for the catch — agreed that requiring the metalake owner to be a USER
was too strict for GROUP-owned metalakes.
**Strategy:** when `gravitino.authorization.enable=true`, TMS now submits as
a configured service USER (`gravitino.maintenance.jobSubmitter`) via
`PrincipalUtils.doAs`, instead of reading the metalake owner. That gives a
stable USER job owner for both USER-owned and GROUP-owned metalakes. When
authorization is disabled, submit stays on the current thread (JobManager skips
`setOwner`).
**Startup:** `TableMaintenanceRESTFeature` requires a non-blank
`jobSubmitter` whenever authorization is enabled.
**Regression:** `TestMaintenanceJobManager` covers:
- constructor rejects authz-on without `jobSubmitter`
- `runIcebergMaintenanceJob` doAs / no-doAs paths
- real `submitAndBind` (runJob + bind) under authz-on as `jobSubmitter`
(GROUP-owner case no longer blocked, because owner is not consulted)
- claim release when `runJob` fails
Docs/conf template updated for `gravitino.maintenance.jobSubmitter`.
--
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]