Weiwei Yang created YUNIKORN-805: ------------------------------------ Summary: Fix race condition on the TestMode flag Key: YUNIKORN-805 URL: https://issues.apache.org/jira/browse/YUNIKORN-805 Project: Apache YuniKorn Issue Type: Bug Components: shim - kubernetes Reporter: Weiwei Yang Fix For: 1.0.0
We see the following data race while running UT: {code} ================== WARNING: DATA RACE Write at 0x00c000030168 by goroutine 18: github.com/apache/incubator-yunikorn-k8shim/pkg/conf.(*SchedulerConf).SetTestMode() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/conf/schedulerconf.go:83 +0x8c github.com/apache/incubator-yunikorn-k8shim/pkg/shim.(*MockScheduler).init() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler_mock_test.go:58 +0x89 github.com/apache/incubator-yunikorn-k8shim/pkg/shim.TestTaskFailures() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler_test.go:194 +0x89 testing.tRunner() /usr/local/go/src/testing/testing.go:1193 +0x202 Previous read at 0x00c000030168 by goroutine 16: github.com/apache/incubator-yunikorn-k8shim/pkg/shim.(*KubernetesShim).handleSchedulerFailure() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler.go:149 +0xa4 github.com/apache/incubator-yunikorn-k8shim/pkg/shim.(*KubernetesShim).handleSchedulerFailure-fm() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler.go:147 +0x54 github.com/looplab/fsm.(*FSM).afterEventCallbacks() /Users/chenyazhang/go/pkg/mod/github.com/looplab/fsm@v0.1.0/fsm.go:414 +0x196 github.com/looplab/fsm.(*FSM).Event.func1() /Users/chenyazhang/go/pkg/mod/github.com/looplab/fsm@v0.1.0/fsm.go:309 +0xdc github.com/looplab/fsm.transitionerStruct.transition() /Users/chenyazhang/go/pkg/mod/github.com/looplab/fsm@v0.1.0/fsm.go:354 +0xc7 github.com/looplab/fsm.(*transitionerStruct).transition() <autogenerated>:1 +0x2e github.com/looplab/fsm.(*FSM).doTransition() /Users/chenyazhang/go/pkg/mod/github.com/looplab/fsm@v0.1.0/fsm.go:339 +0x6b9 github.com/looplab/fsm.(*FSM).Event() /Users/chenyazhang/go/pkg/mod/github.com/looplab/fsm@v0.1.0/fsm.go:321 +0x685 github.com/apache/incubator-yunikorn-k8shim/pkg/shim.(*KubernetesShim).handle() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler.go:241 +0x244 github.com/apache/incubator-yunikorn-k8shim/pkg/shim.(*KubernetesShim).SchedulerEventHandler.func1() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler.go:125 +0x14c github.com/apache/incubator-yunikorn-k8shim/pkg/dispatcher.Start.func1() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/dispatcher/dispatcher.go:196 +0x60c Goroutine 18 (running) created at: testing.(*T).Run() /usr/local/go/src/testing/testing.go:1238 +0x5d7 testing.runTests.func1() /usr/local/go/src/testing/testing.go:1511 +0xa6 testing.tRunner() /usr/local/go/src/testing/testing.go:1193 +0x202 testing.runTests() /usr/local/go/src/testing/testing.go:1509 +0x612 testing.(*M).Run() /usr/local/go/src/testing/testing.go:1417 +0x3b3 main.main() _testmain.go:101 +0x356 Goroutine 16 (running) created at: github.com/apache/incubator-yunikorn-k8shim/pkg/dispatcher.Start() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/dispatcher/dispatcher.go:184 +0xa8 github.com/apache/incubator-yunikorn-k8shim/pkg/shim.(*KubernetesShim).run() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler.go:269 +0x64 github.com/apache/incubator-yunikorn-k8shim/pkg/shim.TestSchedulerRegistrationFailed() /Users/chenyazhang/Chenya-Eng/incubator-yunikorn-k8shim/pkg/shim/scheduler_test.go:165 +0x20d testing.tRunner() /usr/local/go/src/testing/testing.go:1193 +0x202 ================== {code} conf.TestMode can be modified during the test, to avoid race conditions, we should provide a IsTestMode function in the conf object with the R lock protected. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@yunikorn.apache.org For additional commands, e-mail: issues-h...@yunikorn.apache.org