Skip to content

Commit

Permalink
Merge pull request #5236 from sseago/no-namespaces-fix
Browse files Browse the repository at this point in the history
Check for empty ns list before checking nslist[0]
  • Loading branch information
qiuming-best authored Sep 5, 2022
2 parents 4bc73f2 + 55bf2de commit a5a3df1
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 a5a3df1

Please sign in to comment.