File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import (
24
24
"path/filepath"
25
25
"regexp"
26
26
"strings"
27
- "sync"
27
+ "sync/atomic "
28
28
"time"
29
29
30
30
"k8s.io/apimachinery/pkg/util/version"
@@ -434,11 +434,19 @@ type chaosMonkeyAdapter struct {
434
434
435
435
func (cma * chaosMonkeyAdapter ) Test (sem * chaosmonkey.Semaphore ) {
436
436
start := time .Now ()
437
- var once sync.Once
437
+
438
+ // Using an atomic with a CAS is a potential workaround for #74890.
439
+ //
440
+ // This is a speculative workaround - we are really seeing if
441
+ // this is better; if not we should revert.
442
+ //
443
+ // If it is better we should file a bug against go 1.12, and
444
+ // then revert!
445
+ var onceWithoutMutex uint32
438
446
ready := func () {
439
- once . Do ( func ( ) {
447
+ if atomic . CompareAndSwapUint32 ( & onceWithoutMutex , 0 , 1 ) {
440
448
sem .Ready ()
441
- })
449
+ }
442
450
}
443
451
defer finalizeUpgradeTest (start , cma .testReport )
444
452
defer ready ()
You can’t perform that action at this time.
0 commit comments