controllers support message in progress

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2026-09-04 14:28:31 +08:00
parent 67923bca6f
commit 1048f26c20
4 changed files with 52 additions and 8 deletions
+13 -2
View File
@@ -42,7 +42,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"github.com/vmware-tanzu/velero/pkg/constant"
@@ -609,7 +608,19 @@ func (r *DataDownloadReconciler) OnDataDownloadProgress(ctx context.Context, nam
log := r.logger.WithField("datadownload", ddName)
if err := UpdateDataDownloadWithRetry(ctx, r.client, types.NamespacedName{Namespace: namespace, Name: ddName}, log, func(dd *velerov2alpha1api.DataDownload) bool {
dd.Status.Progress = shared.DataMoveOperationProgress{TotalBytes: progress.TotalBytes, BytesDone: progress.BytesDone}
if progress.TotalBytes != -1 {
dd.Status.Progress.TotalBytes = progress.TotalBytes
}
if progress.BytesDone != -1 {
dd.Status.Progress.BytesDone = progress.BytesDone
}
if progress.Message != "" {
dd.Status.Message += progress.Message
dd.Status.Message += ";"
}
return true
}); err != nil {
log.WithError(err).Error("Failed to update progress")
+13 -2
View File
@@ -42,7 +42,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
velerov2alpha1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v2alpha1"
"github.com/vmware-tanzu/velero/pkg/constant"
@@ -634,7 +633,19 @@ func (r *DataUploadReconciler) OnDataUploadProgress(ctx context.Context, namespa
log := r.logger.WithField("dataupload", duName)
if err := UpdateDataUploadWithRetry(ctx, r.client, types.NamespacedName{Namespace: namespace, Name: duName}, log, func(du *velerov2alpha1api.DataUpload) bool {
du.Status.Progress = shared.DataMoveOperationProgress{TotalBytes: progress.TotalBytes, BytesDone: progress.BytesDone}
if progress.TotalBytes != -1 {
du.Status.Progress.TotalBytes = progress.TotalBytes
}
if progress.BytesDone != -1 {
du.Status.Progress.BytesDone = progress.BytesDone
}
if progress.Message != "" {
du.Status.Message += progress.Message
du.Status.Message += ";"
}
return true
}); err != nil {
log.WithError(err).Error("Failed to update progress")
+13 -2
View File
@@ -41,7 +41,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
veleroapishared "github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/constant"
"github.com/vmware-tanzu/velero/pkg/datapath"
@@ -628,7 +627,19 @@ func (r *PodVolumeBackupReconciler) OnDataPathProgress(ctx context.Context, name
log := r.logger.WithField("pvb", pvbName)
if err := UpdatePVBWithRetry(ctx, r.client, types.NamespacedName{Namespace: namespace, Name: pvbName}, log, func(pvb *velerov1api.PodVolumeBackup) bool {
pvb.Status.Progress = veleroapishared.DataMoveOperationProgress{TotalBytes: progress.TotalBytes, BytesDone: progress.BytesDone}
if progress.TotalBytes != -1 {
pvb.Status.Progress.TotalBytes = progress.TotalBytes
}
if progress.BytesDone != -1 {
pvb.Status.Progress.BytesDone = progress.BytesDone
}
if progress.Message != "" {
pvb.Status.Message += progress.Message
pvb.Status.Message += ";"
}
return true
}); err != nil {
log.WithError(err).Error("Failed to update progress")
@@ -44,7 +44,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
veleroapishared "github.com/vmware-tanzu/velero/pkg/apis/velero/shared"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/constant"
"github.com/vmware-tanzu/velero/pkg/datapath"
@@ -905,7 +904,19 @@ func (r *PodVolumeRestoreReconciler) OnDataPathProgress(ctx context.Context, nam
log := r.logger.WithField("PVR", pvrName)
if err := UpdatePVRWithRetry(ctx, r.client, types.NamespacedName{Namespace: namespace, Name: pvrName}, log, func(pvr *velerov1api.PodVolumeRestore) bool {
pvr.Status.Progress = veleroapishared.DataMoveOperationProgress{TotalBytes: progress.TotalBytes, BytesDone: progress.BytesDone}
if progress.TotalBytes != -1 {
pvr.Status.Progress.TotalBytes = progress.TotalBytes
}
if progress.BytesDone != -1 {
pvr.Status.Progress.BytesDone = progress.BytesDone
}
if progress.Message != "" {
pvr.Status.Message += progress.Message
pvr.Status.Message += ";"
}
return true
}); err != nil {
log.WithError(err).Error("Failed to update progress")