From aa3abefdbf221f7354342713f1a4e8401ab85f0f Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Mon, 20 Apr 2020 12:33:21 -0400 Subject: [PATCH] Address review feedback Signed-off-by: Nolan Brubaker --- pkg/controller/backup_controller.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/controller/backup_controller.go b/pkg/controller/backup_controller.go index 222ae41b3..b8a9e0d13 100644 --- a/pkg/controller/backup_controller.go +++ b/pkg/controller/backup_controller.go @@ -564,12 +564,15 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error { if c.volumeSnapshotContentLister != nil { // Since VolumeSnapshotContent objects are not currently labeled, get them by using binding from the VolumeSnapshot for _, vs := range volumeSnapshots { - vsc, err := c.volumeSnapshotContentLister.Get(*vs.Status.BoundVolumeSnapshotContentName) - if err != nil { - backupLog.Error(err) - continue + // nil check just in case the snapshot and the content object did not get bound before returning from the plugins + if vs.Status != nil && vs.Status.BoundVolumeSnapshotContentName != nil { + vsc, err := c.volumeSnapshotContentLister.Get(*vs.Status.BoundVolumeSnapshotContentName) + if err != nil { + backupLog.Error(err) + continue + } + volumeSnapshotContents = append(volumeSnapshotContents, vsc) } - volumeSnapshotContents = append(volumeSnapshotContents, vsc) } } } @@ -648,8 +651,8 @@ func persistBackup(backup *pkgbackup.Request, persistErrs := []error{} backupJSON := new(bytes.Buffer) - if errs := encode.EncodeTo(backup.Backup, "json", backupJSON); errs != nil { - persistErrs = append(persistErrs, errors.Wrap(errs, "error encoding backup")) + if err := encode.EncodeTo(backup.Backup, "json", backupJSON); err != nil { + persistErrs = append(persistErrs, errors.Wrap(err, "error encoding backup")) } // Velero-native volume snapshots (as opposed to CSI ones)