Skip to content

Commit

Permalink
Check for empty ns list before checking nslist[0]
Browse files Browse the repository at this point in the history
In determining whether a backup includes all namespaces, item_collector
checks for an empty string in the first element of the ns list. If processing
includes+excludes results in an empty list, treat this as another case
of a not-all-namespaces backup rather than crashing velero.

Signed-off-by: Scott Seago <[email protected]>
  • Loading branch information
sseago committed Aug 24, 2022
1 parent b6cca3f commit 55bf2de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5236-sseago
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check for empty ns list before checking nslist[0]
7 changes: 5 additions & 2 deletions pkg/backup/item_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ func (r *itemCollector) getResourceItems(log logrus.FieldLogger, gv schema.Group

namespacesToList := getNamespacesToList(r.backupRequest.NamespaceIncludesExcludes)

// Check if we're backing up namespaces, and only certain ones
if gr == kuberesource.Namespaces && namespacesToList[0] != "" {
// Check if we're backing up namespaces for a less-than-full backup.
// We enter this block if resource is Namespaces and the namespae list is either empty or contains
// an explicit namespace list. (We skip this block if the list contains "" since that indicates
// a full-cluster backup
if gr == kuberesource.Namespaces && (len(namespacesToList) == 0 || namespacesToList[0] != "") {
resourceClient, err := r.dynamicFactory.ClientForGroupVersionResource(gv, resource, "")
if err != nil {
log.WithError(err).Error("Error getting dynamic client")
Expand Down

0 comments on commit 55bf2de

Please sign in to comment.