diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-05-05 11:32:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 11:32:47 +0200 |
commit | 2bf7962280de289d34f750f40f8f6103da5ae288 (patch) | |
tree | 0ef3d0ae022b182254b32600215d2c5952bcf555 | |
parent | 36c50cfd9c65c957580e802a52692be18020a19f (diff) | |
parent | 80db359811d47e6dca2fca9de203c22db0870338 (diff) |
Merge pull request #17741 from vespa-engine/freva/fix-notification-nuke
Remove the correct notifications
2 files changed, 16 insertions, 2 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDb.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDb.java index 112b0fbc04d..e6435178d08 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDb.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDb.java @@ -49,8 +49,9 @@ public class NotificationsDb { try (Lock lock = curatorDb.lockNotifications(tenant)) { List<Notification> initial = curatorDb.readNotifications(tenant); List<Notification> filtered = initial.stream() - .filter(notification -> notification.type() == Type.applicationPackage && - notification.source().instance().isPresent() && notification.source().zoneId().isEmpty()) + .filter(notification -> notification.type() != Type.applicationPackage || + notification.source().instance().isEmpty() || + notification.source().zoneId().isPresent()) .collect(Collectors.toUnmodifiableList()); if (initial.size() > filtered.size()) curatorDb.writeNotifications(tenant, filtered); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java index 5bd7d1db769..9f07f784dbf 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java @@ -50,6 +50,19 @@ public class NotificationsDbTest { private final NotificationsDb notificationsDb = new NotificationsDb(clock, curatorDb); @Test + public void clears_old_application_package_notifications() { + List<Notification> allNotifications = new ArrayList<>(notifications); + allNotifications.add(notification(1601, Type.applicationPackage, Level.warning, NotificationSource.from(ApplicationId.from("tenant1", "app1", "instance1")), "msg")); + allNotifications.add(notification(1701, Type.applicationPackage, Level.warning, NotificationSource.from(new DeploymentId(ApplicationId.from("tenant1", "app1", "instance1"), ZoneId.from("dev", "us-south-3"))), "msg")); + curatorDb.writeNotifications(tenant, allNotifications); + + assertEquals(allNotifications, notificationsDb.listNotifications(NotificationSource.from(tenant), false)); + notificationsDb.removeApplicationPackageNotificationsWithInstanceSource(); + allNotifications.remove(6); + assertEquals(allNotifications, notificationsDb.listNotifications(NotificationSource.from(tenant), false)); + } + + @Test public void list_test() { assertEquals(notifications, notificationsDb.listNotifications(NotificationSource.from(tenant), false)); assertEquals(notificationIndices(0, 1, 2, 3), notificationsDb.listNotifications(NotificationSource.from(tenant), true)); |