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
5e0e8bfa
Commit
5e0e8bfa
authored
May 30, 2017
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix flake
parent
052cd6d3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
17 deletions
+15
-17
configuration_manager.go
...piserver/admission/configuration/configuration_manager.go
+9
-6
initializer_manager_test.go
...erver/admission/configuration/initializer_manager_test.go
+6
-11
No files found.
pkg/kubeapiserver/admission/configuration/configuration_manager.go
View file @
5e0e8bfa
...
@@ -46,6 +46,8 @@ type poller struct {
...
@@ -46,6 +46,8 @@ type poller struct {
// if the number of consecutive read failure equals or exceeds the failureThreshold , the
// if the number of consecutive read failure equals or exceeds the failureThreshold , the
// configuration is regarded as not ready.
// configuration is regarded as not ready.
failureThreshold
int
failureThreshold
int
// number of consecutive failures so far.
failures
int
// if the configuration is regarded as ready.
// if the configuration is regarded as ready.
ready
bool
ready
bool
mergedConfiguration
runtime
.
Object
mergedConfiguration
runtime
.
Object
...
@@ -84,17 +86,18 @@ func (a *poller) setConfigurationAndReady(value runtime.Object) {
...
@@ -84,17 +86,18 @@ func (a *poller) setConfigurationAndReady(value runtime.Object) {
}
}
func
(
a
*
poller
)
Run
(
stopCh
<-
chan
struct
{})
{
func
(
a
*
poller
)
Run
(
stopCh
<-
chan
struct
{})
{
var
failure
int
go
wait
.
Until
(
a
.
sync
,
a
.
interval
,
stopCh
)
go
wait
.
Until
(
func
()
{
}
func
(
a
*
poller
)
sync
()
{
configuration
,
err
:=
a
.
get
()
configuration
,
err
:=
a
.
get
()
if
err
!=
nil
{
if
err
!=
nil
{
failure
++
a
.
failures
++
if
failure
>=
a
.
failureThreshold
{
if
a
.
failures
>=
a
.
failureThreshold
{
a
.
notReady
()
a
.
notReady
()
}
}
return
return
}
}
failure
=
0
a
.
failures
=
0
a
.
setConfigurationAndReady
(
configuration
)
a
.
setConfigurationAndReady
(
configuration
)
},
a
.
interval
,
stopCh
)
}
}
pkg/kubeapiserver/admission/configuration/initializer_manager_test.go
View file @
5e0e8bfa
...
@@ -30,7 +30,6 @@ type mockLister struct {
...
@@ -30,7 +30,6 @@ type mockLister struct {
invoked
int
invoked
int
successes
int
successes
int
failures
int
failures
int
stopCh
chan
struct
{}
configurationList
v1alpha1
.
InitializerConfigurationList
configurationList
v1alpha1
.
InitializerConfigurationList
t
*
testing
.
T
t
*
testing
.
T
}
}
...
@@ -40,20 +39,15 @@ func newMockLister(successes, failures int, configurationList v1alpha1.Initializ
...
@@ -40,20 +39,15 @@ func newMockLister(successes, failures int, configurationList v1alpha1.Initializ
failures
:
failures
,
failures
:
failures
,
successes
:
successes
,
successes
:
successes
,
configurationList
:
configurationList
,
configurationList
:
configurationList
,
stopCh
:
make
(
chan
struct
{}),
t
:
t
,
t
:
t
,
}
}
}
}
// The first List will be successful; the next m.failures List will
// The first List will be successful; the next m.failures List will
// fail; the next m.successes List will be successful
; the stopCh is closed at
// fail; the next m.successes List will be successful
//
the 1+m.failures+m.successes call
.
//
List should only be called 1+m.failures+m.successes times
.
func
(
m
*
mockLister
)
List
(
options
metav1
.
ListOptions
)
(
*
v1alpha1
.
InitializerConfigurationList
,
error
)
{
func
(
m
*
mockLister
)
List
(
options
metav1
.
ListOptions
)
(
*
v1alpha1
.
InitializerConfigurationList
,
error
)
{
m
.
invoked
++
m
.
invoked
++
// m.successes could be 0, so call this `if` first.
if
m
.
invoked
==
1
+
m
.
failures
+
m
.
successes
{
close
(
m
.
stopCh
)
}
if
m
.
invoked
==
1
{
if
m
.
invoked
==
1
{
return
&
m
.
configurationList
,
nil
return
&
m
.
configurationList
,
nil
}
}
...
@@ -63,7 +57,7 @@ func (m *mockLister) List(options metav1.ListOptions) (*v1alpha1.InitializerConf
...
@@ -63,7 +57,7 @@ func (m *mockLister) List(options metav1.ListOptions) (*v1alpha1.InitializerConf
if
m
.
invoked
<=
1
+
m
.
failures
+
m
.
successes
{
if
m
.
invoked
<=
1
+
m
.
failures
+
m
.
successes
{
return
&
m
.
configurationList
,
nil
return
&
m
.
configurationList
,
nil
}
}
m
.
t
.
Fatalf
(
"unexpected call to List, s
topCh has been closed at the %d time call
"
,
1
+
m
.
successes
+
m
.
failures
)
m
.
t
.
Fatalf
(
"unexpected call to List, s
hould only be called %d times
"
,
1
+
m
.
successes
+
m
.
failures
)
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -103,8 +97,9 @@ func TestConfiguration(t *testing.T) {
...
@@ -103,8 +97,9 @@ func TestConfiguration(t *testing.T) {
mock
:=
newMockLister
(
c
.
successes
,
c
.
failures
,
v1alpha1
.
InitializerConfigurationList
{},
t
)
mock
:=
newMockLister
(
c
.
successes
,
c
.
failures
,
v1alpha1
.
InitializerConfigurationList
{},
t
)
manager
:=
NewInitializerConfigurationManager
(
mock
)
manager
:=
NewInitializerConfigurationManager
(
mock
)
manager
.
interval
=
1
*
time
.
Millisecond
manager
.
interval
=
1
*
time
.
Millisecond
manager
.
Run
(
mock
.
stopCh
)
for
i
:=
0
;
i
<
1
+
c
.
successes
+
c
.
failures
;
i
++
{
<-
mock
.
stopCh
manager
.
sync
()
}
_
,
err
:=
manager
.
Initializers
()
_
,
err
:=
manager
.
Initializers
()
if
err
!=
nil
&&
c
.
expectReady
{
if
err
!=
nil
&&
c
.
expectReady
{
t
.
Errorf
(
"case %s, expect ready, got: %v"
,
c
.
name
,
err
)
t
.
Errorf
(
"case %s, expect ready, got: %v"
,
c
.
name
,
err
)
...
...
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