Improve executor bootstrap speed (#1446)

This commit is contained in:
Ta-Ching Chen
2019-11-29 14:18:23 +08:00
committed by GitHub
parent 3067ecdee3
commit 47aaa85108
9 changed files with 134 additions and 127 deletions
+15
View File
@@ -17,6 +17,9 @@ limitations under the License.
package util
import (
"sync"
"time"
apiv1 "k8s.io/api/core/v1"
)
@@ -31,3 +34,15 @@ func ApplyImagePullSecret(secret string, podspec apiv1.PodSpec) *apiv1.PodSpec {
podspec.ImagePullSecrets = []apiv1.LocalObjectReference{{Name: secret}}
return &podspec
}
func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) {
waitCh := make(chan struct{})
go func() {
defer close(waitCh)
wg.Wait()
}()
select {
case <-waitCh:
case <-time.After(timeout):
}
}