Documentation
¶
Index ¶
- func GetPodsUsingPVCWithCache(pvcNamespace, pvcName string, crClient crclient.Client, cache *PVCPodCache) ([]corev1api.Pod, error)
- func GetVolumesByPod(pod *corev1api.Pod, defaultVolumesToFsBackup, backupExcludePVC bool, ...) ([]string, []string)
- func GetVolumesToBackup(obj metav1.Object) []string
- func GetVolumesToExclude(obj metav1.Object) []string
- func GetVolumesToProcess(volumes []corev1api.Volume, volsToProcessByLegacyApproach []string) []corev1api.Volume
- func IsPVCDefaultToFSBackupWithCache(pvcNamespace, pvcName string, crClient crclient.Client, ...) (bool, error)
- type PVCPodCache
- func (c *PVCPodCache) BuildCacheForNamespace(ctx context.Context, namespace string, crClient crclient.Client) error
- func (c *PVCPodCache) BuildCacheForNamespaces(ctx context.Context, namespaces []string, crClient crclient.Client) error
- func (c *PVCPodCache) GetPodsUsingPVC(namespace, pvcName string) []corev1api.Pod
- func (c *PVCPodCache) IsBuilt() bool
- func (c *PVCPodCache) IsNamespaceBuilt(namespace string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPodsUsingPVCWithCache ¶ added in v1.18.0
func GetPodsUsingPVCWithCache( pvcNamespace, pvcName string, crClient crclient.Client, cache *PVCPodCache, ) ([]corev1api.Pod, error)
GetPodsUsingPVCWithCache returns all pods that use the specified PVC. If cache is available and built, it uses the cache for O(1) lookup. Otherwise, it falls back to listing pods directly. Note: In the main backup path, the cache is always built (via NewVolumeHelperImplWithNamespaces), so the fallback is only used by plugins that don't need cache optimization.
func GetVolumesByPod ¶
func GetVolumesByPod(pod *corev1api.Pod, defaultVolumesToFsBackup, backupExcludePVC bool, volsToProcessByLegacyApproach []string) ([]string, []string)
GetVolumesByPod returns a list of volume names to backup for the provided pod.
func GetVolumesToBackup ¶
GetVolumesToBackup returns a list of volume names to backup for the provided pod. Deprecated: Use GetVolumesByPod instead.
func GetVolumesToExclude ¶ added in v1.14.0
func GetVolumesToProcess ¶ added in v1.14.0
func IsPVCDefaultToFSBackupWithCache ¶ added in v1.18.0
func IsPVCDefaultToFSBackupWithCache( pvcNamespace, pvcName string, crClient crclient.Client, defaultVolumesToFsBackup bool, cache *PVCPodCache, ) (bool, error)
IsPVCDefaultToFSBackupWithCache checks if a PVC should default to fs-backup based on pod annotations. If cache is nil or not built, it falls back to listing pods directly. Note: In the main backup path, the cache is always built (via NewVolumeHelperImplWithNamespaces), so the fallback is only used by plugins that don't need cache optimization.
Types ¶
type PVCPodCache ¶ added in v1.18.0
type PVCPodCache struct {
// contains filtered or unexported fields
}
PVCPodCache provides a cached mapping from PVC to the pods that use it. This cache is built once per backup to avoid repeated pod listings which cause O(N*M) performance issues when there are many PVCs and pods.
func NewPVCPodCache ¶ added in v1.18.0
func NewPVCPodCache() *PVCPodCache
NewPVCPodCache creates a new empty PVC to Pod cache.
func (*PVCPodCache) BuildCacheForNamespace ¶ added in v1.18.0
func (c *PVCPodCache) BuildCacheForNamespace( ctx context.Context, namespace string, crClient crclient.Client, ) error
BuildCacheForNamespace builds the cache for a single namespace lazily. This is used by plugins where namespaces are encountered one at a time. If the namespace is already cached, this is a no-op.
func (*PVCPodCache) BuildCacheForNamespaces ¶ added in v1.18.0
func (c *PVCPodCache) BuildCacheForNamespaces( ctx context.Context, namespaces []string, crClient crclient.Client, ) error
BuildCacheForNamespaces builds the cache by listing pods once per namespace. This is much more efficient than listing pods for each PVC lookup.
func (*PVCPodCache) GetPodsUsingPVC ¶ added in v1.18.0
func (c *PVCPodCache) GetPodsUsingPVC(namespace, pvcName string) []corev1api.Pod
GetPodsUsingPVC retrieves pods using a specific PVC from the cache. Returns nil slice if the PVC is not found in the cache.
func (*PVCPodCache) IsBuilt ¶ added in v1.18.0
func (c *PVCPodCache) IsBuilt() bool
IsBuilt returns true if the cache has been built.
func (*PVCPodCache) IsNamespaceBuilt ¶ added in v1.18.0
func (c *PVCPodCache) IsNamespaceBuilt(namespace string) bool
IsNamespaceBuilt returns true if the cache has been built for the given namespace.