mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-04-26 10:41:14 +00:00
Merge branch 'main' into backup-pvc-to-different-node
This commit is contained in:
@@ -42,7 +42,7 @@ The following is a list of the supported Kubernetes versions for each Velero ver
|
||||
|
||||
| Velero version | Expected Kubernetes version compatibility | Tested on Kubernetes version |
|
||||
|----------------|-------------------------------------------|-------------------------------------|
|
||||
| 1.17 | 1.18-latest | 1.31.7, 1.32.3, and 1.33.1 |
|
||||
| 1.17 | 1.18-latest | 1.31.7, 1.32.3, 1.33.1, and 1.34.0 |
|
||||
| 1.16 | 1.18-latest | 1.31.4, 1.32.3, and 1.33.0 |
|
||||
| 1.15 | 1.18-latest | 1.28.8, 1.29.8, 1.30.4 and 1.31.1 |
|
||||
| 1.14 | 1.18-latest | 1.27.9, 1.28.9, and 1.29.4 |
|
||||
|
||||
1
changelogs/unreleased/9226-sseago
Normal file
1
changelogs/unreleased/9226-sseago
Normal file
@@ -0,0 +1 @@
|
||||
Get pod list once per namespace in pvc IBA
|
||||
1
changelogs/unreleased/9244-priyansh17
Normal file
1
changelogs/unreleased/9244-priyansh17
Normal file
@@ -0,0 +1 @@
|
||||
Update AzureAD Microsoft Authentication Library to v1.5.0
|
||||
2
go.mod
2
go.mod
@@ -73,7 +73,7 @@ require (
|
||||
cloud.google.com/go/monitoring v1.24.2 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.5.0 // indirect
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 // indirect
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.51.0 // indirect
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.51.0 // indirect
|
||||
|
||||
4
go.sum
4
go.sum
@@ -95,8 +95,8 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ
|
||||
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
|
||||
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM=
|
||||
github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.5.0 h1:XkkQbfMyuH2jTSjQjSoihryI8GINRcs4xp8lNawg0FI=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.5.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 h1:IEjq88XO4PuBDcvmjQJcQGg+w+UaafSy8G5Kcb5tBhI=
|
||||
|
||||
@@ -39,6 +39,8 @@ import (
|
||||
type PVCAction struct {
|
||||
log logrus.FieldLogger
|
||||
crClient crclient.Client
|
||||
// map[namespace]->[map[pvcVolumes]->[]podName]
|
||||
nsPVCs map[string]map[string][]string
|
||||
}
|
||||
|
||||
func NewPVCAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
@@ -78,31 +80,18 @@ func (a *PVCAction) GetRelatedItems(item runtime.Unstructured, backup *v1.Backup
|
||||
|
||||
// Adds pods mounting this PVC to ensure that multiple pods mounting the same RWX
|
||||
// volume get backed up together.
|
||||
pods := new(corev1api.PodList)
|
||||
err := a.crClient.List(context.Background(), pods, crclient.InNamespace(pvc.Namespace))
|
||||
pvcs, err := a.getPVCList(pvc.Namespace)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to list pods")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range pods.Items {
|
||||
for _, volume := range pods.Items[i].Spec.Volumes {
|
||||
if volume.VolumeSource.PersistentVolumeClaim == nil {
|
||||
continue
|
||||
}
|
||||
if volume.PersistentVolumeClaim.ClaimName == pvc.Name {
|
||||
if kube.IsPodRunning(&pods.Items[i]) != nil {
|
||||
a.log.Infof("Related pod %s is not running, not adding to ItemBlock for PVC %s", pods.Items[i].Name, pvc.Name)
|
||||
} else {
|
||||
a.log.Infof("Adding related Pod %s to PVC %s", pods.Items[i].Name, pvc.Name)
|
||||
relatedItems = append(relatedItems, velero.ResourceIdentifier{
|
||||
GroupResource: kuberesource.Pods,
|
||||
Namespace: pods.Items[i].Namespace,
|
||||
Name: pods.Items[i].Name,
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, pod := range pvcs[pvc.Name] {
|
||||
a.log.Infof("Adding related Pod %s to PVC %s", pod, pvc.Name)
|
||||
relatedItems = append(relatedItems, velero.ResourceIdentifier{
|
||||
GroupResource: kuberesource.Pods,
|
||||
Namespace: pvc.Namespace,
|
||||
Name: pod,
|
||||
})
|
||||
}
|
||||
|
||||
// Gather groupedPVCs based on VGS label provided in the backup
|
||||
@@ -117,6 +106,35 @@ func (a *PVCAction) GetRelatedItems(item runtime.Unstructured, backup *v1.Backup
|
||||
return relatedItems, nil
|
||||
}
|
||||
|
||||
func (a *PVCAction) getPVCList(ns string) (map[string][]string, error) {
|
||||
if a.nsPVCs == nil {
|
||||
a.nsPVCs = make(map[string]map[string][]string)
|
||||
}
|
||||
pvcList, ok := a.nsPVCs[ns]
|
||||
if ok {
|
||||
return pvcList, nil
|
||||
}
|
||||
pvcList = make(map[string][]string)
|
||||
pods := new(corev1api.PodList)
|
||||
err := a.crClient.List(context.Background(), pods, crclient.InNamespace(ns))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to list pods")
|
||||
}
|
||||
for i := range pods.Items {
|
||||
if kube.IsPodRunning(&pods.Items[i]) != nil {
|
||||
a.log.Debugf("Pod %s is not running, not adding to Pod list for PVC IBA plugin", pods.Items[i].Name)
|
||||
continue
|
||||
}
|
||||
for _, volume := range pods.Items[i].Spec.Volumes {
|
||||
if volume.VolumeSource.PersistentVolumeClaim != nil {
|
||||
pvcList[volume.VolumeSource.PersistentVolumeClaim.ClaimName] = append(pvcList[volume.VolumeSource.PersistentVolumeClaim.ClaimName], pods.Items[i].Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
a.nsPVCs[ns] = pvcList
|
||||
return pvcList, nil
|
||||
}
|
||||
|
||||
func (a *PVCAction) Name() string {
|
||||
return "PVCItemBlockAction"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user