Skip to content

Commit

Permalink
Check audit logs based on event create time
Browse files Browse the repository at this point in the history
Previously used timestamp would never detect the delete event
as the entity update time doesn't get updated on delete
  • Loading branch information
krsoninikhil committed Aug 13, 2024
1 parent bb29a22 commit fba51ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions webapp/src/main/java/org/apache/atlas/web/rest/AuthREST.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ private Long getLastEditTime(String serviceName, long lastUpdatedTime) {
mustClauseList.add(getMap("terms", getMap("typeName", entityUpdateToWatch)));

lastUpdatedTime = lastUpdatedTime == -1 ? 0 : lastUpdatedTime;
mustClauseList.add(getMap("range", getMap("timestamp", getMap("gte", lastUpdatedTime))));
mustClauseList.add(getMap("range", getMap("created", getMap("gte", lastUpdatedTime))));

dsl.put("query", getMap("bool", getMap("must", mustClauseList)));

List<Map<String, Object>> sortList = new ArrayList<>();
sortList.add(getMap("timestamp", "desc"));
sortList.add(getMap("created", "desc"));
dsl.put("sort", sortList);

parameters.setDsl(dsl);
Expand All @@ -217,7 +217,7 @@ private Long getLastEditTime(String serviceName, long lastUpdatedTime) {
if (!EntityAuditEventV2.EntityAuditActionV2.getDeleteActions().contains(lastAuditLog.getAction())) {
lastEditTime = lastAuditLog.getTimestamp();
} else {
LOG.info("found delete action, so ignoring the last edit time: {}", lastAuditLog.getTimestamp());
LOG.info("ES_SYNC_FIX: {}: found delete action, so ignoring the last edit time: {}", serviceName, lastAuditLog.getTimestamp());
}
} else {
lastEditTime = null; // no edits found
Expand Down

0 comments on commit fba51ff

Please sign in to comment.