Skip to content

Commit 2748ac6

Browse files
authored
Merge pull request kubernetes#75305 from justinsb/workaround_once_mutex_issue
Speculative workaround for kubernetes#74890
2 parents e7d09ce + 803de74 commit 2748ac6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/e2e/lifecycle/cluster_upgrade.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"path/filepath"
2525
"regexp"
2626
"strings"
27-
"sync"
27+
"sync/atomic"
2828
"time"
2929

3030
"k8s.io/apimachinery/pkg/util/version"
@@ -434,11 +434,19 @@ type chaosMonkeyAdapter struct {
434434

435435
func (cma *chaosMonkeyAdapter) Test(sem *chaosmonkey.Semaphore) {
436436
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
438446
ready := func() {
439-
once.Do(func() {
447+
if atomic.CompareAndSwapUint32(&onceWithoutMutex, 0, 1) {
440448
sem.Ready()
441-
})
449+
}
442450
}
443451
defer finalizeUpgradeTest(start, cma.testReport)
444452
defer ready()

0 commit comments

Comments
 (0)