Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pb-8713: Added excludeResourceType option handing in the nfsexecutor apis. #403

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export GOFLAGS = -mod=vendor

MAJOR_VERSION := 1
MINOR_VERSION := 2
PATCH_VERSION := 15
PATCH_VERSION := 16

ifndef PKGS
PKGS := $(shell GOFLAGS=-mod=vendor go list ./... 2>&1 | grep -v 'go: ' | grep -v 'github.com/portworx/kdmp/vendor' | grep -v versioned | grep -v 'pkg/apis/v1')
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/go-version v1.6.0
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/kubernetes-incubator/external-storage v0.20.4-openstorage-rc7
github.com/libopenstorage/stork v1.4.1-0.20241029051218-6fcdc46e8ffc
github.com/libopenstorage/stork v1.4.1-0.20241115110516-1b6d535ef497
github.com/portworx/pxc v0.33.0
github.com/portworx/sched-ops v1.20.4-rc1.0.20240812234304-948bf116243e
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3394,8 +3394,8 @@ github.com/libopenstorage/stork v1.4.1-0.20230502135851-9cacb19e1df5/go.mod h1:R
github.com/libopenstorage/stork v1.4.1-0.20230519043154-cbc10dffaf19/go.mod h1:Xm4DHoViynFXMQKBXGj3IkA77LY2RBFkNtv6vbo3wNw=
github.com/libopenstorage/stork v1.4.1-0.20230601053837-5dd68f026569/go.mod h1:+mKPMCPNhS/XOF2RPcNFijkr67CCCWp0o8OXVG6xxAk=
github.com/libopenstorage/stork v1.4.1-0.20230610103146-72cf75320066/go.mod h1:Yst+fnOYjWk6SA5pXZBKm19wtiinjxQ/vgYTXI3k80Q=
github.com/libopenstorage/stork v1.4.1-0.20241029051218-6fcdc46e8ffc h1:awMZ+7AxZQMSZQ8MXfJJfs/f1bQNeWyRTm2M7ZpiGUk=
github.com/libopenstorage/stork v1.4.1-0.20241029051218-6fcdc46e8ffc/go.mod h1:6LHv0kJyrIftmHrS+Xx59SCMqDdclnXdi14vrTafFxg=
github.com/libopenstorage/stork v1.4.1-0.20241115110516-1b6d535ef497 h1:abWQI7IIO+x0tASheueW/zzAC+Pvf9A7GwkcUDomnd8=
github.com/libopenstorage/stork v1.4.1-0.20241115110516-1b6d535ef497/go.mod h1:Ng/SWv7bO2fytEtt3FivXWscukhU2bvLKLkEKizt7F0=
github.com/libopenstorage/systemutils v0.0.0-20160208220149-44ac83be3ce1/go.mod h1:xwNGC7xiz/BQ/wbMkvHujL8Gjgseg+x41xMek7sKRRQ=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
Expand Down
56 changes: 45 additions & 11 deletions pkg/executor/nfs/nfsbkpresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func uploadResource(
var err error

// Listing all resource types
if len(backup.Spec.ResourceTypes) != 0 {
if len(backup.Spec.ResourceTypes) != 0 || len(backup.Spec.ExcludeResourceTypes) != 0 {
optionalResourceTypes := []string{}
resourceTypes, err = rc.GetResourceTypes(optionalResourceTypes, true)
if err != nil {
Expand Down Expand Up @@ -269,7 +269,7 @@ func uploadResource(
// As we support both includeResource and ResourceType to be mentioned
// match out ns for which we want to take includeResource path and
// for which we want to take ResourceType path
if len(backup.Spec.ResourceTypes) != 0 {
if len(backup.Spec.ResourceTypes) != 0 || len(backup.Spec.ExcludeResourceTypes) != 0 {
if !resourcecollector.IsNsPresentInIncludeResource(objectMap, ns) {
resourceTypeNsBatch = append(resourceTypeNsBatch, ns)
} else {
Expand Down Expand Up @@ -297,18 +297,42 @@ func uploadResource(
}

if len(resourceTypeNsBatch) != 0 {
for _, backupResourceType := range backup.Spec.ResourceTypes {
for _, resource := range resourceTypes {
if resource.Kind == backupResourceType || (backupResourceType == "PersistentVolumeClaim" && resource.Kind == "PersistentVolume") {
log.ApplicationBackupLog(backup).Tracef("GetResourcesType for : %v", resource.Kind)
objects, _, err := rc.GetResourcesForType(resource, nil, resourceTypeNsBatch, backup.Spec.Selectors, nil, nil, true, resourceCollectorOpts)
if err != nil {
log.ApplicationBackupLog(backup).Errorf("Error getting resources: %v", err)
return err
if len(backup.Spec.ResourceTypes) != 0 {
for _, backupResourceType := range backup.Spec.ResourceTypes {
for _, resource := range resourceTypes {
if resource.Kind == backupResourceType ||
(backupResourceType == "PersistentVolumeClaim" && resource.Kind == "PersistentVolume") {
log.ApplicationBackupLog(backup).Tracef("GetResourcesType for : %v", resource.Kind)
objects, _, err := rc.GetResourcesForType(resource, nil, resourceTypeNsBatch,
backup.Spec.Selectors, nil, nil, true, resourceCollectorOpts)
if err != nil {
log.ApplicationBackupLog(backup).Errorf("Error getting resources: %v", err)
return err
}
allObjects = append(allObjects, objects.Items...)
}
allObjects = append(allObjects, objects.Items...)
}
}
} else if len(backup.Spec.ExcludeResourceTypes) != 0 {
exclude := backup.Spec.ExcludeResourceTypes
if IsPVCInExcludeResourceType(backup) {
exclude = append(exclude, "PersistentVolume")
}
excludeTypeObjects, _, err := rc.GetResourcesExcludingTypes(
resourceTypeNsBatch,
exclude,
backup.Spec.Selectors,
nil,
nil,
optionalBackupResources,
true,
resourceCollectorOpts,
)
if err != nil {
log.ApplicationBackupLog(backup).Errorf("Error getting resources for ExcludeResouceTypes: %v", err)
return err
}
allObjects = append(allObjects, excludeTypeObjects...)
}
}
}
Expand Down Expand Up @@ -385,6 +409,16 @@ func uploadResource(
return nil
}

// IsPVCInExcludeResourceType check if given ResourceType is PVC
func IsPVCInExcludeResourceType(backup *stork_api.ApplicationBackup) bool {
for _, resType := range backup.Spec.ExcludeResourceTypes {
if resType == "PersistentVolumeClaim" {
return true
}
}
return false
}

func uploadStorageClasses(
bkpNamespace string,
backup *stork_api.ApplicationBackup,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading