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:
Xun Jiang
2026-08-04 06:25:05 +00:00
committed by xun.jiang
parent ff0876a56d
commit 11545ee63c
19 changed files with 87 additions and 49 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ type BackupSpec struct {
SnapshotMoveData *bool `json:"snapshotMoveData,omitempty"`
// DataMover specifies the data mover to be used by the backup.
// If DataMover is "" or "velero", the built-in data mover will be used.
// If DataMover is "" or "velero", the default built-in data mover will be used.
// +optional
DataMover string `json:"datamover,omitempty"`
@@ -32,7 +32,7 @@ type DataDownloadSpec struct {
BackupStorageLocation string `json:"backupStorageLocation"`
// DataMover specifies the data mover to be used by the backup.
// If DataMover is "" or "velero", the built-in data mover will be used.
// If DataMover is "" or "velero", the built-in fs data mover will be used.
// +optional
DataMover string `json:"datamover,omitempty"`
@@ -36,7 +36,7 @@ type DataUploadSpec struct {
SourcePVC string `json:"sourcePVC"`
// DataMover specifies the data mover to be used by the backup.
// If DataMover is "" or "velero", the built-in data mover will be used.
// If DataMover is "" or "velero", the built-in fs data mover will be used.
// +optional
DataMover string `json:"datamover,omitempty"`
+5
View File
@@ -58,6 +58,7 @@ import (
"github.com/vmware-tanzu/velero/pkg/plugin/framework"
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
"github.com/vmware-tanzu/velero/pkg/util/collections"
"github.com/vmware-tanzu/velero/pkg/util/datamover"
"github.com/vmware-tanzu/velero/pkg/util/encode"
kubeutil "github.com/vmware-tanzu/velero/pkg/util/kube"
"github.com/vmware-tanzu/velero/pkg/util/logging"
@@ -431,6 +432,10 @@ func (b *backupReconciler) prepareBackupRequest(ctx context.Context, backup *vel
request.Spec.BackupType = velerov1api.BackupTypeIncremental
}
if len(request.Spec.DataMover) == 0 || request.Spec.DataMover == datamover.DataMoverTypeVelero {
request.Spec.DataMover = datamover.GetDefaultBuiltInDataMover()
}
// calculate expiration
request.Status.Expiration = &metav1.Time{Time: b.clock.Now().Add(request.Spec.TTL.Duration)}
+20
View File
@@ -64,6 +64,7 @@ import (
ibav1 "github.com/vmware-tanzu/velero/pkg/plugin/velero/itemblockaction/v1"
velerotest "github.com/vmware-tanzu/velero/pkg/test"
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
"github.com/vmware-tanzu/velero/pkg/util/datamover"
kubeutil "github.com/vmware-tanzu/velero/pkg/util/kube"
"github.com/vmware-tanzu/velero/pkg/util/logging"
)
@@ -805,6 +806,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -846,6 +848,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -891,6 +894,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -933,6 +937,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -975,6 +980,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1018,6 +1024,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1061,6 +1068,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1104,6 +1112,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1147,6 +1156,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1191,6 +1201,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFailed,
@@ -1235,6 +1246,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFailed,
@@ -1279,6 +1291,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1324,6 +1337,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1369,6 +1383,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1414,6 +1429,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1460,6 +1476,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1505,6 +1522,7 @@ func TestProcessBackupCompletions(t *testing.T) {
ExcludedClusterScopedResources: autoExcludeClusterScopedResources,
ExcludedNamespaceScopedResources: autoExcludeNamespaceScopedResources,
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1556,6 +1574,7 @@ func TestProcessBackupCompletions(t *testing.T) {
IncludedNamespaceScopedResources: []string{"pods"},
ExcludedNamespaceScopedResources: append([]string{"secrets"}, autoExcludeNamespaceScopedResources...),
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
@@ -1607,6 +1626,7 @@ func TestProcessBackupCompletions(t *testing.T) {
IncludedNamespaceScopedResources: []string{"pods"},
ExcludedNamespaceScopedResources: append([]string{"secrets"}, autoExcludeNamespaceScopedResources...),
BackupType: velerov1api.BackupTypeIncremental,
DataMover: datamover.GetDefaultBuiltInDataMover(),
},
Status: velerov1api.BackupStatus{
Phase: velerov1api.BackupPhaseFinalizing,
+3 -3
View File
@@ -466,7 +466,7 @@ func (r *DataDownloadReconciler) OnDataDownloadCompleted(ctx context.Context, na
defer r.dataPathMgr.RemoveAsyncBR(ddName)
log := r.logger.WithField("datadownload", ddName)
log.Info("Async fs restore data path completed")
log.Info("Async restore data path completed")
var dd velerov2alpha1api.DataDownload
if err := r.client.Get(ctx, types.NamespacedName{Name: ddName, Namespace: namespace}, &dd); err != nil {
@@ -513,7 +513,7 @@ func (r *DataDownloadReconciler) OnDataDownloadFailed(ctx context.Context, names
log := r.logger.WithField("datadownload", ddName)
log.WithError(err).Error("Async fs restore data path failed")
log.WithError(err).Error("Async restore data path failed")
var dd velerov2alpha1api.DataDownload
if getErr := r.client.Get(ctx, types.NamespacedName{Name: ddName, Namespace: namespace}, &dd); getErr != nil {
@@ -528,7 +528,7 @@ func (r *DataDownloadReconciler) OnDataDownloadCancelled(ctx context.Context, na
log := r.logger.WithField("datadownload", ddName)
log.Warn("Async fs backup data path canceled")
log.Warn("Async restore data path canceled")
var dd velerov2alpha1api.DataDownload
if getErr := r.client.Get(ctx, types.NamespacedName{Name: ddName, Namespace: namespace}, &dd); getErr != nil {
+3 -3
View File
@@ -482,7 +482,7 @@ func (r *DataUploadReconciler) OnDataUploadCompleted(ctx context.Context, namesp
log := r.logger.WithField("dataupload", duName)
log.Info("Async fs backup data path completed")
log.Info("Async backup data path completed")
var du velerov2alpha1api.DataUpload
if err := r.client.Get(ctx, types.NamespacedName{Name: duName, Namespace: namespace}, &du); err != nil {
@@ -534,7 +534,7 @@ func (r *DataUploadReconciler) OnDataUploadFailed(ctx context.Context, namespace
log := r.logger.WithField("dataupload", duName)
log.WithError(err).Error("Async fs backup data path failed")
log.WithError(err).Error("Async backup data path failed")
var du velerov2alpha1api.DataUpload
if getErr := r.client.Get(ctx, types.NamespacedName{Name: duName, Namespace: namespace}, &du); getErr != nil {
@@ -549,7 +549,7 @@ func (r *DataUploadReconciler) OnDataUploadCancelled(ctx context.Context, namesp
log := r.logger.WithField("dataupload", duName)
log.Warn("Async fs backup data path canceled")
log.Warn("Async backup data path canceled")
du := &velerov2alpha1api.DataUpload{}
if getErr := r.client.Get(ctx, types.NamespacedName{Name: duName, Namespace: namespace}, du); getErr != nil {
+5 -5
View File
@@ -225,7 +225,7 @@ func (r *BackupMicroService) RunCancelableDataPath(ctx context.Context) (string,
return "", errors.Wrap(err, "error starting data path backup")
}
log.Info("Async fs backup data path started")
log.Info("Async backup data path started")
r.eventRecorder.Event(du, false, datapath.EventReasonStarted, "Data path for %s started", du.Name)
result := ""
@@ -240,7 +240,7 @@ func (r *BackupMicroService) RunCancelableDataPath(ctx context.Context) (string,
}
if err != nil {
log.WithError(err).Error("Async fs backup was not completed")
log.WithError(err).Error("Async backup was not completed")
}
r.eventRecorder.EndingEvent(du, false, datapath.EventReasonStopped, "Data path for %s stopped", du.Name)
@@ -277,12 +277,12 @@ func (r *BackupMicroService) OnDataUploadCompleted(ctx context.Context, namespac
}
}
log.Info("Async fs backup completed")
log.Info("Async backup completed")
}
func (r *BackupMicroService) OnDataUploadFailed(ctx context.Context, namespace string, duName string, err error) {
log := r.logger.WithField("dataupload", duName)
log.WithError(err).Error("Async fs backup data path failed")
log.WithError(err).Error("Async backup data path failed")
r.eventRecorder.Event(r.dataUpload, false, datapath.EventReasonFailed, "Data path for data upload %s failed, error %v", r.dataUploadName, err)
r.resultSignal <- dataPathResult{
@@ -292,7 +292,7 @@ func (r *BackupMicroService) OnDataUploadFailed(ctx context.Context, namespace s
func (r *BackupMicroService) OnDataUploadCancelled(ctx context.Context, namespace string, duName string) {
log := r.logger.WithField("dataupload", duName)
log.Warn("Async fs backup data path canceled")
log.Warn("Async backup data path canceled")
r.eventRecorder.Event(r.dataUpload, false, datapath.EventReasonCancelled, "Data path for data upload %s canceled", duName)
r.resultSignal <- dataPathResult{
+4 -4
View File
@@ -184,7 +184,7 @@ func (r *RestoreMicroService) RunCancelableDataPath(ctx context.Context) (string
return "", errors.Wrap(err, "error starting data path restore")
}
log.Info("Async fs restore data path started")
log.Info("Async restore data path started")
r.eventRecorder.Event(dd, false, datapath.EventReasonStarted, "Data path for %s started", dd.Name)
result := ""
@@ -234,12 +234,12 @@ func (r *RestoreMicroService) OnDataDownloadCompleted(ctx context.Context, names
}
}
log.Info("Async fs restore data path completed")
log.Info("Async restore data path completed")
}
func (r *RestoreMicroService) OnDataDownloadFailed(ctx context.Context, namespace string, ddName string, err error) {
log := r.logger.WithField("datadownload", ddName)
log.WithError(err).Error("Async fs restore data path failed")
log.WithError(err).Error("Async restore data path failed")
r.eventRecorder.Event(r.dataDownload, false, datapath.EventReasonFailed, "Data path for data download %s failed, error %v", r.dataDownloadName, err)
r.resultSignal <- dataPathResult{
@@ -249,7 +249,7 @@ func (r *RestoreMicroService) OnDataDownloadFailed(ctx context.Context, namespac
func (r *RestoreMicroService) OnDataDownloadCancelled(ctx context.Context, namespace string, ddName string) {
log := r.logger.WithField("datadownload", ddName)
log.Warn("Async fs restore data path canceled")
log.Warn("Async restore data path canceled")
r.eventRecorder.Event(r.dataDownload, false, datapath.EventReasonCancelled, "Data path for data download %s canceled", ddName)
r.resultSignal <- dataPathResult{
+3
View File
@@ -20,6 +20,7 @@ limitations under the License.
package datamover
const (
DataMoverTypeEmpty = ""
// DataMoverTypeVelero refers to the default built-in data mover. The default
// data mover may change among releases; see GetDefaultBuiltInDataMover.
DataMoverTypeVelero = "velero"
@@ -35,6 +36,7 @@ func IsBuiltInDataMover(dataMover string) bool {
return IsVeleroBlockDataMover(dataMover) || IsVeleroFSDataMover(dataMover)
}
// IsVeleroFSDataMover checks whether the given data mover belongs to fs type.
func IsVeleroFSDataMover(dataMover string) bool {
if dataMover == "" || dataMover == DataMoverTypeVelero {
dataMover = DataMoverTypeVeleroFs
@@ -42,6 +44,7 @@ func IsVeleroFSDataMover(dataMover string) bool {
return dataMover == DataMoverTypeVeleroFs
}
// IsVeleroBlockDataMover checks whether the given data mover belongs to block type.
func IsVeleroBlockDataMover(dataMover string) bool {
return dataMover == DataMoverTypeVeleroBlock
}