Skip to content

Commit

Permalink
Check that snapshot.Status is not nil when checking Status properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsessler7 committed Oct 28, 2024
1 parent 446c9c7 commit 9aec3b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/controller/postgrescluster/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r *Reconciler) reconcileVolumeSnapshots(ctx context.Context,
r.Recorder.Event(postgrescluster, corev1.EventTypeWarning, "VolumeSnapshotError",
*snapshotWithLatestError.Status.Error.Message)
for _, snapshot := range snapshots.Items {
if snapshot.Status.Error != nil &&
if snapshot.Status != nil && snapshot.Status.Error != nil &&
snapshot.Status.Error.Time.Before(snapshotWithLatestError.Status.Error.Time) {
err = r.deleteControlled(ctx, postgrescluster, &snapshot)
if err != nil {
Expand Down Expand Up @@ -537,7 +537,7 @@ func getSnapshotWithLatestError(snapshots *volumesnapshotv1.VolumeSnapshotList)
},
}
for _, snapshot := range snapshots.Items {
if snapshot.Status.Error != nil &&
if snapshot.Status != nil && snapshot.Status.Error != nil &&
snapshotWithLatestError.Status.Error.Time.Before(snapshot.Status.Error.Time) {
snapshotWithLatestError = snapshot
}
Expand Down Expand Up @@ -577,7 +577,7 @@ func getLatestReadySnapshot(snapshots *volumesnapshotv1.VolumeSnapshotList) *vol
},
}
for _, snapshot := range snapshots.Items {
if snapshot.Status.ReadyToUse != nil && *snapshot.Status.ReadyToUse &&
if snapshot.Status != nil && snapshot.Status.ReadyToUse != nil && *snapshot.Status.ReadyToUse &&
latestReadySnapshot.Status.CreationTime.Before(snapshot.Status.CreationTime) {
latestReadySnapshot = snapshot
}
Expand Down

0 comments on commit 9aec3b0

Please sign in to comment.