@@ -4,10 +4,10 @@ import (
44 "fmt"
55 "time"
66
7+ "github.com/deis/builder/pkg/k8s"
78 "github.com/pborman/uuid"
89 "k8s.io/kubernetes/pkg/api"
9- apierrs "k8s.io/kubernetes/pkg/api/errors"
10- client "k8s.io/kubernetes/pkg/client/unversioned"
10+ "k8s.io/kubernetes/pkg/labels"
1111 "k8s.io/kubernetes/pkg/util/wait"
1212)
1313
@@ -171,7 +171,7 @@ func addEnvToPod(pod api.Pod, key, value string) {
171171}
172172
173173// waitForPod waits for a pod in state running, succeeded or failed
174- func waitForPod (c * client. Client , ns , podName string , ticker , interval , timeout time.Duration ) error {
174+ func waitForPod (pw * k8s. PodWatcher , ns , podName string , ticker , interval , timeout time.Duration ) error {
175175 condition := func (pod * api.Pod ) (bool , error ) {
176176 if pod .Status .Phase == api .PodRunning {
177177 return true , nil
@@ -186,14 +186,14 @@ func waitForPod(c *client.Client, ns, podName string, ticker, interval, timeout
186186 }
187187
188188 quit := progress ("..." , ticker )
189- err := waitForPodCondition (c , ns , podName , condition , interval , timeout )
189+ err := waitForPodCondition (pw , ns , podName , condition , interval , timeout )
190190 quit <- true
191191 <- quit
192192 return err
193193}
194194
195195// waitForPodEnd waits for a pod in state succeeded or failed
196- func waitForPodEnd (c * client. Client , ns , podName string , interval , timeout time.Duration ) error {
196+ func waitForPodEnd (pw * k8s. PodWatcher , ns , podName string , interval , timeout time.Duration ) error {
197197 condition := func (pod * api.Pod ) (bool , error ) {
198198 if pod .Status .Phase == api .PodSucceeded {
199199 return true , nil
@@ -204,21 +204,19 @@ func waitForPodEnd(c *client.Client, ns, podName string, interval, timeout time.
204204 return false , nil
205205 }
206206
207- return waitForPodCondition (c , ns , podName , condition , interval , timeout )
207+ return waitForPodCondition (pw , ns , podName , condition , interval , timeout )
208208}
209209
210210// waitForPodCondition waits for a pod in state defined by a condition (func)
211- func waitForPodCondition (c * client. Client , ns , podName string , condition func (pod * api.Pod ) (bool , error ),
211+ func waitForPodCondition (pw * k8s. PodWatcher , ns , podName string , condition func (pod * api.Pod ) (bool , error ),
212212 interval , timeout time.Duration ) error {
213213 return wait .PollImmediate (interval , timeout , func () (bool , error ) {
214- pod , err := c .Pods (ns ).Get (podName )
215- if err != nil {
216- if apierrs .IsNotFound (err ) {
217- return false , nil
218- }
214+ pods , err := pw .Store .List (labels.Set {"heritage" : podName }.AsSelector ())
215+ if err != nil || len (pods ) == 0 {
216+ return false , nil
219217 }
220218
221- done , err := condition (pod )
219+ done , err := condition (pods [ 0 ] )
222220 if err != nil {
223221 return false , err
224222 }
0 commit comments