Check for nil LastMaintenanceTime in dueForMaintenance (#2200)

* Check for nil LastMaintenanceTime in dueForMaintenance

ResticRepository.dueForMaintenance causes a panic in the velero pod
("invalid memory address or nil pointer dereference") if
repository.Status.LastMaintenanceTime is nil. This fix returns 'true'
if it's nil, so the repository is due for maintenance if LastMaintenanceTime
is nil *or* the time elapsed since the last maintenance is greater than
repository.Spec.MaintenanceFrequency.Duration

Signed-off-by: Scott Seago <sseago@redhat.com>

* changelog for PR#2200

Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
Scott Seago
2020-01-15 12:06:16 -05:00
committed by Nolan Brubaker
parent b2acd3b683
commit aa44cf1c32
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Bug fix: Check for nil LastMaintenanceTime in ResticRepository dueForMaintenance
@@ -243,7 +243,7 @@ func (c *resticRepositoryController) runMaintenanceIfDue(req *v1.ResticRepositor
}
func dueForMaintenance(req *v1.ResticRepository, now time.Time) bool {
return req.Status.LastMaintenanceTime.Add(req.Spec.MaintenanceFrequency.Duration).Before(now)
return req.Status.LastMaintenanceTime == nil || req.Status.LastMaintenanceTime.Add(req.Spec.MaintenanceFrequency.Duration).Before(now)
}
func (c *resticRepositoryController) checkNotReadyRepo(req *v1.ResticRepository, log logrus.FieldLogger) error {