From 803de7468546277940d4acd0b7a30416780d8627 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Tue, 12 Mar 2019 18:08:02 -0400 Subject: [PATCH] Speculative workaround for #74890 We try using an atomic with a CAS, as a potential workaround for issue #74890. Kudos to @neolit123 for the investigation & idea. 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! Issue #74890 --- test/e2e/lifecycle/cluster_upgrade.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/e2e/lifecycle/cluster_upgrade.go b/test/e2e/lifecycle/cluster_upgrade.go index a3a0a730af..50f054fed3 100644 --- a/test/e2e/lifecycle/cluster_upgrade.go +++ b/test/e2e/lifecycle/cluster_upgrade.go @@ -24,7 +24,7 @@ import ( "path/filepath" "regexp" "strings" - "sync" + "sync/atomic" "time" "k8s.io/apimachinery/pkg/util/version" @@ -434,11 +434,19 @@ type chaosMonkeyAdapter struct { func (cma *chaosMonkeyAdapter) Test(sem *chaosmonkey.Semaphore) { 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() { - once.Do(func() { + if atomic.CompareAndSwapUint32(&onceWithoutMutex, 0, 1) { sem.Ready() - }) + } } defer finalizeUpgradeTest(start, cma.testReport) defer ready()