@@ -316,6 +316,11 @@ func getDestination(pg *v2.PerconaPGCluster, pb *v2.PerconaPGBackup) string {
316316func updatePGBackrestInfo (ctx context.Context , c client.Client , pod * corev1.Pod , pgBackup * v2.PerconaPGBackup ) error {
317317 info , err := pgbackrest .GetInfo (ctx , pod , pgBackup .Spec .RepoName )
318318 if err != nil {
319+ errortracking .CaptureError (err , map [string ]string {
320+ "backup" : pgBackup .Name ,
321+ "namespace" : pgBackup .Namespace ,
322+ "phase" : "get_pgbackrest_info" ,
323+ })
319324 return errors .Wrap (err , "get pgBackRest info" )
320325 }
321326
@@ -354,29 +359,56 @@ func updatePGBackrestInfo(ctx context.Context, c client.Client, pod *corev1.Pod,
354359
355360 return c .Status ().Update (ctx , bcp )
356361 }); err != nil {
362+ errortracking .CaptureError (err , map [string ]string {
363+ "backup" : pgBackup .Name ,
364+ "namespace" : pgBackup .Namespace ,
365+ "phase" : "update_backup_status" ,
366+ })
357367 return errors .Wrap (err , "update PGBackup status" )
358368 }
359369 }
360370
361371 if err := pgbackrest .SetAnnotationsToBackup (ctx , pod , stanzaName , backup .Label , pgBackup .Spec .RepoName , map [string ]string {
362372 v2 .PGBackrestAnnotationJobName : pgBackup .Status .JobName ,
363373 }); err != nil {
374+ errortracking .CaptureError (err , map [string ]string {
375+ "backup" : pgBackup .Name ,
376+ "namespace" : pgBackup .Namespace ,
377+ "phase" : "set_backup_annotations" ,
378+ })
364379 return errors .Wrap (err , "set annotations to backup" )
365380 }
366381 return nil
367382 }
368383 }
369- return errors .New ("backup annotations are not found in pgbackrest" )
384+
385+ err = errors .New ("backup annotations are not found in pgbackrest" )
386+ errortracking .CaptureError (err , map [string ]string {
387+ "backup" : pgBackup .Name ,
388+ "namespace" : pgBackup .Namespace ,
389+ "phase" : "find_backup_annotations" ,
390+ })
391+ return err
370392}
371393
372394func finishBackup (ctx context.Context , c client.Client , pgBackup * v2.PerconaPGBackup , job * batchv1.Job ) (* reconcile.Result , error ) {
373395 if checkBackupJob (job ) == v2 .BackupSucceeded {
374396 readyPod , err := controller .GetReadyInstancePod (ctx , c , pgBackup .Spec .PGCluster , pgBackup .Namespace )
375397 if err != nil {
398+ errortracking .CaptureError (err , map [string ]string {
399+ "backup" : pgBackup .Name ,
400+ "namespace" : pgBackup .Namespace ,
401+ "phase" : "get_ready_pod" ,
402+ })
376403 return nil , errors .Wrap (err , "get ready instance pod" )
377404 }
378405
379406 if err := updatePGBackrestInfo (ctx , c , readyPod , pgBackup ); err != nil {
407+ errortracking .CaptureError (err , map [string ]string {
408+ "backup" : pgBackup .Name ,
409+ "namespace" : pgBackup .Namespace ,
410+ "phase" : "update_pgbackrest_info" ,
411+ })
380412 return nil , errors .Wrap (err , "update pgbackrest info" )
381413 }
382414 }
@@ -386,6 +418,11 @@ func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBa
386418 }
387419 runningBackup , err := getBackupInProgress (ctx , c , pgBackup .Spec .PGCluster , pgBackup .Namespace )
388420 if err != nil {
421+ errortracking .CaptureError (err , map [string ]string {
422+ "backup" : pgBackup .Name ,
423+ "namespace" : pgBackup .Namespace ,
424+ "phase" : "get_backup_in_progress" ,
425+ })
389426 return nil , errors .Wrap (err , "get backup in progress" )
390427 }
391428 if runningBackup != pgBackup .Name {
@@ -395,6 +432,11 @@ func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBa
395432 deleteAnnotation := func (annotation string ) (bool , error ) {
396433 pgCluster := new (v1beta1.PostgresCluster )
397434 if err := c .Get (ctx , types.NamespacedName {Name : pgBackup .Spec .PGCluster , Namespace : pgBackup .Namespace }, pgCluster ); err != nil {
435+ errortracking .CaptureError (err , map [string ]string {
436+ "backup" : pgBackup .Name ,
437+ "namespace" : pgBackup .Namespace ,
438+ "phase" : "get_postgres_cluster" ,
439+ })
398440 return false , errors .Wrap (err , "get PostgresCluster" )
399441 }
400442
@@ -426,6 +468,11 @@ func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBa
426468
427469 deleted , err := deleteAnnotation (naming .PGBackRestBackup )
428470 if err != nil {
471+ errortracking .CaptureError (err , map [string ]string {
472+ "backup" : pgBackup .Name ,
473+ "namespace" : pgBackup .Namespace ,
474+ "phase" : "delete_pgbackrest_backup_annotation" ,
475+ })
429476 return nil , errors .Wrapf (err , "delete %s annotation" , naming .PGBackRestBackup )
430477 }
431478 if ! deleted {
@@ -450,6 +497,11 @@ func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBa
450497
451498 return c .Update (ctx , j )
452499 }); err != nil {
500+ errortracking .CaptureError (err , map [string ]string {
501+ "backup" : pgBackup .Name ,
502+ "namespace" : pgBackup .Namespace ,
503+ "phase" : "update_backup_job_labels" ,
504+ })
453505 return nil , errors .Wrap (err , "update backup job labels" )
454506 }
455507
@@ -462,11 +514,21 @@ func finishBackup(ctx context.Context, c client.Client, pgBackup *v2.PerconaPGBa
462514
463515 return c .Status ().Update (ctx , pgCluster )
464516 }); err != nil {
517+ errortracking .CaptureError (err , map [string ]string {
518+ "backup" : pgBackup .Name ,
519+ "namespace" : pgBackup .Namespace ,
520+ "phase" : "update_postgres_cluster_status" ,
521+ })
465522 return nil , errors .Wrap (err , "update postgrescluster" )
466523 }
467524
468525 deleted , err = deleteAnnotation (pNaming .AnnotationBackupInProgress )
469526 if err != nil {
527+ errortracking .CaptureError (err , map [string ]string {
528+ "backup" : pgBackup .Name ,
529+ "namespace" : pgBackup .Namespace ,
530+ "phase" : "delete_backup_in_progress_annotation" ,
531+ })
470532 return nil , errors .Wrapf (err , "delete %s annotation" , pNaming .AnnotationBackupInProgress )
471533 }
472534 if ! deleted {
0 commit comments