mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-19 21:56:12 +00:00
fix prepare timeout issue
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -55,7 +55,8 @@ import (
|
||||
|
||||
const (
|
||||
dataUploadDownloadRequestor = "snapshot-data-upload-download"
|
||||
acceptNodeLabelKey = "velero.io/accepted-by"
|
||||
acceptNodeAnnoKey = "velero.io/accepted-by"
|
||||
acceptTimeAnnoKey = "velero.io/accepted-at"
|
||||
DataUploadDownloadFinalizer = "velero.io/data-upload-download-finalizer"
|
||||
preparingMonitorFrequency = time.Minute
|
||||
)
|
||||
@@ -255,9 +256,11 @@ func (r *DataUploadReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||
} else if peekErr := ep.PeekExposed(ctx, getOwnerObject(du)); peekErr != nil {
|
||||
r.tryCancelAcceptedDataUpload(ctx, du, fmt.Sprintf("found a dataupload %s/%s with expose error: %s. mark it as cancel", du.Namespace, du.Name, peekErr))
|
||||
log.Errorf("Cancel du %s/%s because of expose error %s", du.Namespace, du.Name, peekErr)
|
||||
} else if du.Status.StartTimestamp != nil {
|
||||
if time.Since(du.Status.StartTimestamp.Time) >= r.preparingTimeout {
|
||||
r.onPrepareTimeout(ctx, du)
|
||||
} else if at, found := du.Annotations[acceptTimeAnnoKey]; found {
|
||||
if t, err := time.Parse(time.RFC3339, at); err == nil {
|
||||
if time.Since(t) >= r.preparingTimeout {
|
||||
r.onPrepareTimeout(ctx, du)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,12 +704,13 @@ func (r *DataUploadReconciler) acceptDataUpload(ctx context.Context, du *velerov
|
||||
|
||||
updateFunc := func(dataUpload *velerov2alpha1api.DataUpload) {
|
||||
dataUpload.Status.Phase = velerov2alpha1api.DataUploadPhaseAccepted
|
||||
labels := dataUpload.GetLabels()
|
||||
if labels == nil {
|
||||
labels = make(map[string]string)
|
||||
annotations := dataUpload.GetAnnotations()
|
||||
if annotations == nil {
|
||||
annotations = make(map[string]string)
|
||||
}
|
||||
labels[acceptNodeLabelKey] = r.nodeName
|
||||
dataUpload.SetLabels(labels)
|
||||
annotations[acceptNodeAnnoKey] = r.nodeName
|
||||
annotations[acceptTimeAnnoKey] = r.Clock.Now().Format(time.RFC3339)
|
||||
dataUpload.SetAnnotations(annotations)
|
||||
}
|
||||
|
||||
succeeded, err := r.exclusiveUpdateDataUpload(ctx, updated, updateFunc)
|
||||
|
||||
Reference in New Issue
Block a user