Will-Lo commented on code in PR #4070:
URL: https://github.com/apache/gobblin/pull/4070#discussion_r1825175801


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/TimeBasedSnapshotCleanupPolicy.java:
##########
@@ -41,6 +42,7 @@ public TimeBasedSnapshotCleanupPolicy(Properties props) {
   @Override
   public boolean shouldDeleteSnapshot(FileStatus snapshot, Trash trash) {
     DateTime snapshotTime = 
Trash.TRASH_SNAPSHOT_NAME_FORMATTER.parseDateTime(snapshot.getPath().getName());
-    return snapshotTime.plusMinutes(this.retentionMinutes).isBeforeNow();
+    // To ensure that the comparison between snapshotTime and the current time 
is done in the same time zone
+    return 
snapshotTime.plusMinutes(this.retentionMinutes).isBefore(DateTime.now(DateTimeZone.UTC));

Review Comment:
   I think it would be more extensible if we had something like the following:
   ```
   public static final String RETENTION_SNAPSHOT_TIMEZONE = 
"gobblin.trash.snapshot.retention.timezone"
   Timezone retentionSnapshotTimezone;
   ...
   this.retentionSnapshotTImezone = 
props.containsKey(RETENTION_SNAPSHOT_TIMEZONE) ? 
Timezone.getTimeZone(props.getProperty(RETENTION_SNAPSHOT_TIMEZONE)) : 
DateTimeZone.getDefault();
   ...
   return 
snapshotTime.plusMinutes(this.retentionMinutes).isBefore(DateTime.now(this.retentionSnapshotTimezone));
   ```
   This allows the retention snapshot be more configurable in the long term and 
more explciit what the behavior is.



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