Skip to content

Commit 2c0a9d1

Browse files
committed
fix retry logic
1 parent b027169 commit 2c0a9d1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/e2e/utils/utils.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,24 @@ func GCEClientAndDriverSetup(instance *remote.InstanceInfo) (*remote.TestContext
6767

6868
// getBoskosProject retries acquiring a boskos project until success or timeout
6969
func getBoskosProject(resourceType string) *common.Resource {
70-
timeout := time.After(30 * time.Minute)
71-
tick := time.After(1 * time.Minute)
70+
timer := time.NewTimer(30 * time.Minute)
71+
defer timer.Stop()
72+
ticker := time.NewTicker(1 * time.Minute)
73+
defer ticker.Stop()
74+
7275
for {
7376
select {
74-
case <-timeout:
77+
case <-timer.C:
7578
glog.Fatalf("timed out trying to acquire boskos project")
76-
case <-tick:
79+
case <-ticker.C:
7780
p, err := boskos.Acquire(resourceType, "free", "busy")
7881
if err != nil {
7982
glog.Warningf("boskos failed to acquire project: %v", err)
80-
}
81-
if p == nil {
83+
} else if p == nil {
8284
glog.Warningf("boskos does not have a free %s at the moment", resourceType)
85+
} else {
86+
return p
8387
}
84-
return p
8588
}
8689
}
8790

0 commit comments

Comments
 (0)