mchades commented on code in PR #14907:
URL: https://github.com/apache/gravitino/pull/14907#discussion_r4538118810
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -1212,8 +1213,9 @@ private void
initPublicMetadataDispatchers(MetadataOperations metadataOperations
PolicyHookDispatcher policyHookDispatcher = new
PolicyHookDispatcher(internalPolicyDispatcher);
this.policyDispatcher = new PolicyEventDispatcher(eventBus,
policyHookDispatcher);
- // Domain audit events are added separately from lifecycle hooks.
- this.domainDispatcher = new DomainHookDispatcher(internalDomainDispatcher);
+ // Keep events outside lifecycle hooks so hook failures are audited as
well.
+ this.domainDispatcher =
+ new DomainEventDispatcher(eventBus, new
DomainHookDispatcher(internalDomainDispatcher));
Review Comment:
With authorization enabled, `setParent` uses this dispatcher for its
`requireManage` lookup. I reproduced `PUT
/api/metalakes/lake/domains/missing/parent` returning 404 with just one audit
event, `GET_DOMAIN/FAILURE`. That lookup sets the failure flag, so
`HttpAuditFilter` skips the entry that would identify the failed PUT. Please
use `internalDomainDispatcher()` for the authorization lookup and add a
regression test that checks the failed request is identifiable.
##########
core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainEvent.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.listener.api.event.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for AttachDomain. */
+@DeveloperApi
+public final class AttachDomainEvent extends DomainEvent {
+ private final String parent;
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param parent The requested parent name.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public AttachDomainEvent(
+ String user, String metalake, String name, String parent, DomainInfo
domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.parent = parent;
Review Comment:
The requested parent is available on the event, but the JSON audit formatter
never reads `parent()`. Attaching the same child to `Finance` and to `Risk`
produced identical audit records apart from the timestamp. Please include the
requested parent in `ownCustomInfo()` for both `AttachDomainEvent` and
`AttachDomainFailureEvent`, and assert that the formatter writes it.
--
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]