mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 14:21:18 +00:00
BIA/RIAv2 -- distinguish between New and InProgress operations
Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
@@ -2478,7 +2478,7 @@ func TestBackupWithAsyncOperations(t *testing.T) {
|
||||
OperationID: "pod-1-1",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: "InProgress",
|
||||
Phase: "New",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2507,7 +2507,7 @@ func TestBackupWithAsyncOperations(t *testing.T) {
|
||||
OperationID: "pod-2-1",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: "InProgress",
|
||||
Phase: "New",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -367,7 +367,7 @@ func (ib *itemBackupper) executeActions(
|
||||
OperationID: operationID,
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &now,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -286,7 +286,8 @@ func getBackupItemOperationProgress(
|
||||
var completedCount, failedCount int
|
||||
|
||||
for _, operation := range operationsList {
|
||||
if operation.Status.Phase == itemoperation.OperationPhaseInProgress {
|
||||
if operation.Status.Phase == itemoperation.OperationPhaseNew ||
|
||||
operation.Status.Phase == itemoperation.OperationPhaseInProgress {
|
||||
bia, err := pluginManager.GetBackupItemActionV2(operation.Spec.BackupItemAction)
|
||||
if err != nil {
|
||||
operation.Status.Phase = itemoperation.OperationPhaseFailed
|
||||
@@ -322,12 +323,14 @@ func getBackupItemOperationProgress(
|
||||
changes = true
|
||||
}
|
||||
started := metav1.NewTime(operationProgress.Started)
|
||||
if operation.Status.Started == nil || *(operation.Status.Started) != started {
|
||||
if operation.Status.Started == nil && !operationProgress.Started.IsZero() ||
|
||||
operation.Status.Started != nil && *(operation.Status.Started) != started {
|
||||
operation.Status.Started = &started
|
||||
changes = true
|
||||
}
|
||||
updated := metav1.NewTime(operationProgress.Updated)
|
||||
if operation.Status.Updated == nil || *(operation.Status.Updated) != updated {
|
||||
if operation.Status.Updated == nil && !operationProgress.Updated.IsZero() ||
|
||||
operation.Status.Updated != nil && *(operation.Status.Updated) != updated {
|
||||
operation.Status.Updated = &updated
|
||||
changes = true
|
||||
}
|
||||
@@ -356,6 +359,11 @@ func getBackupItemOperationProgress(
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
if operation.Status.Phase == itemoperation.OperationPhaseNew &&
|
||||
operation.Status.Started != nil {
|
||||
operation.Status.Phase = itemoperation.OperationPhaseInProgress
|
||||
changes = true
|
||||
}
|
||||
// if we reach this point, the operation is still running
|
||||
inProgressOperations = true
|
||||
} else if operation.Status.Phase == itemoperation.OperationPhaseCompleted {
|
||||
|
||||
@@ -106,7 +106,7 @@ func TestBackupOperationsReconcile(t *testing.T) {
|
||||
OperationID: "operation-11",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &metav1Now,
|
||||
},
|
||||
},
|
||||
@@ -136,7 +136,7 @@ func TestBackupOperationsReconcile(t *testing.T) {
|
||||
OperationID: "operation-12",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &metav1Now,
|
||||
},
|
||||
},
|
||||
@@ -167,7 +167,7 @@ func TestBackupOperationsReconcile(t *testing.T) {
|
||||
OperationID: "operation-13",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &metav1Now,
|
||||
},
|
||||
},
|
||||
@@ -197,7 +197,7 @@ func TestBackupOperationsReconcile(t *testing.T) {
|
||||
OperationID: "operation-14",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &metav1Now,
|
||||
},
|
||||
},
|
||||
@@ -227,7 +227,7 @@ func TestBackupOperationsReconcile(t *testing.T) {
|
||||
OperationID: "operation-15",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &metav1Now,
|
||||
},
|
||||
},
|
||||
@@ -258,7 +258,7 @@ func TestBackupOperationsReconcile(t *testing.T) {
|
||||
OperationID: "operation-16",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &metav1Now,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -270,7 +270,8 @@ func getRestoreItemOperationProgress(
|
||||
var completedCount, failedCount int
|
||||
|
||||
for _, operation := range operationsList {
|
||||
if operation.Status.Phase == itemoperation.OperationPhaseInProgress {
|
||||
if operation.Status.Phase == itemoperation.OperationPhaseNew ||
|
||||
operation.Status.Phase == itemoperation.OperationPhaseInProgress {
|
||||
ria, err := pluginManager.GetRestoreItemActionV2(operation.Spec.RestoreItemAction)
|
||||
if err != nil {
|
||||
operation.Status.Phase = itemoperation.OperationPhaseFailed
|
||||
@@ -306,12 +307,14 @@ func getRestoreItemOperationProgress(
|
||||
changes = true
|
||||
}
|
||||
started := metav1.NewTime(operationProgress.Started)
|
||||
if operation.Status.Started == nil || *(operation.Status.Started) != started {
|
||||
if operation.Status.Started == nil && !operationProgress.Started.IsZero() ||
|
||||
operation.Status.Started != nil && *(operation.Status.Started) != started {
|
||||
operation.Status.Started = &started
|
||||
changes = true
|
||||
}
|
||||
updated := metav1.NewTime(operationProgress.Updated)
|
||||
if operation.Status.Updated == nil || *(operation.Status.Updated) != updated {
|
||||
if operation.Status.Updated == nil && !operationProgress.Updated.IsZero() ||
|
||||
operation.Status.Updated != nil && *(operation.Status.Updated) != updated {
|
||||
operation.Status.Updated = &updated
|
||||
changes = true
|
||||
}
|
||||
@@ -340,6 +343,11 @@ func getRestoreItemOperationProgress(
|
||||
failedCount++
|
||||
continue
|
||||
}
|
||||
if operation.Status.Phase == itemoperation.OperationPhaseNew &&
|
||||
operation.Status.Started != nil {
|
||||
operation.Status.Phase = itemoperation.OperationPhaseInProgress
|
||||
changes = true
|
||||
}
|
||||
// if we reach this point, the operation is still running
|
||||
inProgressOperations = true
|
||||
} else if operation.Status.Phase == itemoperation.OperationPhaseCompleted {
|
||||
|
||||
@@ -86,7 +86,11 @@ func (in *OperationStatus) DeepCopyInto(out *OperationStatus) {
|
||||
}
|
||||
|
||||
const (
|
||||
// OperationPhaseNew means the item operation has been created and started
|
||||
// OperationPhaseNew means the item operation has been created but not started
|
||||
// by the plugin
|
||||
OperationPhaseNew OperationPhase = "New"
|
||||
|
||||
// OperationPhaseInProgress means the item operation has been created and started
|
||||
// by the plugin
|
||||
OperationPhaseInProgress OperationPhase = "InProgress"
|
||||
|
||||
|
||||
@@ -1221,7 +1221,7 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
|
||||
OperationID: executeOutput.OperationID,
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: itemoperation.OperationPhaseInProgress,
|
||||
Phase: itemoperation.OperationPhaseNew,
|
||||
Created: &now,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1707,7 +1707,7 @@ func TestRestoreWithAsyncOperations(t *testing.T) {
|
||||
OperationID: "pod-1-1",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: "InProgress",
|
||||
Phase: "New",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1732,7 +1732,7 @@ func TestRestoreWithAsyncOperations(t *testing.T) {
|
||||
OperationID: "pod-2-1",
|
||||
},
|
||||
Status: itemoperation.OperationStatus{
|
||||
Phase: "InProgress",
|
||||
Phase: "New",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user