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 19, 2022
1 parent b6cca3f commit a8f7b20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/backup/item_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ 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] != "" {
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 a8f7b20

Please sign in to comment.