@@ -26,6 +26,7 @@ import (
2626 "golang.org/x/oauth2/google"
2727 cloudresourcemanager "google.golang.org/api/cloudresourcemanager/v1"
2828 boskosclient "k8s.io/test-infra/boskos/client"
29+ "k8s.io/test-infra/boskos/common"
2930 remote "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/test/remote"
3031)
3132
@@ -64,20 +65,34 @@ func GCEClientAndDriverSetup(instance *remote.InstanceInfo) (*remote.TestContext
6465 return remote .SetupNewDriverAndClient (instance , config )
6566}
6667
68+ // getBoskosProject retries acquiring a boskos project until success or timeout
69+ func getBoskosProject (resourceType string ) * common.Resource {
70+ timeout := time .After (30 * time .Minute )
71+ tick := time .After (1 * time .Minute )
72+ for {
73+ select {
74+ case <- timeout :
75+ glog .Fatalf ("timed out trying to acquire boskos project" )
76+ case <- tick :
77+ p , err := boskos .Acquire (resourceType , "free" , "busy" )
78+ if err != nil {
79+ glog .Warningf ("boskos failed to acquire project: %v" , err )
80+ }
81+ if p == nil {
82+ glog .Warningf ("boskos does not have a free %s at the moment" , resourceType )
83+ }
84+ return p
85+ }
86+ }
87+
88+ }
89+
6790func SetupProwConfig (resourceType string ) (project , serviceAccount string ) {
6891 // Try to get a Boskos project
6992 glog .V (4 ).Infof ("Running in PROW" )
7093 glog .V (4 ).Infof ("Fetching a Boskos loaned project" )
7194
72- p , err := boskos .Acquire (resourceType , "free" , "busy" )
73- if err != nil {
74- glog .Fatalf ("boskos failed to acquire project: %v" , err )
75- }
76-
77- if p == nil {
78- glog .Fatal ("boskos does not have a free %s at the moment" , resourceType )
79- }
80-
95+ p := getBoskosProject (resourceType )
8196 project = p .GetName ()
8297
8398 go func (c * boskosclient.Client , proj string ) {
0 commit comments