Skip to content

Commit 9aec3b0

Browse files
committed
Check that snapshot.Status is not nil when checking Status properties.
1 parent 446c9c7 commit 9aec3b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/controller/postgrescluster/snapshots.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (r *Reconciler) reconcileVolumeSnapshots(ctx context.Context,
103103
r.Recorder.Event(postgrescluster, corev1.EventTypeWarning, "VolumeSnapshotError",
104104
*snapshotWithLatestError.Status.Error.Message)
105105
for _, snapshot := range snapshots.Items {
106-
if snapshot.Status.Error != nil &&
106+
if snapshot.Status != nil && snapshot.Status.Error != nil &&
107107
snapshot.Status.Error.Time.Before(snapshotWithLatestError.Status.Error.Time) {
108108
err = r.deleteControlled(ctx, postgrescluster, &snapshot)
109109
if err != nil {
@@ -537,7 +537,7 @@ func getSnapshotWithLatestError(snapshots *volumesnapshotv1.VolumeSnapshotList)
537537
},
538538
}
539539
for _, snapshot := range snapshots.Items {
540-
if snapshot.Status.Error != nil &&
540+
if snapshot.Status != nil && snapshot.Status.Error != nil &&
541541
snapshotWithLatestError.Status.Error.Time.Before(snapshot.Status.Error.Time) {
542542
snapshotWithLatestError = snapshot
543543
}
@@ -577,7 +577,7 @@ func getLatestReadySnapshot(snapshots *volumesnapshotv1.VolumeSnapshotList) *vol
577577
},
578578
}
579579
for _, snapshot := range snapshots.Items {
580-
if snapshot.Status.ReadyToUse != nil && *snapshot.Status.ReadyToUse &&
580+
if snapshot.Status != nil && snapshot.Status.ReadyToUse != nil && *snapshot.Status.ReadyToUse &&
581581
latestReadySnapshot.Status.CreationTime.Before(snapshot.Status.CreationTime) {
582582
latestReadySnapshot = snapshot
583583
}

0 commit comments

Comments
 (0)