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