mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 21:36:30 +00:00
backupPVC to different node
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
Fix issue #9229, add intolerateSourceNode backupPVC option
|
||||
Fix issue #9229, don't attach backupPVC to the source node
|
||||
@@ -52,7 +52,7 @@ type CSISnapshotExposeParam struct {
|
||||
// SourcePVCName is the original name of the PVC that the snapshot is taken for
|
||||
SourcePVCName string
|
||||
|
||||
// SourcePVCName is the name of PV for SourcePVC
|
||||
// SourcePVName is the name of PV for SourcePVC
|
||||
SourcePVName string
|
||||
|
||||
// AccessMode defines the mode to access the snapshot
|
||||
@@ -217,7 +217,8 @@ func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1api.O
|
||||
|
||||
if _, found := backupPVCAnnotations[util.VSphereCNSFastCloneAnno]; found {
|
||||
if n, err := kube.GetPVAttachedNodes(ctx, csiExposeParam.SourcePVName, e.kubeClient.StorageV1()); err != nil {
|
||||
curLog.WithField("source PV", csiExposeParam.SourcePVName).WithError(err).Warn("Failed to get attached node for source PV, ignore intolerable nodes")
|
||||
curLog.WithField("source PV", csiExposeParam.SourcePVName).WithError(err).Warnf("Failed to get attached node for source PV, ignore %s annotation", util.VSphereCNSFastCloneAnno)
|
||||
delete(backupPVCAnnotations, util.VSphereCNSFastCloneAnno)
|
||||
} else {
|
||||
intoleratableNodes = n
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ func TestExpose(t *testing.T) {
|
||||
expectedReadOnlyPVC bool
|
||||
expectedBackupPVCStorageClass string
|
||||
expectedAffinity *corev1api.Affinity
|
||||
expectedPVCAnnotation map[string]string
|
||||
}{
|
||||
{
|
||||
name: "wait vs ready fail",
|
||||
@@ -686,7 +687,8 @@ func TestExpose(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedAffinity: nil,
|
||||
expectedAffinity: nil,
|
||||
expectedPVCAnnotation: nil,
|
||||
},
|
||||
{
|
||||
name: "IntolerateSourceNode, get empty source node",
|
||||
@@ -713,7 +715,8 @@ func TestExpose(t *testing.T) {
|
||||
kubeClientObj: []runtime.Object{
|
||||
daemonSet,
|
||||
},
|
||||
expectedAffinity: nil,
|
||||
expectedAffinity: nil,
|
||||
expectedPVCAnnotation: map[string]string{util.VSphereCNSFastCloneAnno: "true"},
|
||||
},
|
||||
{
|
||||
name: "IntolerateSourceNode, get source nodes",
|
||||
@@ -759,6 +762,7 @@ func TestExpose(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedPVCAnnotation: map[string]string{util.VSphereCNSFastCloneAnno: "true"},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -841,6 +845,12 @@ func TestExpose(t *testing.T) {
|
||||
if test.expectedAffinity != nil {
|
||||
assert.Equal(t, test.expectedAffinity, backupPod.Spec.Affinity)
|
||||
}
|
||||
|
||||
if test.expectedPVCAnnotation != nil {
|
||||
assert.Equal(t, test.expectedPVCAnnotation, backupPVC.Annotations)
|
||||
} else {
|
||||
assert.Empty(t, backupPVC.Annotations)
|
||||
}
|
||||
} else {
|
||||
assert.EqualError(t, err, test.err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user