Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
9f35eebb
Commit
9f35eebb
authored
Dec 22, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timeout in etcdwatcher tests
parent
1f26fa40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
etcd_watcher.go
pkg/storage/etcd/etcd_watcher.go
+6
-3
No files found.
pkg/storage/etcd/etcd_watcher.go
View file @
9f35eebb
...
@@ -150,8 +150,7 @@ func (w *etcdWatcher) etcdWatch(ctx context.Context, client etcd.KeysAPI, key st
...
@@ -150,8 +150,7 @@ func (w *etcdWatcher) etcdWatch(ctx context.Context, client etcd.KeysAPI, key st
// All calls to etcd are coming from this function - once it is finished
// All calls to etcd are coming from this function - once it is finished
// no other call to etcd should be generated by this watcher.
// no other call to etcd should be generated by this watcher.
w
.
wg
.
Add
(
1
)
done
:=
func
()
{}
defer
w
.
wg
.
Done
()
// We need to be prepared, that Stop() can be called at any time.
// We need to be prepared, that Stop() can be called at any time.
// It can potentially also be called, even before this function is called.
// It can potentially also be called, even before this function is called.
...
@@ -165,6 +164,8 @@ func (w *etcdWatcher) etcdWatch(ctx context.Context, client etcd.KeysAPI, key st
...
@@ -165,6 +164,8 @@ func (w *etcdWatcher) etcdWatch(ctx context.Context, client etcd.KeysAPI, key st
// Watcher has already been stopped - don't event initiate it here.
// Watcher has already been stopped - don't event initiate it here.
return
true
return
true
}
}
w
.
wg
.
Add
(
1
)
done
=
w
.
wg
.
Done
// Perform initialization of watcher under lock - we want to avoid situation when
// Perform initialization of watcher under lock - we want to avoid situation when
// Stop() is called in the meantime (which in tests can cause etcd termination and
// Stop() is called in the meantime (which in tests can cause etcd termination and
// strange behavior here).
// strange behavior here).
...
@@ -185,6 +186,7 @@ func (w *etcdWatcher) etcdWatch(ctx context.Context, client etcd.KeysAPI, key st
...
@@ -185,6 +186,7 @@ func (w *etcdWatcher) etcdWatch(ctx context.Context, client etcd.KeysAPI, key st
w
.
ctx
,
w
.
cancel
=
context
.
WithCancel
(
ctx
)
w
.
ctx
,
w
.
cancel
=
context
.
WithCancel
(
ctx
)
return
false
return
false
}()
}()
defer
done
()
if
returned
{
if
returned
{
return
return
}
}
...
@@ -455,7 +457,6 @@ func (w *etcdWatcher) ResultChan() <-chan watch.Event {
...
@@ -455,7 +457,6 @@ func (w *etcdWatcher) ResultChan() <-chan watch.Event {
// Stop implements watch.Interface.
// Stop implements watch.Interface.
func
(
w
*
etcdWatcher
)
Stop
()
{
func
(
w
*
etcdWatcher
)
Stop
()
{
w
.
stopLock
.
Lock
()
w
.
stopLock
.
Lock
()
defer
w
.
stopLock
.
Unlock
()
if
w
.
cancel
!=
nil
{
if
w
.
cancel
!=
nil
{
w
.
cancel
()
w
.
cancel
()
w
.
cancel
=
nil
w
.
cancel
=
nil
...
@@ -464,6 +465,8 @@ func (w *etcdWatcher) Stop() {
...
@@ -464,6 +465,8 @@ func (w *etcdWatcher) Stop() {
w
.
stopped
=
true
w
.
stopped
=
true
close
(
w
.
userStop
)
close
(
w
.
userStop
)
}
}
w
.
stopLock
.
Unlock
()
// Wait until all calls to etcd are finished and no other
// Wait until all calls to etcd are finished and no other
// will be issued.
// will be issued.
w
.
wg
.
Wait
()
w
.
wg
.
Wait
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment