@@ -20,6 +20,7 @@ import (
2020 "encoding/json"
2121 "fmt"
2222 log "github.com/Sirupsen/logrus"
23+ "github.com/crunchydata/postgres-operator/operator/util"
2324 "github.com/spf13/viper"
2425 "io"
2526 "io/ioutil"
@@ -51,13 +52,13 @@ func printPVC(pvcName string) {
5152 fmt .Printf ("\n PVC %s\n " , pvcName + " is not found" )
5253 fmt .Println (err .Error ())
5354 } else {
54- fmt . Printf ("\n PVC %s\n " , pvc .Name + " is found" )
55- printPVCListing (pvc .Name )
55+ log . Debug ("\n PVC %s\n " , pvc .Name + " is found" )
56+ PrintPVCListing (pvc .Name )
5657 }
5758
5859}
5960
60- func printPVCListing (pvcName string ) {
61+ func PrintPVCListing (pvcName string ) {
6162 var POD_PATH = viper .GetString ("PGO.LSPVC_TEMPLATE" )
6263 var PodTemplate * template.Template
6364 var err error
@@ -91,10 +92,19 @@ func printPVCListing(pvcName string) {
9192 }
9293 PodTemplate = template .Must (template .New ("pod template" ).Parse (string (buf )))
9394
95+ pvcRoot := "/"
96+ if PVCRoot != "" {
97+ log .Debug ("using " + PVCRoot + " as the PVC listing root" )
98+ pvcRoot = PVCRoot
99+ fmt .Println (pvcName + "/" + pvcRoot )
100+ } else {
101+ fmt .Println (pvcName )
102+ }
103+
94104 podFields := PodTemplateFields {
95105 Name : podName ,
96106 CO_IMAGE_TAG : viper .GetString ("PGO.CO_IMAGE_TAG" ),
97- BACKUP_ROOT : "/" ,
107+ BACKUP_ROOT : pvcRoot ,
98108 PVC_NAME : pvcName ,
99109 }
100110
@@ -122,8 +132,13 @@ func printPVCListing(pvcName string) {
122132 }
123133 log .Debug ("created pod " + resultPod .Name )
124134
125- //sleep a bit for the pod to finish, replace later with watch or better
126- time .Sleep (3000 * time .Millisecond )
135+ timeout := time .Duration (6 * time .Second )
136+ lo := v1.ListOptions {LabelSelector : "name=lspvc,pvcname=" + pvcName }
137+ podPhase := v1 .PodSucceeded
138+ err = util .WaitUntilPod (Clientset , lo , podPhase , timeout , Namespace )
139+ if err != nil {
140+ log .Error ("error waiting on lspvc pod to complete" + err .Error ())
141+ }
127142
128143 //get lspvc pod output
129144 logOptions := v1.PodLogOptions {}
0 commit comments