bug5730: added e-mail notifications for archiving process

This commit is contained in:
Axel Uhl
2023-02-28 15:38:01 +01:00
parent a04d27e1d5
commit b64873aece
4 changed files with 40 additions and 14 deletions
@@ -1,4 +1,12 @@
MasterUnavailableMailSubject=Primary server of replica set {0} temporarily unavailable
MasterUnavailableMailBody=The primary server of replica set {0} is temporarily unavailable.\nModifying access will be suspended.\nModifications incurred by a replica will be queued and will be applied when the primary is available again.
MasterAvailableMailSubject=Primary server of replica set {0} available again
MasterAvailableMailBody=The primary server of replica set {0} is available again.\nModifying access is possible again.\nQueued modifications will now process.
MasterAvailableMailBody=The primary server of replica set {0} is available again.\nModifying access is possible again.\nQueued modifications will now process.
StartingToArchiveReplicaSetIntoSubject=Starting to archive a replica set to {0}
StartingToArchiveReplicaSetIntoBody=Starting to archive a replica set to {0}.\nWhile this is going on, refrain from archiving another replica set into the same archive {0}.\nAfter the content has been imported it will be compared to the original.\nYou should receive another e-mail when this has completed.
StartingToArchiveReplicaSetSubject=Starting to archive replica set {0}
StartingToArchiveReplicaSetBody=Starting to archive a replica set {0}.\nWhile this is ongoing please do not make any modifications to {0}.\nYou will receive another e-mail when this process has finished.
FinishedToArchiveReplicaSetIntoSubject=Archiving a replica set to {0} finished
FinishedToArchiveReplicaSetIntoBody=Archiving a replica set to {0} has finished.\nYou can now archive other content to {0} if you want.
FinishedToArchiveReplicaSetSubject=Archiving replica set {0} finished
FinishedToArchiveReplicaSetBody=Archiving replica set {0} has finished.\nIf you requested so, the original replica set has been removed.
@@ -1,4 +1,12 @@
MasterUnavailableMailSubject=
MasterUnavailableMailBody=
MasterAvailableMailSubject=
MasterAvailableMailBody=
MasterUnavailableMailSubject=Primär-Server des Anwendungs-Clusters {0} vorübergehend nicht verfügbar
MasterUnavailableMailBody=Der Primär-Server des Anwendungs-Clusters {0} ist vorübergehend nicht verfügbar.\nVerändernde Zugriffe sind derzeit nicht möglich.\nModifikationen, die durch eine Replika ausgeüfhrt werden, werden gepuffert und werden angewandt, wenn der primäre Server wieder verfügbar ist.
MasterAvailableMailSubject=Primär-Server des Anwendungs-Clusters {0} wieder verfügbar
MasterAvailableMailBody=Der Primär-Server des Anwendungs-Clusters {0} ist wieder verfügbar.\nVerändernde Zugriffe sind jetzt wieder möglich.\nGepufferte Modifikationen werden jetzt abgearbeitet.
StartingToArchiveReplicaSetIntoSubject=Anwendungs-Cluster wird nach {0} archiviert
StartingToArchiveReplicaSetIntoBody=Ein Anwendungs-Cluster wird nach {0} archiviert.\nWährend dieser Vorgang läuft, dürfen keine weitere Anwendungs-Cluster nach {0} archiviert werden.\nNach der Archivierung werden die Inhalte verglichen.\nEine e-Mail folgt, wenn der Vorgang abgeschlossen ist.
StartingToArchiveReplicaSetSubject=Anwendungs-Cluster {0} wird archiviert
StartingToArchiveReplicaSetBody=Das Anwendungs-Cluster {0} wird jetzt archiviert.\nWährenddessen dürfen keine Veränderungen an {0} vorgenommen werden.\nEine e-Mail folgt, wenn der Vorgang abgeschlossen ist.
FinishedToArchiveReplicaSetIntoSubject=Archivierung des Anwendungs-Clusters nach {0} beendet
FinishedToArchiveReplicaSetIntoBody=Die Archivierung des Anwendungs-Clusters nach {0} ist beendet.\nAb jetzt sind bei Bedarf weitere Archivierungen nach {0} möglich.
FinishedToArchiveReplicaSetSubject=Archivierung des Anwendungs-Clusters {0} beendet
FinishedToArchiveReplicaSetBody=Die Archivierung des Anwendungs-Clusters {0} ist beendet.\nFalls angefragt, wurde das Original Anwendungs-Cluster entfernt.
@@ -427,6 +427,8 @@ public class LandscapeServiceImpl implements LandscapeService {
final SailingServer from = sailingServerFactory.getSailingServer(new URL("https", hostnameFromWhichToArchive, "/"), bearerTokenOrNullForApplicationReplicaSetToArchive);
final SailingServer archive = sailingServerFactory.getSailingServer(new URL("https", hostnameOfArchive, "/"), bearerTokenOrNullForArchive);
logger.info("Importing master data from "+from+" to "+archive);
sendMailToReplicaSetOwner(archiveReplicaSet, "StartingToArchiveReplicaSetIntoSubject", "StartingToArchiveReplicaSetIntoBody");
sendMailToReplicaSetOwner(applicationReplicaSetToArchive, "StartingToArchiveReplicaSetSubject", "StartingToArchiveReplicaSetBody");
// Note: if from.getLeaderboardGroupIds() returns an empty set, "all" leaderboards will be imported by the MDI which again is the empty set.
// In this case, no comparison is required; in fact it wouldn't even work because passing an empty set to the archive into which the import
// was done would implicitly compare all leaderboard groups, resulting in the entire archive server content being the "diff."
@@ -507,6 +509,8 @@ public class LandscapeServiceImpl implements LandscapeService {
" did not work"+(mdiProgress != null ? mdiProgress.getErrorMessage() : " (no result at all)"));
compareServersResult = null;
}
sendMailToReplicaSetOwner(archiveReplicaSet, "FinishedToArchiveReplicaSetIntoSubject", "FinishedToArchiveReplicaSetIntoBody");
sendMailToReplicaSetOwner(applicationReplicaSetToArchive, "FinishedToArchiveReplicaSetSubject", "FinishedToArchiveReplicaSetBody");
return new Util.Pair<>(mdiProgress, compareServersResult);
}
@@ -932,6 +936,7 @@ public class LandscapeServiceImpl implements LandscapeService {
+ replicaSet.getPublicTargetGroup() + " and " + replicaSet.getMasterTargetGroup());
replicaSet.getPublicTargetGroup().addTarget(master.getHost());
replicaSet.getMasterTargetGroup().addTarget(master.getHost());
sendMailAboutMasterAvailable(replicaSet);
// the following map stores the assignment of the temporary upgrade replicas to the public / shard target groups
// for later removal as the final auto-scaling replicas start to replace them:
final Map<TargetGroup<String>, Iterable<AwsInstance<String>>> tempUpgradeReplicasByTargetGroup = new HashMap<>();
@@ -1167,6 +1172,7 @@ public class LandscapeServiceImpl implements LandscapeService {
replicaSet.getPublicTargetGroup()+" and "+replicaSet.getMasterTargetGroup());
replicaSet.getPublicTargetGroup().removeTarget(replicaSet.getMaster().getHost());
replicaSet.getMasterTargetGroup().removeTarget(replicaSet.getMaster().getHost());
sendMailAboutMasterUnavailable(replicaSet);
return additionalReplicaStarted;
}
@@ -1427,7 +1433,6 @@ public class LandscapeServiceImpl implements LandscapeService {
optionalPreferredInstanceToDeployTo).getInstanceToDeployTo(replicaSet);
}
logger.info("Stopping master "+replicaSet.getMaster());
sendMailAboutMasterUnavailable(replicaSet);
replicaSet.getMaster().stopAndTerminateIfLast(Landscape.WAIT_FOR_PROCESS_TIMEOUT, Optional.ofNullable(optionalKeyName), privateKeyEncryptionPassphrase);
final AppConfigBuilderT masterConfigurationBuilder = createMasterConfigurationBuilder(replicaSet.getName(),
optionalMasterReplicationBearerTokenOrNull, optionalMemoryInMegabytesOrNull, optionalMemoryTotalSizeFactorOrNull,
@@ -440,15 +440,20 @@ implements ReplicableSecurityService, ClearStateTestSupport {
@Override
public void sendMail(String username, String subject, String body) throws MailException {
final User user = getUserByName(username);
if (user != null && user.isEmailValidated()) {
final String toAddress = user.getEmail();
if (toAddress != null) {
MailService mailService = getMailService();
if (mailService == null) {
logger.warning(String.format("Could not send mail to user %s: no MailService found", username));
} else {
getMailService().sendMail(toAddress, subject, body);
if (user != null) {
if (user.isEmailValidated()) {
final String toAddress = user.getEmail();
if (toAddress != null) {
MailService mailService = getMailService();
if (mailService == null) {
logger.warning(String.format("Could not send mail to user %s: no MailService found", username));
} else {
getMailService().sendMail(toAddress, subject, body);
}
}
} else {
logger.warning("Not sending e-mail with subject "+subject+" to user "+user.getName()+
" with e-mail address "+user.getEmail()+" because e-mail address has not been validated");
}
}
}