mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-30 03:36:12 +00:00
Fix logs, CRD, and GetDataMover for CBT features.
Modify the logs. Modify the CRD's data mover's comment. Modify the resource policy's GetDataMover for default data mover case. Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
@@ -31,7 +31,7 @@ import (
|
||||
crclient "sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
datamover "github.com/vmware-tanzu/velero/pkg/util/datamover"
|
||||
"github.com/vmware-tanzu/velero/pkg/util/datamover"
|
||||
"github.com/vmware-tanzu/velero/pkg/util/wildcard"
|
||||
)
|
||||
|
||||
@@ -59,6 +59,7 @@ const (
|
||||
// validDataMovers is the set of data mover values accepted in the snapshot
|
||||
// action's dataMover parameter.
|
||||
var validDataMovers = map[string]struct{}{
|
||||
datamover.DataMoverTypeEmpty: {},
|
||||
datamover.DataMoverTypeVelero: {},
|
||||
datamover.DataMoverTypeVeleroFs: {},
|
||||
datamover.DataMoverTypeVeleroBlock: {},
|
||||
@@ -90,14 +91,21 @@ func (a *Action) GetDataMover() (string, error) {
|
||||
if !ok {
|
||||
return datamover.GetDefaultBuiltInDataMover(), nil
|
||||
}
|
||||
|
||||
dataMover, ok := raw.(string)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("parameter %q must be a string, got %T", DataMoverParameter, raw)
|
||||
}
|
||||
if _, ok := validDataMovers[dataMover]; !ok {
|
||||
return "", fmt.Errorf("invalid %q value %q, valid values are %q, %q, %q",
|
||||
DataMoverParameter, dataMover, datamover.DataMoverTypeVelero, datamover.DataMoverTypeVeleroFs, datamover.DataMoverTypeVeleroBlock)
|
||||
return "", fmt.Errorf("invalid %q value %q, valid values are %q, %q, %q, %q",
|
||||
DataMoverParameter, dataMover, datamover.DataMoverTypeEmpty, datamover.DataMoverTypeVelero, datamover.DataMoverTypeVeleroFs, datamover.DataMoverTypeVeleroBlock)
|
||||
}
|
||||
|
||||
// Return default data mover for backup's volume policy, when the data mover's original value is legacy value: "" or "velero".
|
||||
if dataMover == datamover.DataMoverTypeEmpty || dataMover == datamover.DataMoverTypeVelero {
|
||||
dataMover = datamover.GetDefaultBuiltInDataMover()
|
||||
}
|
||||
|
||||
return dataMover, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
velerotest "github.com/vmware-tanzu/velero/pkg/test"
|
||||
"github.com/vmware-tanzu/velero/pkg/util/datamover"
|
||||
)
|
||||
|
||||
func pvcVolumeMode(mode corev1api.PersistentVolumeMode) *corev1api.PersistentVolumeMode {
|
||||
@@ -2999,10 +3000,10 @@ namespacedFilterPolicies:
|
||||
|
||||
func TestActionGetDataMover(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
action *Action
|
||||
expectedMove string
|
||||
expectErr bool
|
||||
name string
|
||||
action *Action
|
||||
expectedDataMover string
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "nil action",
|
||||
@@ -3010,29 +3011,29 @@ func TestActionGetDataMover(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "snapshot action without parameters returns default mover",
|
||||
action: &Action{Type: Snapshot},
|
||||
expectedMove: "velero-fs",
|
||||
name: "snapshot action without parameters returns default mover",
|
||||
action: &Action{Type: Snapshot},
|
||||
expectedDataMover: datamover.GetDefaultBuiltInDataMover(),
|
||||
},
|
||||
{
|
||||
name: "snapshot action without dataMover parameter returns default mover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"other": "value"}},
|
||||
expectedMove: "velero-fs",
|
||||
name: "snapshot action without dataMover parameter returns default mover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"other": "value"}},
|
||||
expectedDataMover: datamover.GetDefaultBuiltInDataMover(),
|
||||
},
|
||||
{
|
||||
name: "snapshot action with velero dataMover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"dataMover": "velero"}},
|
||||
expectedMove: "velero",
|
||||
name: "snapshot action with velero dataMover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"dataMover": "velero"}},
|
||||
expectedDataMover: datamover.GetDefaultBuiltInDataMover(),
|
||||
},
|
||||
{
|
||||
name: "snapshot action with velero-fs dataMover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"dataMover": "velero-fs"}},
|
||||
expectedMove: "velero-fs",
|
||||
name: "snapshot action with velero-fs dataMover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"dataMover": datamover.DataMoverTypeVeleroFs}},
|
||||
expectedDataMover: datamover.DataMoverTypeVeleroFs,
|
||||
},
|
||||
{
|
||||
name: "snapshot action with velero-block dataMover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"dataMover": "velero-block"}},
|
||||
expectedMove: "velero-block",
|
||||
name: "snapshot action with velero-block dataMover",
|
||||
action: &Action{Type: Snapshot, Parameters: map[string]any{"dataMover": datamover.DataMoverTypeVeleroBlock}},
|
||||
expectedDataMover: datamover.DataMoverTypeVeleroBlock,
|
||||
},
|
||||
{
|
||||
name: "non-snapshot action returns error",
|
||||
@@ -3059,7 +3060,7 @@ func TestActionGetDataMover(t *testing.T) {
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tc.expectedMove, dataMover)
|
||||
assert.Equal(t, tc.expectedDataMover, dataMover)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user