mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-04-28 11:27:00 +00:00
Address review feedback
- Use ResolveNamespaceList() instead of GetIncludes() for more accurate namespace resolution when building the PVC-to-Pod cache - Refactor NewVolumeHelperImpl to call NewVolumeHelperImplWithCache with nil cache parameter to avoid code duplication Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
This commit is contained in:
@@ -46,15 +46,15 @@ func NewVolumeHelperImpl(
|
||||
defaultVolumesToFSBackup bool,
|
||||
backupExcludePVC bool,
|
||||
) VolumeHelper {
|
||||
return &volumeHelperImpl{
|
||||
volumePolicy: volumePolicy,
|
||||
snapshotVolumes: snapshotVolumes,
|
||||
logger: logger,
|
||||
client: client,
|
||||
defaultVolumesToFSBackup: defaultVolumesToFSBackup,
|
||||
backupExcludePVC: backupExcludePVC,
|
||||
pvcPodCache: nil, // Cache will be nil by default for backward compatibility
|
||||
}
|
||||
return NewVolumeHelperImplWithCache(
|
||||
volumePolicy,
|
||||
snapshotVolumes,
|
||||
logger,
|
||||
client,
|
||||
defaultVolumesToFSBackup,
|
||||
backupExcludePVC,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// NewVolumeHelperImplWithCache creates a VolumeHelper with a PVC-to-Pod cache for improved performance.
|
||||
|
||||
@@ -413,8 +413,11 @@ func (kb *kubernetesBackupper) BackupWithResolvers(
|
||||
// This avoids O(N*M) complexity when there are many PVCs and pods.
|
||||
// See issue #9179 for details.
|
||||
pvcPodCache := podvolumeutil.NewPVCPodCache()
|
||||
namespaces := backupRequest.NamespaceIncludesExcludes.GetIncludes()
|
||||
if len(namespaces) > 0 {
|
||||
namespaces, err := backupRequest.NamespaceIncludesExcludes.ResolveNamespaceList()
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Failed to resolve namespace list for PVC-to-Pod cache, falling back to direct lookups")
|
||||
pvcPodCache = nil
|
||||
} else if len(namespaces) > 0 {
|
||||
if err := pvcPodCache.BuildCacheForNamespaces(context.Background(), namespaces, kb.kbClient); err != nil {
|
||||
// Log warning but continue - the cache will fall back to direct lookups
|
||||
log.WithError(err).Warn("Failed to build PVC-to-Pod cache, falling back to direct lookups")
|
||||
|
||||
Reference in New Issue
Block a user