@@ -561,6 +561,22 @@ Collecting PGO CLI logs...
561561 writeInfo (cmd , fmt .Sprintf ("Error gathering kubectl plugins: %s" , err ))
562562 }
563563
564+ // Get PGUpgrade spec (if available)
565+ writeInfo (cmd , "Collecting PGUpgrade spec (if available)..." )
566+
567+ key := util .AllowUpgradeAnnotation ()
568+ value , exists := get .GetAnnotations ()[key ]
569+
570+ if exists {
571+ writeInfo (cmd , fmt .Sprintf ("The PGUpgrade object is: %s" , value ))
572+ err = gatherPGUpgradeSpec (clusterName , namespace , value , tw , cmd )
573+ if err != nil {
574+ writeInfo (cmd , fmt .Sprintf ("Error gathering PGUpgrade spec: %s" , err ))
575+ }
576+ } else {
577+ writeInfo (cmd , fmt .Sprintf ("There is no PGUpgrade object associated with cluster '%s'" , clusterName ))
578+ }
579+
564580 // Print cli output
565581 writeInfo (cmd , "Collecting PGO CLI logs..." )
566582 path := clusterName + "/cli.log"
@@ -594,6 +610,26 @@ func gatherPluginList(clusterName string, tw *tar.Writer, cmd *cobra.Command) er
594610 return nil
595611}
596612
613+ func gatherPGUpgradeSpec (clusterName , namespace , pgUpgrade string , tw * tar.Writer , cmd * cobra.Command ) error {
614+ ex := exec .Command ("kubectl" , "get" , "pgupgrade" , pgUpgrade , "-n" , namespace , "-o" , "yaml" )
615+ msg , err := ex .Output ()
616+
617+ if err != nil {
618+ msg = append (msg , err .Error ()... )
619+ msg = append (msg , []byte (`
620+ There was an error running 'kubectl get pgupgrade'. Verify permissions and that the resource exists.` )... )
621+
622+ writeInfo (cmd , fmt .Sprintf ("Error: '%s'" , msg ))
623+ }
624+
625+ path := clusterName + "/pgupgrade.yaml"
626+ if err := writeTar (tw , msg , path , cmd ); err != nil {
627+ return err
628+ }
629+
630+ return nil
631+ }
632+
597633// exportSizeReport defines the message displayed when a support export archive
598634// is created. If the size of the archive file is greater than 25MiB, an alternate
599635// message is displayed.
0 commit comments