Eli Mesika has uploaded a new change for review. Change subject: core: backup awareness, full backup check ......................................................................
core: backup awareness, full backup check This patch changes the backup awareness logic as follows: We will check only for FULL backup , a full backup contains 'db' and 'files' as scope If one of 'db' or 'files' is missing or both we will generate NO BACKUP alert If two exists but at least one is OLD we will generate an alert with the oldest date Change-Id: I71a8b2b4278db039518f7bfc9b684f390ca449fe Signed-off-by: emesika <emes...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EngineBackupAwarenessManager.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties M backend/manager/modules/dal/src/test/resources/fixtures.xml M packaging/dbscripts/audit_log_sp.sql M packaging/dbscripts/engine_backup_log_sp.sql 6 files changed, 18 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/40543/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EngineBackupAwarenessManager.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EngineBackupAwarenessManager.java index 67c462d..1773de1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EngineBackupAwarenessManager.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/EngineBackupAwarenessManager.java @@ -26,7 +26,8 @@ @Singleton public class EngineBackupAwarenessManager { private static final Logger log = LoggerFactory.getLogger(EngineBackupAwarenessManager.class); - private static final String SCOPE = "db"; + private static final String DB_SCOPE = "db"; + private static final String FILES_SCOPE = "files"; private volatile boolean active; @Inject private AuditLogDirector auditLogDirector; @@ -73,16 +74,19 @@ AuditLogableBase alert = new AuditLogableBase(); //try to get last backup record - EngineBackupLog lastBackup = engineBackupLogDao.getLastSuccessfulEngineBackup(SCOPE); - if (lastBackup == null) { - auditLogDirector.log(alert, AuditLogType.ENGINE_NO_BACKUP); + EngineBackupLog lastDbBackup = engineBackupLogDao.getLastSuccessfulEngineBackup(DB_SCOPE); + EngineBackupLog lastFilesBackup = engineBackupLogDao.getLastSuccessfulEngineBackup(FILES_SCOPE); + if (lastDbBackup == null || lastFilesBackup == null) { + auditLogDirector.log(alert, AuditLogType.ENGINE_NO_FULL_BACKUP); } else { - //check time elapsed from last backup + //check time elapsed from last full (db and files) backup Integer backupAlertPeriodInDays = Config.<Integer>getValue(ConfigValues.BackupAlertPeriodInDays); - Date lastBackupDate = lastBackup.getDoneAt(); - long diffInDays = (Calendar.getInstance().getTimeInMillis() - lastBackupDate.getTime()) / TimeUnit.DAYS.toMillis(1); + Date lastDbBackupDate = lastDbBackup.getDoneAt(); + Date lastFilesBackupDate = lastFilesBackup.getDoneAt(); + Date lastFullBackupDate = lastDbBackupDate.compareTo(lastFilesBackupDate) < 0 ? lastDbBackupDate : lastFilesBackupDate; + long diffInDays = (Calendar.getInstance().getTimeInMillis() - lastFullBackupDate.getTime()) / TimeUnit.DAYS.toMillis(1); if (diffInDays > backupAlertPeriodInDays) { - alert.addCustomValue("Date", lastBackupDate.toString()); + alert.addCustomValue("Date", lastFullBackupDate.toString()); auditLogDirector.log(alert, AuditLogType.ENGINE_NO_WARM_BACKUP); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index cd3f280..918d3a9 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -1014,7 +1014,7 @@ FENCE_OPERATION_USING_AGENT_AND_PROXY_STARTED(9020), FENCE_OPERATION_USING_AGENT_AND_PROXY_FAILED(9021, AuditLogSeverity.WARNING), // Engine backup - ENGINE_NO_BACKUP(9022, AuditLogSeverity.ALERT, AuditLogTimeInterval.DAY.getValue()), + ENGINE_NO_FULL_BACKUP(9022, AuditLogSeverity.ALERT, AuditLogTimeInterval.DAY.getValue()), ENGINE_NO_WARM_BACKUP(9023, AuditLogSeverity.ALERT, AuditLogTimeInterval.DAY.getValue()), ENGINE_BACKUP_STARTED(9024, AuditLogSeverity.NORMAL), ENGINE_BACKUP_COMPLETED(9025, AuditLogSeverity.NORMAL), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties index 69a55d3..ff21b45 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -616,8 +616,8 @@ FENCE_OPERATION_FAILED=Power management ${Action} of Host ${VdsName} failed. FENCE_OPERATION_USING_AGENT_AND_PROXY_STARTED=Executing power management ${Action} on Host ${Host} using Proxy Host ${ProxyHost} and Fence Agent ${AgentType}:${AgentIp}. FENCE_OPERATION_USING_AGENT_AND_PROXY_FAILED=Execution of power management ${Action} on Host ${Host} using Proxy Host ${ProxyHost} and Fence Agent ${AgentType}:${AgentIp} failed. -ENGINE_NO_BACKUP=There is no backup available, please run engine-backup to prevent data loss in case of corruption. -ENGINE_NO_WARM_BACKUP=Backup was created on ${Date} and it's too old. Please run engine-backup to prevent data loss in case of corruption. +ENGINE_NO_FULL_BACKUP=There is no full backup available, please run engine-backup to prevent data loss in case of corruption. +ENGINE_NO_WARM_BACKUP=Full backup was created on ${Date} and it's too old. Please run engine-backup to prevent data loss in case of corruption. ENGINE_BACKUP_STARTED=Engine backup started. ENGINE_BACKUP_COMPLETED=Engine backup completed successfully. ENGINE_BACKUP_FAILED=Engine backup failed. diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 2db2439..2ef1518 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -6372,7 +6372,7 @@ <null /> <null /> <value>2008-04-02 13:11:29</value> - <value>ENGINE_NO_BACKUP</value> + <value>ENGINE_NO_FULL_BACKUP</value> <value>9022</value> <value>10</value> <value>There is no backup available, please run engine-backup to prevent data loss in case of corruption.</value> diff --git a/packaging/dbscripts/audit_log_sp.sql b/packaging/dbscripts/audit_log_sp.sql index 5265f87..f26d8f7 100644 --- a/packaging/dbscripts/audit_log_sp.sql +++ b/packaging/dbscripts/audit_log_sp.sql @@ -240,7 +240,7 @@ AS $procedure$ BEGIN UPDATE audit_log set deleted = true - where origin='oVirt' and log_type in (9022, 9023, 9026); -- (ENGINE_NO_BACKUP, ENGINE_NO_BACKUP, ENGINE_BACKUP_FAILED) + where origin='oVirt' and log_type in (9022, 9023, 9026); -- (ENGINE_NO_FULL_BACKUP, ENGINE_NO_WARM_BACKUP, ENGINE_BACKUP_FAILED) END; $procedure$ LANGUAGE plpgsql; diff --git a/packaging/dbscripts/engine_backup_log_sp.sql b/packaging/dbscripts/engine_backup_log_sp.sql index e7796b8..8ab332f 100644 --- a/packaging/dbscripts/engine_backup_log_sp.sql +++ b/packaging/dbscripts/engine_backup_log_sp.sql @@ -1,4 +1,5 @@ -- The following SP is used by engine-backup to report engine-backup activity +-- v_scope is one of {db,dwhdb,reportsdb,files} -- v_status can be : -- -1 backup failed -- 0 backup started -- To view, visit https://gerrit.ovirt.org/40543 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71a8b2b4278db039518f7bfc9b684f390ca449fe Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches