Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Test fails with race detected #79

Closed
Fei-Guo opened this issue May 25, 2021 · 4 comments · Fixed by #84
Closed

Test fails with race detected #79

Fei-Guo opened this issue May 25, 2021 · 4 comments · Fixed by #84
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Fei-Guo
Copy link

Fei-Guo commented May 25, 2021

How to reproduce?

Sync to ToT and run make

=== RUN   TestReconcile
==================
WARNING: DATA RACE
Write at 0x00c0001146a8 by goroutine 41:
  internal/race.Write()
      /usr/local/go/src/internal/race/race.go:41 +0x114
  sync.(*WaitGroup).Wait()
      /usr/local/go/src/sync/waitgroup.go:128 +0x115
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).waitForRunnableToEnd.func2()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:567 +0x40

Previous read at 0x00c0001146a8 by goroutine 173:
  internal/race.Read()
      /usr/local/go/src/internal/race/race.go:37 +0x1e8
  sync.(*WaitGroup).Add()
      /usr/local/go/src/sync/waitgroup.go:71 +0x1fb
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).startRunnable()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:678 +0x4e
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).serveMetrics()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:384 +0x318

Goroutine 41 (running) created at:
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).waitForRunnableToEnd()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:566 +0xc6
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).engageStopProcedure()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:548 +0x370
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Start.func1()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:449 +0x49
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Start()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:499 +0x573
  sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/vcmanager.(*VirtualClusterManager).Start()
      <autogenerated>:1 +0x7d
  sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/virtualcluster.StartTestManager.func1()
      /Users/f.guo/go/src/sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/virtualcluster/virtualcluster_controller_suite_test.go:73 +0xb0

Goroutine 173 (running) created at:
  sigs.k8s.io/controller-runtime/pkg/manager.(*controllerManager).Start()
      /Users/f.guo/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/internal.go:473 +0x5d4
  sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/vcmanager.(*VirtualClusterManager).Start()
      <autogenerated>:1 +0x7d
  sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/virtualcluster.StartTestManager.func1()
      /Users/f.guo/go/src/sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/virtualcluster/virtualcluster_controller_suite_test.go:73 +0xb0
==================
    TestReconcile: testing.go:906: race detected during execution of test
--- FAIL: TestReconcile (0.16s)
    : testing.go:906: race detected during execution of test
FAIL
coverage: 10.7% of statements
FAIL	sigs.k8s.io/cluster-api-provider-nested/virtualcluster/pkg/controller/virtualcluster	11.843s

it can be 100% reproduced in my local machine.

@christopherhein
Copy link
Contributor

gah! alright, I'll check this out more was hoping it wasn't going to crop up. From what I looked into it before it's not a run code problem it's a test setup problem between the two startup processes for the controllers conflicting. I will dig more into it tomorrow.

@christopherhein
Copy link
Contributor

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 25, 2021
@Fei-Guo
Copy link
Author

Fei-Guo commented May 25, 2021

It is specific to the controller test suite code which was originated from old kubebuilder I believe. Other UTs were working fine.

@christopherhein
Copy link
Contributor

Yeah, it's about the addition of the context.Context in the controller code, this is one of the reasons that made breaking NCP and NC a good choice cause having separate controllers for and test suites often have conflicts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
3 participants