From 7f44db6c7c582290c832569606a3056457506b0d Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Fri, 20 Jan 2023 10:59:15 -0800 Subject: [PATCH] Fail operation if we failed to fetch item data (#2199) ## Description If GraphConnector reported errors while trying to fetch item data, fail the entire operation. This stops silent failures, but is a big hammer at the moment because there's no checks for items no longer being available. Error reporting is minimal as well, but some info should be in the log. **This effectively disables best-effort as any failure will result in the operation being reported as failed** ## Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No ## Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup ## Issue(s) * #2196 ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/operations/backup.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 89dbb340d..92a8b93c6 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -205,10 +205,21 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) { return opStats.writeErr } + opStats.gc = gc.AwaitStatus() + + if opStats.gc.ErrorCount > 0 { + opStats.writeErr = multierror.Append(nil, opStats.writeErr, errors.Errorf( + "%v errors reported while fetching item data", + opStats.gc.ErrorCount, + )).ErrorOrNil() + + // Need to exit before we set started to true else we'll report no errors. + return opStats.writeErr + } + // should always be 1, since backups are 1:1 with resourceOwners. opStats.resourceCount = 1 opStats.started = true - opStats.gc = gc.AwaitStatus() return err }