From db229b379259405ca1eb29bfd18e807b993c8ef8 Mon Sep 17 00:00:00 2001 From: woblerr Date: Sat, 4 May 2024 22:39:44 +0300 Subject: [PATCH] Fix parsing backup timestamp (start time). Add timezone for parsing timestamp. This is missing change. --- gpbckpexporter/gpbckp_exporter.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gpbckpexporter/gpbckp_exporter.go b/gpbckpexporter/gpbckp_exporter.go index 74e6687..57e5538 100644 --- a/gpbckpexporter/gpbckp_exporter.go +++ b/gpbckpexporter/gpbckp_exporter.go @@ -96,15 +96,15 @@ func GetGPBackupInfo(historyFile, backupType string, collectDeleted, collectFail } // Check backup type and compare with backup type filter. if backupType == "" || backupType == bckpType { - bckpStartTime, err := time.Parse(gpbckpconfig.Layout, parseHData.BackupConfigs[i].Timestamp) - if err != nil { - level.Error(logger).Log("msg", "Parse backup timestamp value failed", "err", err) - } - // History file contains backup end time with timezone information. + // History file contains backup timestamp and endtime with timezone information. // See https://github.com/greenplum-db/gpbackup/blob/722899aada32ec118eb311255ac521b691bb4360/backup/backup.go#L431-L432 // It is necessary to take this into account when calculating time intervals. // With a high probability, the exporter will work in the same timezone as Greenplum cluster. // If this is not the case, then there are many questions about the backup process. + bckpStartTime, err := time.ParseInLocation(gpbckpconfig.Layout, parseHData.BackupConfigs[i].Timestamp, time.Local) + if err != nil { + level.Error(logger).Log("msg", "Parse backup timestamp value failed", "err", err) + } bckpStopTime, err := time.ParseInLocation(gpbckpconfig.Layout, parseHData.BackupConfigs[i].EndTime, time.Local) if err != nil { level.Error(logger).Log("msg", "Parse backup end time value failed", "err", err)