Skip to content

Commit 10b7999

Browse files
committed
fixed panic in describe output while displaying Hooksattempted or failed count
1 parent b4d6566 commit 10b7999

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

cmd/non-admin/backup/describe.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,13 @@ func printNonAdminBackupDetails(cmd *cobra.Command, nab *nacv1alpha1.NonAdminBac
372372
fmt.Fprintf(out, "\n")
373373

374374
// Hooks
375-
fmt.Fprintf(out, "HooksAttempted: %d\n", status.HookStatus.HooksAttempted)
376-
fmt.Fprintf(out, "HooksFailed: %d\n", status.HookStatus.HooksFailed)
375+
if status.HookStatus != nil {
376+
fmt.Fprintf(out, "HooksAttempted: %d\n", status.HookStatus.HooksAttempted)
377+
fmt.Fprintf(out, "HooksFailed: %d\n", status.HookStatus.HooksFailed)
378+
} else {
379+
fmt.Fprintf(out, "HooksAttempted: <none>\n")
380+
fmt.Fprintf(out, "HooksFailed: <none>\n")
381+
}
377382
} else {
378383
// Velero backup not available yet
379384
fmt.Fprintf(out, "Velero backup information not yet available.\n")

cmd/non-admin/restore/describe.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,13 @@ func printNonAdminRestoreDetails(cmd *cobra.Command, nar *nacv1alpha1.NonAdminRe
317317
fmt.Fprintf(out, "\n")
318318

319319
// Hooks
320-
fmt.Fprintf(out, "HooksAttempted: %d\n", status.HookStatus.HooksAttempted)
321-
fmt.Fprintf(out, "HooksFailed: %d\n", status.HookStatus.HooksFailed)
320+
if status.HookStatus != nil {
321+
fmt.Fprintf(out, "HooksAttempted: %d\n", status.HookStatus.HooksAttempted)
322+
fmt.Fprintf(out, "HooksFailed: %d\n", status.HookStatus.HooksFailed)
323+
} else {
324+
fmt.Fprintf(out, "HooksAttempted: <none>\n")
325+
fmt.Fprintf(out, "HooksFailed: <none>\n")
326+
}
322327
} else {
323328
// Velero restore not available yet
324329
fmt.Fprintf(out, "Velero restore information not yet available.\n")

cmd/root_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ func TestApplyTimeoutToConfig_DialerTimeout(t *testing.T) {
777777
}
778778

779779
// Should complete within a reasonable time of the timeout
780-
// Allow some margin for test execution overhead
781-
maxExpected := timeout + 500*time.Millisecond
780+
// Allow some margin for test execution overhead and system load variations
781+
maxExpected := timeout + 1*time.Second
782782
if elapsed > maxExpected {
783783
t.Errorf("Dial took too long: %v (expected ~%v)", elapsed, timeout)
784784
}

0 commit comments

Comments
 (0)