@@ -26,6 +26,7 @@ import (
26
26
"golang.org/x/oauth2/google"
27
27
cloudresourcemanager "google.golang.org/api/cloudresourcemanager/v1"
28
28
boskosclient "k8s.io/test-infra/boskos/client"
29
+ "k8s.io/test-infra/boskos/common"
29
30
remote "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/test/remote"
30
31
)
31
32
@@ -64,20 +65,34 @@ func GCEClientAndDriverSetup(instance *remote.InstanceInfo) (*remote.TestContext
64
65
return remote .SetupNewDriverAndClient (instance , config )
65
66
}
66
67
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
+
67
90
func SetupProwConfig (resourceType string ) (project , serviceAccount string ) {
68
91
// Try to get a Boskos project
69
92
glog .V (4 ).Infof ("Running in PROW" )
70
93
glog .V (4 ).Infof ("Fetching a Boskos loaned project" )
71
94
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 )
81
96
project = p .GetName ()
82
97
83
98
go func (c * boskosclient.Client , proj string ) {
0 commit comments