@@ -43,6 +43,10 @@ func mcCmd(configDir string, args ...string) *exec.Cmd {
4343 return cmd
4444}
4545
46+ func kGetCmd (podNS , podName string ) * exec.Cmd {
47+ return exec .Command ("kubectl" , fmt .Sprintf ("--namespace=%s" , podNS ), "get" , "pods" , "-o" , "yaml" , podName )
48+ }
49+
4650// run prints the command it will execute to the debug log, then runs it and returns the result of run
4751func run (cmd * exec.Cmd ) error {
4852 cmdStr := strings .Join (cmd .Args , " " )
@@ -331,27 +335,14 @@ func build(conf *Config, builderKey, gitSha string) error {
331335
332336 // poll kubectl every 100ms to determine when the build pod is running
333337 // TODO: use the k8s client and watch the event stream instead (https://github.com/deis/builder/issues/65)
334- kGetCmd := exec .Command (
335- "kubectl" ,
336- fmt .Sprintf ("--namespace=%s" , conf .PodNamespace ),
337- fmt .Sprintf ("get" ),
338- fmt .Sprintf ("pods" ),
339- "-o" ,
340- "yaml" ,
341- buildPodName ,
342- )
343338 for {
339+ cmd := kGetCmd (conf .PodNamespace , buildPodName )
344340 var out bytes.Buffer
345- kGetCmd .Stdout = & out
346- if err := run (kGetCmd ); err != nil {
347- return fmt .Errorf (
348- "running %s while determining if builder pod %s is running (%s)" ,
349- strings .Join (kGetCmd .Args , " " ),
350- buildPodName ,
351- err ,
352- )
353- }
354- if strings .Contains (string (out .Bytes ()), "phase: Running" ) {
341+ cmd .Stdout = & out
342+ // ignore errors
343+ run (cmd )
344+ outStr := string (out .Bytes ())
345+ if strings .Contains (outStr , "phase: Running" ) {
355346 break
356347 } else if strings .Contains (outStr , "phase: Failed" ) {
357348 return fmt .Errorf ("build pod %s entered phase: Failed" , buildPodName )
0 commit comments