Fix staticcheck failures for vendor/k8s.io/client-go/transport (#100429)

* Fix staticcheck failures for vendor/k8s.io/client-go/transport

* avoid the possibility of a hang
This commit is contained in:
Huang Huang 2021-04-11 11:29:15 +08:00 committed by GitHub
parent 3723713c55
commit 02d20442a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -22,4 +22,3 @@ vendor/k8s.io/apiserver/pkg/util/webhook
vendor/k8s.io/apiserver/pkg/util/wsstream
vendor/k8s.io/client-go/rest
vendor/k8s.io/client-go/rest/watch
vendor/k8s.io/client-go/transport

View File

@ -140,16 +140,23 @@ func TestCachingTokenSourceRace(t *testing.T) {
var wg sync.WaitGroup
wg.Add(100)
errc := make(chan error, 100)
for i := 0; i < 100; i++ {
go func() {
defer wg.Done()
if _, err := ts.Token(); err != nil {
t.Fatalf("err: %v", err)
errc <- err
}
}()
}
wg.Wait()
go func() {
wg.Wait()
close(errc)
}()
if err, ok := <-errc; ok {
t.Fatalf("err: %v", err)
}
if tts.calls != 1 {
t.Errorf("expected one call to Token() but saw: %d", tts.calls)
}