mirror of https://github.com/k3s-io/k3s
Merge pull request #75305 from justinsb/workaround_once_mutex_issue
Speculative workaround for #74890pull/564/head
commit
2748ac6210
|
@ -24,7 +24,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/version"
|
"k8s.io/apimachinery/pkg/util/version"
|
||||||
|
@ -434,11 +434,19 @@ type chaosMonkeyAdapter struct {
|
||||||
|
|
||||||
func (cma *chaosMonkeyAdapter) Test(sem *chaosmonkey.Semaphore) {
|
func (cma *chaosMonkeyAdapter) Test(sem *chaosmonkey.Semaphore) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
var once sync.Once
|
|
||||||
|
// Using an atomic with a CAS is a potential workaround for #74890.
|
||||||
|
//
|
||||||
|
// This is a speculative workaround - we are really seeing if
|
||||||
|
// this is better; if not we should revert.
|
||||||
|
//
|
||||||
|
// If it is better we should file a bug against go 1.12, and
|
||||||
|
// then revert!
|
||||||
|
var onceWithoutMutex uint32
|
||||||
ready := func() {
|
ready := func() {
|
||||||
once.Do(func() {
|
if atomic.CompareAndSwapUint32(&onceWithoutMutex, 0, 1) {
|
||||||
sem.Ready()
|
sem.Ready()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
defer finalizeUpgradeTest(start, cma.testReport)
|
defer finalizeUpgradeTest(start, cma.testReport)
|
||||||
defer ready()
|
defer ready()
|
||||||
|
|
Loading…
Reference in New Issue