diff --git a/agent/app/service/alert_helper.go b/agent/app/service/alert_helper.go index 4a7ed87d9b8a..d51c65317c0e 100644 --- a/agent/app/service/alert_helper.go +++ b/agent/app/service/alert_helper.go @@ -30,10 +30,11 @@ import ( ) const ( - ResourceAlertInterval = 30 - CheckIntervalSec = 3 - LoadCheckIntervalMin = 5 - sshIPLoginWindow = 30 * time.Minute + ResourceAlertInterval = 30 + CheckIntervalSec = 3 + LoadCheckIntervalMin = 5 + sshIPLoginWindow = 30 * time.Minute + sslAutoRenewAlertSkipDays = 31 ) type AlertTaskHelper struct { @@ -864,7 +865,7 @@ func calculateSSLExpiryDays(sslList []model.WebsiteSSL, cycle uint) (map[int][]s daysDiff := int(math.Ceil( ssl.ExpireDate.Sub(currentDate).Hours() / 24, )) - if daysDiff > 0 && int(cycle) >= daysDiff { + if daysDiff > 0 && int(cycle) >= daysDiff && !shouldSuppressSSLExpiryAlert(ssl, daysDiff) { daysDiffMap[daysDiff] = append(daysDiffMap[daysDiff], ssl.PrimaryDomain) projectMap[ssl.ID] = append(projectMap[ssl.ID], ssl.ExpireDate) } @@ -872,6 +873,10 @@ func calculateSSLExpiryDays(sslList []model.WebsiteSSL, cycle uint) (map[int][]s return daysDiffMap, projectMap } +func shouldSuppressSSLExpiryAlert(ssl model.WebsiteSSL, remainingDays int) bool { + return ssl.AutoRenew && remainingDays < sslAutoRenewAlertSkipDays +} + func calculateWebsiteExpiryDays(websites []model.Website, cycle uint) (map[int][]string, map[uint][]time.Time) { currentDate := time.Now() daysDiffMap := make(map[int][]string)