From 39404d52518688e1e1d4817668515fdba1003095 Mon Sep 17 00:00:00 2001 From: mattl-netflix <63665634+mattl-netflix@users.noreply.github.com> Date: Thu, 4 May 2023 21:30:57 -0700 Subject: [PATCH] Fix snapshot location regression in SNS messages. (#1054) --- .../priam/backupv2/BackupVerificationTask.java | 11 +++++++++-- .../priam/backupv2/TestBackupVerificationTask.java | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/priam/src/main/java/com/netflix/priam/backupv2/BackupVerificationTask.java b/priam/src/main/java/com/netflix/priam/backupv2/BackupVerificationTask.java index 06dc0646e..21c3f758b 100644 --- a/priam/src/main/java/com/netflix/priam/backupv2/BackupVerificationTask.java +++ b/priam/src/main/java/com/netflix/priam/backupv2/BackupVerificationTask.java @@ -28,6 +28,8 @@ import com.netflix.priam.scheduler.TaskTimer; import com.netflix.priam.utils.DateUtil; import com.netflix.priam.utils.DateUtil.DateRange; +import java.nio.file.Path; +import java.nio.file.Paths; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.List; @@ -93,12 +95,17 @@ public void execute() throws Exception { .filter(result -> result.getLastValidated().toInstant().isAfter(now)) .forEach( result -> { + Path snapshotLocation = Paths.get(result.getSnapshotLocation()); + String snapshotKey = + snapshotLocation + .subpath(1, snapshotLocation.getNameCount()) + .toString(); logger.info( "Sending {} message for backup: {}", AbstractBackupPath.BackupFileType.SNAPSHOT_VERIFIED, - result.getSnapshotLocation()); + snapshotKey); backupNotificationMgr.notify( - result.getSnapshotLocation(), result.getStart().toInstant()); + snapshotKey, result.getStart().toInstant()); }); if (verifiedBackups.isEmpty()) { diff --git a/priam/src/test/java/com/netflix/priam/backupv2/TestBackupVerificationTask.java b/priam/src/test/java/com/netflix/priam/backupv2/TestBackupVerificationTask.java index 50874d71e..f0e3adcd2 100644 --- a/priam/src/test/java/com/netflix/priam/backupv2/TestBackupVerificationTask.java +++ b/priam/src/test/java/com/netflix/priam/backupv2/TestBackupVerificationTask.java @@ -191,6 +191,7 @@ private static BackupMetadata getRecentlyValidatedMetadata() { new BackupMetadata(BackupVersion.SNAPSHOT_META_SERVICE, "12345", new Date()); backupMetadata.setLastValidated( new Date(Instant.now().plus(1, ChronoUnit.HOURS).toEpochMilli())); + backupMetadata.setSnapshotLocation("bucket/path/to/file.db"); return backupMetadata; } }