persist error count aside from errors (#2652)
#### Does this PR need a docs update or release note? - [ ] ⛔ No #### Type of change - [x] 🐛 Bugfix #### Issue(s) * #1970
This commit is contained in:
parent
ac4d7d047a
commit
422a05e21d
@ -37,7 +37,8 @@ type Backup struct {
|
|||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
|
|
||||||
// Errors contains all errors aggregated during a backup operation.
|
// Errors contains all errors aggregated during a backup operation.
|
||||||
Errors fault.ErrorsData `json:"errors"`
|
Errors fault.ErrorsData `json:"errors"`
|
||||||
|
ErrorCount int `json:"errorCount"`
|
||||||
|
|
||||||
// stats are embedded so that the values appear as top-level properties
|
// stats are embedded so that the values appear as top-level properties
|
||||||
stats.Errs // Deprecated, replaced with Errors.
|
stats.Errs // Deprecated, replaced with Errors.
|
||||||
@ -56,6 +57,13 @@ func New(
|
|||||||
se stats.StartAndEndTime,
|
se stats.StartAndEndTime,
|
||||||
errs *fault.Errors,
|
errs *fault.Errors,
|
||||||
) *Backup {
|
) *Backup {
|
||||||
|
errData := errs.Data()
|
||||||
|
|
||||||
|
errCount := len(errs.Data().Errs)
|
||||||
|
if errData.Err != nil {
|
||||||
|
errCount++
|
||||||
|
}
|
||||||
|
|
||||||
return &Backup{
|
return &Backup{
|
||||||
BaseModel: model.BaseModel{
|
BaseModel: model.BaseModel{
|
||||||
ID: id,
|
ID: id,
|
||||||
@ -68,7 +76,8 @@ func New(
|
|||||||
DetailsID: detailsID,
|
DetailsID: detailsID,
|
||||||
Status: status,
|
Status: status,
|
||||||
Selector: selector,
|
Selector: selector,
|
||||||
Errors: errs.Data(),
|
Errors: errData,
|
||||||
|
ErrorCount: errCount,
|
||||||
ReadWrites: rw,
|
ReadWrites: rw,
|
||||||
StartAndEndTime: se,
|
StartAndEndTime: se,
|
||||||
Version: version.Backup,
|
Version: version.Backup,
|
||||||
@ -114,7 +123,7 @@ type Printable struct {
|
|||||||
func (b Backup) MinimumPrintable() any {
|
func (b Backup) MinimumPrintable() any {
|
||||||
return Printable{
|
return Printable{
|
||||||
ID: b.ID,
|
ID: b.ID,
|
||||||
ErrorCount: b.errorCount(),
|
ErrorCount: b.countErrors(),
|
||||||
StartedAt: b.StartedAt,
|
StartedAt: b.StartedAt,
|
||||||
Status: b.Status,
|
Status: b.Status,
|
||||||
Version: "0",
|
Version: "0",
|
||||||
@ -138,7 +147,7 @@ func (b Backup) Headers() []string {
|
|||||||
// Values returns the values matching the Headers list for printing
|
// Values returns the values matching the Headers list for printing
|
||||||
// out to a terminal in a columnar display.
|
// out to a terminal in a columnar display.
|
||||||
func (b Backup) Values() []string {
|
func (b Backup) Values() []string {
|
||||||
status := fmt.Sprintf("%s (%d errors)", b.Status, b.errorCount())
|
status := fmt.Sprintf("%s (%d errors)", b.Status, b.countErrors())
|
||||||
|
|
||||||
return []string{
|
return []string{
|
||||||
common.FormatTabularDisplayTime(b.StartedAt),
|
common.FormatTabularDisplayTime(b.StartedAt),
|
||||||
@ -148,8 +157,11 @@ func (b Backup) Values() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Backup) errorCount() int {
|
func (b Backup) countErrors() int {
|
||||||
var errCount int
|
errCount := b.ErrorCount
|
||||||
|
if errCount > 0 {
|
||||||
|
return errCount
|
||||||
|
}
|
||||||
|
|
||||||
// current tracking
|
// current tracking
|
||||||
if b.ReadErrors != nil || b.WriteErrors != nil {
|
if b.ReadErrors != nil || b.WriteErrors != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user