minor logging and cli output tweaks (#5016)
just touchups for supportability and tracking, plus a ux tweak here and there. No real logic changes. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🤖 Supportability/Tests #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
8c2d7c3c18
commit
dab53502ae
@ -190,6 +190,8 @@ func genericCreateCommand(
|
|||||||
ictx = clues.Add(ctx, "resource_owner_selected", owner)
|
ictx = clues.Add(ctx, "resource_owner_selected", owner)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.Ctx(ictx).Infof("setting up backup")
|
||||||
|
|
||||||
bo, err := r.NewBackupWithLookup(ictx, discSel, ins)
|
bo, err := r.NewBackupWithLookup(ictx, discSel, ins)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cerr := clues.WrapWC(ictx, err, owner)
|
cerr := clues.WrapWC(ictx, err, owner)
|
||||||
@ -206,21 +208,23 @@ func genericCreateCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ictx = clues.Add(
|
ictx = clues.Add(
|
||||||
ctx,
|
ictx,
|
||||||
"resource_owner_id", bo.ResourceOwner.ID(),
|
"resource_owner_id", bo.ResourceOwner.ID(),
|
||||||
"resource_owner_name", bo.ResourceOwner.Name())
|
"resource_owner_name", clues.Hide(bo.ResourceOwner.Name()))
|
||||||
|
|
||||||
|
logger.Ctx(ictx).Infof("running backup")
|
||||||
|
|
||||||
err = bo.Run(ictx)
|
err = bo.Run(ictx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, core.ErrServiceNotEnabled) {
|
if errors.Is(err, core.ErrServiceNotEnabled) {
|
||||||
logger.Ctx(ctx).Infow("service not enabled",
|
logger.Ctx(ictx).Infow("service not enabled",
|
||||||
"resource_owner_id", bo.ResourceOwner.ID(),
|
"resource_owner_id", bo.ResourceOwner.ID(),
|
||||||
"service", serviceName)
|
"service", serviceName)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr := clues.WrapWC(ictx, err, owner)
|
cerr := clues.Wrap(err, owner)
|
||||||
errs = append(errs, cerr)
|
errs = append(errs, cerr)
|
||||||
|
|
||||||
meta, err := json.Marshal(cerr.Core().Values)
|
meta, err := json.Marshal(cerr.Core().Values)
|
||||||
@ -236,10 +240,10 @@ func genericCreateCommand(
|
|||||||
bIDs = append(bIDs, string(bo.Results.BackupID))
|
bIDs = append(bIDs, string(bo.Results.BackupID))
|
||||||
|
|
||||||
if !DisplayJSONFormat() {
|
if !DisplayJSONFormat() {
|
||||||
Infof(ctx, fmt.Sprintf("Backup complete %s %s", observe.Bullet, color.BlueOutput(bo.Results.BackupID)))
|
Infof(ictx, fmt.Sprintf("Backup complete %s %s", observe.Bullet, color.BlueOutput(bo.Results.BackupID)))
|
||||||
printBackupStats(ctx, r, string(bo.Results.BackupID))
|
printBackupStats(ictx, r, string(bo.Results.BackupID))
|
||||||
} else {
|
} else {
|
||||||
Infof(ctx, "Backup complete - ID: %v\n", bo.Results.BackupID)
|
Infof(ictx, "Backup complete - ID: %v\n", bo.Results.BackupID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,10 +70,13 @@ func (mc *mergeCollection) Items(
|
|||||||
go func() {
|
go func() {
|
||||||
defer close(res)
|
defer close(res)
|
||||||
|
|
||||||
logger.Ctx(ctx).Infow(
|
log := logger.Ctx(ctx)
|
||||||
"getting items for merged collection",
|
log.Infow(
|
||||||
|
"streaming all merged collections' items",
|
||||||
"merged_collection_count", len(mc.cols))
|
"merged_collection_count", len(mc.cols))
|
||||||
|
|
||||||
|
defer log.Debug("done streaming all merged collections' items")
|
||||||
|
|
||||||
for _, c := range mc.cols {
|
for _, c := range mc.cols {
|
||||||
// Unfortunately doesn't seem to be a way right now to see if the
|
// Unfortunately doesn't seem to be a way right now to see if the
|
||||||
// iteration failed and we should be exiting early.
|
// iteration failed and we should be exiting early.
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
hideProgressBarsFN = "hide-progress"
|
hideProgressBarsFN = "hide-progress"
|
||||||
retainProgressBarsFN = "retain-progress"
|
retainProgressBarsFN = "retain-progress"
|
||||||
progressBarWidth = 40
|
progressBarWidth = 32
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -117,6 +117,10 @@ func (o *observer) resetWriter(ctx context.Context) {
|
|||||||
// opts = append(opts, mpb.WithAutoRefresh())
|
// opts = append(opts, mpb.WithAutoRefresh())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if o.mp != nil {
|
||||||
|
logger.Ctx(ctx).Infow("resetting progress bars", "bar_count", o.mp.BarCount())
|
||||||
|
}
|
||||||
|
|
||||||
o.mp = mpb.NewWithContext(ctx, opts...)
|
o.mp = mpb.NewWithContext(ctx, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +158,12 @@ func Flush(ctx context.Context) {
|
|||||||
obs := getObserver(ctx)
|
obs := getObserver(ctx)
|
||||||
|
|
||||||
if obs.mp != nil {
|
if obs.mp != nil {
|
||||||
|
logr := logger.Ctx(ctx)
|
||||||
|
logr.Infow("blocked flushing progress bars", "bar_count", obs.mp.BarCount())
|
||||||
|
|
||||||
obs.mp.Wait()
|
obs.mp.Wait()
|
||||||
|
|
||||||
|
logr.Infow("progress bars flushed")
|
||||||
}
|
}
|
||||||
|
|
||||||
obs.resetWriter(ctx)
|
obs.resetWriter(ctx)
|
||||||
|
|||||||
@ -306,36 +306,42 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogFaultErrors(ctx, op.Errors.Errors(), "running backup")
|
LogFaultErrors(ctx, op.Errors.Errors(), "running backup")
|
||||||
|
op.doPersistence(ctx, &opStats, sstore, deets, startTime)
|
||||||
|
finalizeErrorHandling(ctx, op.Options, op.Errors, "running backup")
|
||||||
|
|
||||||
// -----
|
logger.Ctx(ctx).Infow(
|
||||||
// Persistence
|
"completed backup",
|
||||||
// -----
|
"results", op.Results,
|
||||||
|
"failure", op.Errors.Failure())
|
||||||
|
|
||||||
err = op.persistResults(startTime, &opStats, op.Counter)
|
return op.Errors.Failure()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (op *BackupOperation) doPersistence(
|
||||||
|
ctx context.Context,
|
||||||
|
opStats *backupStats,
|
||||||
|
detailsStore streamstore.Streamer,
|
||||||
|
deets *details.Builder,
|
||||||
|
start time.Time,
|
||||||
|
) {
|
||||||
|
observe.Message(ctx, observe.ProgressCfg{}, "Finalizing storage")
|
||||||
|
|
||||||
|
err := op.persistResults(start, opStats, op.Counter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
op.Errors.Fail(clues.Wrap(err, "persisting backup results"))
|
op.Errors.Fail(clues.Wrap(err, "persisting backup results"))
|
||||||
return op.Errors.Failure()
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = op.createBackupModels(
|
err = op.createBackupModels(
|
||||||
ctx,
|
ctx,
|
||||||
sstore,
|
detailsStore,
|
||||||
opStats,
|
*opStats,
|
||||||
op.Results.BackupID,
|
op.Results.BackupID,
|
||||||
op.BackupVersion,
|
op.BackupVersion,
|
||||||
deets.Details())
|
deets.Details())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
op.Errors.Fail(clues.Wrap(err, "persisting backup models"))
|
op.Errors.Fail(clues.Wrap(err, "persisting backup models"))
|
||||||
return op.Errors.Failure()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizeErrorHandling(ctx, op.Options, op.Errors, "running backup")
|
|
||||||
|
|
||||||
if op.Errors.Failure() == nil {
|
|
||||||
logger.Ctx(ctx).Infow("completed backup", "results", op.Results)
|
|
||||||
}
|
|
||||||
|
|
||||||
return op.Errors.Failure()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// do is purely the action of running a backup. All pre/post behavior
|
// do is purely the action of running a backup. All pre/post behavior
|
||||||
|
|||||||
@ -357,9 +357,9 @@ func (bs backupStats) MinimumPrintable() any {
|
|||||||
// for printing out to a terminal in a columnar display.
|
// for printing out to a terminal in a columnar display.
|
||||||
func (bs backupStats) Headers(skipID bool) []string {
|
func (bs backupStats) Headers(skipID bool) []string {
|
||||||
headers := []string{
|
headers := []string{
|
||||||
"Bytes Uploaded",
|
"Bytes uploaded",
|
||||||
"Items Uploaded",
|
"Items uploaded",
|
||||||
"Items Skipped",
|
"Items skipped",
|
||||||
"Errors",
|
"Errors",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -364,9 +364,9 @@ func (suite *BackupUnitSuite) TestStats_headersValues() {
|
|||||||
|
|
||||||
expectHeaders := []string{
|
expectHeaders := []string{
|
||||||
"ID",
|
"ID",
|
||||||
"Bytes Uploaded",
|
"Bytes uploaded",
|
||||||
"Items Uploaded",
|
"Items uploaded",
|
||||||
"Items Skipped",
|
"Items skipped",
|
||||||
"Errors",
|
"Errors",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,9 @@ var piiSafePathElems = pii.MapWithPlurals(
|
|||||||
PagesCategory.String(),
|
PagesCategory.String(),
|
||||||
DetailsCategory.String(),
|
DetailsCategory.String(),
|
||||||
|
|
||||||
|
// other internal values
|
||||||
|
"fault_error", // streamstore.FaultErrorType causes an import cycle
|
||||||
|
|
||||||
// well known folders
|
// well known folders
|
||||||
// https://learn.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0
|
// https://learn.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0
|
||||||
"archive",
|
"archive",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user