Populate reason info in tags
This commit is contained in:
parent
9b8ee4f3f6
commit
5c6d46a581
@ -278,7 +278,7 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
||||
|
||||
observe.Message(ctx, "Backing Up", observe.Bullet, clues.Hide(op.ResourceOwner.Name()))
|
||||
|
||||
bases, deets, err := op.do(
|
||||
reasons, bases, deets, err := op.do(
|
||||
ctx,
|
||||
&opStats,
|
||||
sstore,
|
||||
@ -304,6 +304,7 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
||||
err = op.createBackupModels(
|
||||
ctx,
|
||||
sstore,
|
||||
reasons,
|
||||
bases,
|
||||
opStats,
|
||||
op.Results.BackupID,
|
||||
@ -330,17 +331,17 @@ func (op *BackupOperation) do(
|
||||
opStats *backupStats,
|
||||
detailsStore streamstore.Streamer,
|
||||
backupID model.StableID,
|
||||
) (backup.BackupBases, *details.Builder, error) {
|
||||
) ([]identity.Reasoner, backup.BackupBases, *details.Builder, error) {
|
||||
lastBackupVersion := version.NoBackup
|
||||
|
||||
reasons, err := op.Selectors.Reasons(op.account.ID(), false)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "getting reasons")
|
||||
return nil, nil, nil, clues.Wrap(err, "getting reasons")
|
||||
}
|
||||
|
||||
fallbackReasons, err := makeFallbackReasons(op.account.ID(), op.Selectors)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "getting fallback reasons")
|
||||
return nil, nil, nil, clues.Wrap(err, "getting fallback reasons")
|
||||
}
|
||||
|
||||
logger.Ctx(ctx).With(
|
||||
@ -353,7 +354,7 @@ func (op *BackupOperation) do(
|
||||
|
||||
kbf, err := op.kopia.NewBaseFinder(op.store)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Stack(err)
|
||||
return nil, nil, nil, clues.Stack(err)
|
||||
}
|
||||
|
||||
bases, mdColls, canUseMetadata, err := produceManifestsAndMetadata(
|
||||
@ -366,7 +367,7 @@ func (op *BackupOperation) do(
|
||||
op.incremental,
|
||||
op.disableAssistBackup)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "producing manifests and metadata")
|
||||
return nil, nil, nil, clues.Wrap(err, "producing manifests and metadata")
|
||||
}
|
||||
|
||||
ctx = clues.Add(
|
||||
@ -393,7 +394,7 @@ func (op *BackupOperation) do(
|
||||
op.Options,
|
||||
op.Errors)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "producing backup data collections")
|
||||
return nil, nil, nil, clues.Wrap(err, "producing backup data collections")
|
||||
}
|
||||
|
||||
ctx = clues.Add(
|
||||
@ -413,7 +414,7 @@ func (op *BackupOperation) do(
|
||||
op.incremental && canUseMetadata && canUsePreviousBackup,
|
||||
op.Errors)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "persisting collection backups")
|
||||
return nil, nil, nil, clues.Wrap(err, "persisting collection backups")
|
||||
}
|
||||
|
||||
opStats.hasNewDetailEntries = (deets != nil && !deets.Empty()) ||
|
||||
@ -430,14 +431,14 @@ func (op *BackupOperation) do(
|
||||
op.Selectors.PathService(),
|
||||
op.Errors)
|
||||
if err != nil {
|
||||
return nil, nil, clues.Wrap(err, "merging details")
|
||||
return nil, nil, nil, clues.Wrap(err, "merging details")
|
||||
}
|
||||
|
||||
opStats.ctrl = op.bp.Wait()
|
||||
|
||||
logger.Ctx(ctx).Debug(opStats.ctrl)
|
||||
|
||||
return bases, deets, nil
|
||||
return reasons, bases, deets, nil
|
||||
}
|
||||
|
||||
func makeFallbackReasons(tenant string, sel selectors.Selector) ([]identity.Reasoner, error) {
|
||||
@ -844,6 +845,7 @@ func (op *BackupOperation) persistResults(
|
||||
func (op *BackupOperation) createBackupModels(
|
||||
ctx context.Context,
|
||||
sscw streamstore.CollectorWriter,
|
||||
reasons []identity.Reasoner,
|
||||
bases backup.BackupBases,
|
||||
opStats backupStats,
|
||||
backupID model.StableID,
|
||||
@ -930,6 +932,7 @@ func (op *BackupOperation) createBackupModels(
|
||||
op.ResourceOwner.Name(),
|
||||
op.Results.ReadWrites,
|
||||
op.Results.StartAndEndTime,
|
||||
reasons,
|
||||
bases,
|
||||
op.Errors.Errors(),
|
||||
tags)
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/dustin/go-humanize"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/alcionai/corso/src/cli/print"
|
||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||
@ -89,6 +90,7 @@ func New(
|
||||
ownerID, ownerName string,
|
||||
rw stats.ReadWrites,
|
||||
se stats.StartAndEndTime,
|
||||
reasons []identity.Reasoner,
|
||||
bases BackupBases,
|
||||
fe *fault.Errors,
|
||||
tags map[string]string,
|
||||
@ -121,10 +123,15 @@ func New(
|
||||
}
|
||||
}
|
||||
|
||||
// maps.Clone throws an NPE if passed nil on Mac for some reason.
|
||||
if tags == nil {
|
||||
tags = map[string]string{}
|
||||
}
|
||||
|
||||
b := &Backup{
|
||||
BaseModel: model.BaseModel{
|
||||
ID: id,
|
||||
Tags: tags,
|
||||
Tags: maps.Clone(tags),
|
||||
},
|
||||
|
||||
ProtectedResourceID: ownerID,
|
||||
@ -181,6 +188,12 @@ func New(
|
||||
}
|
||||
}
|
||||
|
||||
for _, reason := range reasons {
|
||||
for k, v := range reasonTags(reason) {
|
||||
b.Tags[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user