mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-05 21:14:56 +00:00
Wrap CSI lister access in a nil check
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
@@ -551,18 +551,22 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
|
|||||||
if features.IsEnabled("EnableCSI") {
|
if features.IsEnabled("EnableCSI") {
|
||||||
selector := labels.SelectorFromSet(map[string]string{velerov1api.BackupNameLabel: backup.Name})
|
selector := labels.SelectorFromSet(map[string]string{velerov1api.BackupNameLabel: backup.Name})
|
||||||
|
|
||||||
// TODO(nrb-csi): Only run listers methods if the listers aren't nil, just in case
|
// Listers are wrapped in a nil check out of caution, since they may not be populated based on the
|
||||||
volumeSnapshots, err = c.volumeSnapshotLister.List(selector)
|
// EnableCSI feature flag. This is more to guard against programmer error, as they shouldn't be nil
|
||||||
if err != nil {
|
// when EnableCSI is on.
|
||||||
//TODO: Is this right?
|
if c.volumeSnapshotLister != nil {
|
||||||
backupLog.Error(err)
|
volumeSnapshots, err = c.volumeSnapshotLister.List(selector)
|
||||||
|
if err != nil {
|
||||||
|
backupLog.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Currently, VSCs are not being labelled in the plugin, so none will be returned here.
|
|
||||||
volumeSnapshotContents, err = c.volumeSnapshotContentLister.List(selector)
|
|
||||||
if err != nil {
|
|
||||||
//TODO: Is this right?
|
|
||||||
backupLog.Error(err)
|
|
||||||
|
|
||||||
|
if c.volumeSnapshotContentLister != nil {
|
||||||
|
volumeSnapshotContents, err = c.volumeSnapshotContentLister.List(selector)
|
||||||
|
if err != nil {
|
||||||
|
backupLog.Error(err)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user