return gc stats errors in backup (#2248)
## Description If gc.stats reports a non-zero error count at the end of a backup, retrieve the error from the status and return it as the backup operation err. ## Does this PR need a docs update or release note? - [x] ⛔ No ## Type of change - [x] 🐛 Bugfix ## Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
4a6959f60f
commit
e828209a30
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
multierror "github.com/hashicorp/go-multierror"
|
||||||
bytesize "github.com/inhies/go-bytesize"
|
bytesize "github.com/inhies/go-bytesize"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
@ -21,6 +22,7 @@ type ConnectorOperationStatus struct {
|
|||||||
FolderCount int
|
FolderCount int
|
||||||
Successful int
|
Successful int
|
||||||
ErrorCount int
|
ErrorCount int
|
||||||
|
Err error
|
||||||
incomplete bool
|
incomplete bool
|
||||||
incompleteReason string
|
incompleteReason string
|
||||||
additionalDetails string
|
additionalDetails string
|
||||||
@ -70,6 +72,7 @@ func CreateStatus(
|
|||||||
FolderCount: folders,
|
FolderCount: folders,
|
||||||
Successful: cm.Successes,
|
Successful: cm.Successes,
|
||||||
ErrorCount: numErr,
|
ErrorCount: numErr,
|
||||||
|
Err: err,
|
||||||
incomplete: hasErrors,
|
incomplete: hasErrors,
|
||||||
incompleteReason: reason,
|
incompleteReason: reason,
|
||||||
bytes: cm.TotalBytes,
|
bytes: cm.TotalBytes,
|
||||||
@ -115,6 +118,7 @@ func MergeStatus(one, two ConnectorOperationStatus) ConnectorOperationStatus {
|
|||||||
FolderCount: one.FolderCount + two.FolderCount,
|
FolderCount: one.FolderCount + two.FolderCount,
|
||||||
Successful: one.Successful + two.Successful,
|
Successful: one.Successful + two.Successful,
|
||||||
ErrorCount: one.ErrorCount + two.ErrorCount,
|
ErrorCount: one.ErrorCount + two.ErrorCount,
|
||||||
|
Err: multierror.Append(one.Err, two.Err).ErrorOrNil(),
|
||||||
bytes: one.bytes + two.bytes,
|
bytes: one.bytes + two.bytes,
|
||||||
incomplete: hasErrors,
|
incomplete: hasErrors,
|
||||||
incompleteReason: one.incompleteReason + ", " + two.incompleteReason,
|
incompleteReason: one.incompleteReason + ", " + two.incompleteReason,
|
||||||
|
|||||||
@ -208,13 +208,11 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
|||||||
opStats.gc = gc.AwaitStatus()
|
opStats.gc = gc.AwaitStatus()
|
||||||
|
|
||||||
if opStats.gc.ErrorCount > 0 {
|
if opStats.gc.ErrorCount > 0 {
|
||||||
opStats.writeErr = multierror.Append(nil, opStats.writeErr, errors.Errorf(
|
merr := multierror.Append(opStats.readErr, errors.Wrap(opStats.gc.Err, "retrieving data"))
|
||||||
"%v errors reported while fetching item data",
|
opStats.readErr = merr.ErrorOrNil()
|
||||||
opStats.gc.ErrorCount,
|
|
||||||
)).ErrorOrNil()
|
|
||||||
|
|
||||||
// Need to exit before we set started to true else we'll report no errors.
|
// Need to exit before we set started to true else we'll report no errors.
|
||||||
return opStats.writeErr
|
return opStats.readErr
|
||||||
}
|
}
|
||||||
|
|
||||||
// should always be 1, since backups are 1:1 with resourceOwners.
|
// should always be 1, since backups are 1:1 with resourceOwners.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user