Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7499995
:running: support release notes on new version
DirectXMan12 Apr 22, 2019
52f4a7c
Fix docs & comments referring to "Reconciler" instead of "reconcile"
luksa May 17, 2019
2d952ac
webhook: Handle TLS certificate rotation
bison May 20, 2019
96b67f2
Merge pull request #421 from bison/tls-reload
k8s-ci-robot May 20, 2019
d79d6ae
update contributing.md
anthonyho007 May 21, 2019
d850185
:sparkles: webhook server doesn't use leader election by default
May 24, 2019
e381b18
Merge pull request #441 from mengqiy/webhook_le
k8s-ci-robot May 24, 2019
0af7a98
:bug: set status in conversion response
May 24, 2019
e72b0e7
Merge pull request #434 from luksa/fix_docs
k8s-ci-robot May 24, 2019
13ee2bc
Merge pull request #443 from mengqiy/conversionstatus
k8s-ci-robot May 24, 2019
1da1a4b
Merge pull request #438 from anthonyho007/fix-contribute.md
k8s-ci-robot May 29, 2019
761e03e
update internal controller for more clean code and metrics
adohe May 30, 2019
31d8c66
:sparkles: Allow setting "UseExistingCluster" via environment
adohe May 30, 2019
0532336
Merge pull request #448 from adohe/update_internal_controller
k8s-ci-robot May 30, 2019
5320b25
Merge pull request #449 from adohe/support_use_existing_cluster
k8s-ci-robot May 30, 2019
2a14111
Allow setting controller name, fix default
DirectXMan12 May 30, 2019
b56d269
Merge pull request #458 from DirectXMan12/bug/metrics-compatible-defa…
k8s-ci-robot May 30, 2019
267523b
:sparkles: more visibility of the testing control plane
May 30, 2019
228ca93
Merge pull request #404 from DirectXMan12/infra/release-notes-cross-v…
k8s-ci-robot May 31, 2019
bce1e17
Merge pull request #459 from mengqiy/controlplanevisibility
k8s-ci-robot May 31, 2019
596620d
:ghost: add webhook markers in the example
May 31, 2019
b88347b
Merge pull request #462 from mengqiy/addmarkers
k8s-ci-robot Jun 4, 2019
55c40b7
:running: use :ghost: for no release note commits
Jun 4, 2019
96826f6
🐛 Fix race when adding runnable
abursavich Jun 4, 2019
aa16141
Merge pull request #465 from mengqiy/ghost
k8s-ci-robot Jun 5, 2019
17e0976
Verify Emoji with GH actions
DirectXMan12 Jun 5, 2019
cd4692d
Merge pull request #474 from DirectXMan12/infra/verify-emoji
k8s-ci-robot Jun 6, 2019
be010e1
Merge pull request #466 from abursavich/dontpanic
k8s-ci-robot Jun 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🐛 Fix race when adding runnable
  • Loading branch information
abursavich committed Jun 5, 2019
commit 96826f6b55a31dfa5a43c904fe14da2f8ba07010
42 changes: 24 additions & 18 deletions pkg/manager/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,7 @@ func (cm *controllerManager) startNonLeaderElectionRunnables() {
cm.mu.Lock()
defer cm.mu.Unlock()

// Start the Cache. Allow the function to start the cache to be mocked out for testing
if cm.startCache == nil {
cm.startCache = cm.cache.Start
}
go func() {
if err := cm.startCache(cm.internalStop); err != nil {
cm.errChan <- err
}
}()

// Wait for the caches to sync.
// TODO(community): Check the return value and write a test
cm.cache.WaitForCacheSync(cm.internalStop)
cm.waitForCache()

// Start the non-leaderelection Runnables after the cache has synced
for _, c := range cm.nonLeaderElectionRunnables {
Expand All @@ -311,14 +299,13 @@ func (cm *controllerManager) startNonLeaderElectionRunnables() {
cm.errChan <- ctrl.Start(cm.internalStop)
}()
}

cm.started = true
}

func (cm *controllerManager) startLeaderElectionRunnables() {
// Wait for the caches to sync.
// TODO(community): Check the return value and write a test
cm.cache.WaitForCacheSync(cm.internalStop)
cm.mu.Lock()
defer cm.mu.Unlock()

cm.waitForCache()

// Start the leader election Runnables after the cache has synced
for _, c := range cm.leaderElectionRunnables {
Expand All @@ -329,7 +316,26 @@ func (cm *controllerManager) startLeaderElectionRunnables() {
cm.errChan <- ctrl.Start(cm.internalStop)
}()
}
}

func (cm *controllerManager) waitForCache() {
if cm.started {
return
}

// Start the Cache. Allow the function to start the cache to be mocked out for testing
if cm.startCache == nil {
cm.startCache = cm.cache.Start
}
go func() {
if err := cm.startCache(cm.internalStop); err != nil {
cm.errChan <- err
}
}()

// Wait for the caches to sync.
// TODO(community): Check the return value and write a test
cm.cache.WaitForCacheSync(cm.internalStop)
cm.started = true
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ var _ = Describe("manger.Manager", func() {
Expect(err).NotTo(HaveOccurred())
c1 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer close(c1)
defer GinkgoRecover()
close(c1)
return nil
}))).To(Succeed())

c2 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer close(c2)
defer GinkgoRecover()
close(c2)
return nil
}))).To(Succeed())

Expand Down Expand Up @@ -257,21 +257,21 @@ var _ = Describe("manger.Manager", func() {
c1 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer GinkgoRecover()
defer close(c1)
close(c1)
return nil
}))).To(Succeed())

c2 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer GinkgoRecover()
defer close(c2)
close(c2)
return fmt.Errorf("expected error")
}))).To(Succeed())

c3 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer GinkgoRecover()
defer close(c3)
close(c3)
return nil
}))).To(Succeed())

Expand Down Expand Up @@ -441,8 +441,8 @@ var _ = Describe("manger.Manager", func() {
// Add one component before starting
c1 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer close(c1)
defer GinkgoRecover()
close(c1)
return nil
}))).To(Succeed())

Expand All @@ -457,8 +457,8 @@ var _ = Describe("manger.Manager", func() {
// Add another component after starting
c2 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer close(c2)
defer GinkgoRecover()
close(c2)
return nil
}))).To(Succeed())
<-c1
Expand All @@ -483,8 +483,8 @@ var _ = Describe("manger.Manager", func() {

c1 := make(chan struct{})
Expect(m.Add(RunnableFunc(func(s <-chan struct{}) error {
defer close(c1)
defer GinkgoRecover()
close(c1)
return nil
}))).To(Succeed())
<-c1
Expand Down