77 "sync"
88 "time"
99
10- "github.com/coreos/fleet/client"
1110 "github.com/coreos/fleet/job"
1211)
1312
@@ -38,12 +37,12 @@ func testUnitStateActive(j *job.Job) bool {
3837// than zero. Returned is an error channel used to communicate when
3938// timeouts occur. The returned error channel will be closed after all
4039// polling operation is complete.
41- func waitForJobStates (cAPI client. API , jobs []string , test testJob , maxAttempts int , out io.Writer ) chan error {
40+ func waitForJobStates (jobs []string , test testJob , maxAttempts int , out io.Writer ) chan error {
4241 errchan := make (chan error )
4342 var wg sync.WaitGroup
4443 for _ , name := range jobs {
4544 wg .Add (1 )
46- go checkJobState (cAPI , name , test , maxAttempts , out , & wg , errchan )
45+ go checkJobState (name , test , maxAttempts , out , & wg , errchan )
4746 }
4847 go func () {
4948 wg .Wait ()
@@ -52,19 +51,19 @@ func waitForJobStates(cAPI client.API, jobs []string, test testJob, maxAttempts
5251 return errchan
5352}
5453
55- func checkJobState (cAPI client. API , jobName string , test testJob , maxAttempts int , out io.Writer , wg * sync.WaitGroup , errchan chan error ) {
54+ func checkJobState (jobName string , test testJob , maxAttempts int , out io.Writer , wg * sync.WaitGroup , errchan chan error ) {
5655 defer wg .Done ()
5756 sleep := 100 * time .Millisecond
5857 if maxAttempts < 1 {
5958 for {
60- if assertJobState (cAPI , jobName , test , out ) {
59+ if assertJobState (jobName , test , out ) {
6160 return
6261 }
6362 time .Sleep (sleep )
6463 }
6564 } else {
6665 for attempt := 0 ; attempt < maxAttempts ; attempt ++ {
67- if assertJobState (cAPI , jobName , test , out ) {
66+ if assertJobState (jobName , test , out ) {
6867 return
6968 }
7069 time .Sleep (sleep )
@@ -73,7 +72,7 @@ func checkJobState(cAPI client.API, jobName string, test testJob, maxAttempts in
7372 }
7473}
7574
76- func assertJobState (cAPI client. API , name string , test testJob , out io.Writer ) (ret bool ) {
75+ func assertJobState (name string , test testJob , out io.Writer ) (ret bool ) {
7776 j , err := cAPI .Job (name )
7877 if err != nil {
7978 fmt .Fprintf (os .Stderr , "Error retrieving Job(%s) from Registry: %v" , name , err )
@@ -94,21 +93,12 @@ func assertJobState(cAPI client.API, name string, test testJob, out io.Writer) (
9493 msg = fmt .Sprintf ("\033 [0;33m%v:\033 [0m %v" , name , * (j .State ))
9594 }
9695
97- tgt , err := cAPI .JobTarget (name )
98- if err != nil {
99- fmt .Fprintf (os .Stderr , "Error retrieving target information for Job(%s) from Registry: %v" , name , err )
100- return
101- }
102- if tgt == "" {
103- return
104- }
105-
10696 machines , err := cAPI .Machines ()
10797 if err != nil {
10898 fmt .Fprintf (os .Stderr , "Failed retrieving list of Machines from Registry: %v" , err )
10999 }
110100 for _ , ms := range machines {
111- if ms .ID != tgt {
101+ if ms .ID != j . TargetMachineID {
112102 continue
113103 }
114104 msg = fmt .Sprintf ("%s on %s" , msg , machineFullLegend (ms , false ))
0 commit comments