@@ -259,6 +259,7 @@ Collecting Postgres logs...
259259Collecting PostgresCluster pod logs...
260260Collecting monitoring pod logs...
261261Collecting Patroni info...
262+ Collecting pgBackRest info...
262263Collecting processes...
263264Collecting system times from containers...
264265Collecting PGO CLI logs...
@@ -434,6 +435,10 @@ Collecting PGO CLI logs...
434435 err = gatherPatroniInfo (ctx , clientset , restConfig , namespace , clusterName , tw , cmd )
435436 }
436437
438+ if err == nil {
439+ err = gatherPgBackRestInfo (ctx , clientset , restConfig , namespace , clusterName , tw , cmd )
440+ }
441+
437442 // Exec to get Container processes
438443 if err == nil {
439444 err = gatherProcessInfo (ctx , clientset , restConfig , namespace , clusterName , tw , cmd )
@@ -994,7 +999,7 @@ func gatherPodLogs(ctx context.Context,
994999 return nil
9951000}
9961001
997- // gatherExecInfo takes a client and buffer
1002+ // gatherPatroniInfo takes a client and buffer
9981003// execs into relevant pods to grab information
9991004func gatherPatroniInfo (ctx context.Context ,
10001005 clientset * kubernetes.Clientset ,
@@ -1072,6 +1077,65 @@ func gatherPatroniInfo(ctx context.Context,
10721077 return nil
10731078}
10741079
1080+ // gatherPgBackRestInfo takes a client and buffer
1081+ // execs into relevant pods to grab information
1082+ func gatherPgBackRestInfo (ctx context.Context ,
1083+ clientset * kubernetes.Clientset ,
1084+ config * rest.Config ,
1085+ namespace string ,
1086+ clusterName string ,
1087+ tw * tar.Writer ,
1088+ cmd * cobra.Command ,
1089+ ) error {
1090+ writeInfo (cmd , "Collecting pgBackRest info..." )
1091+ // Get the primary instance Pod by its labels
1092+ pods , err := clientset .CoreV1 ().Pods (namespace ).List (ctx , metav1.ListOptions {
1093+ LabelSelector : util .PrimaryInstanceLabels (clusterName ),
1094+ })
1095+ if err != nil {
1096+ if apierrors .IsForbidden (err ) {
1097+ writeInfo (cmd , err .Error ())
1098+ return nil
1099+ }
1100+ return err
1101+ }
1102+ if len (pods .Items ) < 1 {
1103+ writeInfo (cmd , "No pod found for pgBackRest info" )
1104+ return nil
1105+ }
1106+
1107+ podExec , err := util .NewPodExecutor (config )
1108+ if err != nil {
1109+ return err
1110+ }
1111+
1112+ exec := func (stdin io.Reader , stdout , stderr io.Writer , command ... string ,
1113+ ) error {
1114+ return podExec (namespace , pods .Items [0 ].GetName (), util .ContainerDatabase ,
1115+ stdin , stdout , stderr , command ... )
1116+ }
1117+
1118+ var buf bytes.Buffer
1119+
1120+ buf .Write ([]byte ("pgbackrest info\n " ))
1121+ stdout , stderr , err := Executor (exec ).pgBackRestInfo ("text" , "" )
1122+ if err != nil {
1123+ if apierrors .IsForbidden (err ) {
1124+ writeInfo (cmd , err .Error ())
1125+ return nil
1126+ }
1127+ return err
1128+ }
1129+
1130+ buf .Write ([]byte (stdout ))
1131+ if stderr != "" {
1132+ buf .Write ([]byte (stderr ))
1133+ }
1134+
1135+ path := clusterName + "/pgbackrest-info"
1136+ return writeTar (tw , buf .Bytes (), path , cmd )
1137+ }
1138+
10751139// gatherSystemTime takes a client and buffer and collects system time
10761140// in each Pod and calculates the delta against client system time.
10771141func gatherSystemTime (ctx context.Context ,
0 commit comments