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
b7bc9b11
Commit
b7bc9b11
authored
Nov 06, 2017
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resync status on apiservices for aggregator
parent
33f873db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
apiserver.go
...ing/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go
+2
-1
available_controller.go
...aggregator/pkg/controllers/status/available_controller.go
+31
-24
No files found.
staging/src/k8s.io/kube-aggregator/pkg/apiserver/apiserver.go
View file @
b7bc9b11
...
@@ -221,7 +221,8 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
...
@@ -221,7 +221,8 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
return
nil
return
nil
})
})
s
.
GenericAPIServer
.
AddPostStartHook
(
"apiservice-status-available-controller"
,
func
(
context
genericapiserver
.
PostStartHookContext
)
error
{
s
.
GenericAPIServer
.
AddPostStartHook
(
"apiservice-status-available-controller"
,
func
(
context
genericapiserver
.
PostStartHookContext
)
error
{
go
availableController
.
Run
(
context
.
StopCh
)
// if we end up blocking for long periods of time, we may need to increase threadiness.
go
availableController
.
Run
(
5
,
context
.
StopCh
)
return
nil
return
nil
})
})
...
...
staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go
View file @
b7bc9b11
...
@@ -62,7 +62,7 @@ type AvailableConditionController struct {
...
@@ -62,7 +62,7 @@ type AvailableConditionController struct {
endpointsLister
v1listers
.
EndpointsLister
endpointsLister
v1listers
.
EndpointsLister
endpointsSynced
cache
.
InformerSynced
endpointsSynced
cache
.
InformerSynced
proxyTransport
*
http
.
Transpor
t
discoveryClient
*
http
.
Clien
t
serviceResolver
ServiceResolver
serviceResolver
ServiceResolver
// To allow injection for testing.
// To allow injection for testing.
...
@@ -87,16 +87,35 @@ func NewAvailableConditionController(
...
@@ -87,16 +87,35 @@ func NewAvailableConditionController(
servicesSynced
:
serviceInformer
.
Informer
()
.
HasSynced
,
servicesSynced
:
serviceInformer
.
Informer
()
.
HasSynced
,
endpointsLister
:
endpointsInformer
.
Lister
(),
endpointsLister
:
endpointsInformer
.
Lister
(),
endpointsSynced
:
endpointsInformer
.
Informer
()
.
HasSynced
,
endpointsSynced
:
endpointsInformer
.
Informer
()
.
HasSynced
,
proxyTransport
:
proxyTransport
,
serviceResolver
:
serviceResolver
,
serviceResolver
:
serviceResolver
,
queue
:
workqueue
.
NewNamedRateLimitingQueue
(
workqueue
.
DefaultControllerRateLimiter
(),
"AvailableConditionController"
),
queue
:
workqueue
.
NewNamedRateLimitingQueue
(
workqueue
.
DefaultControllerRateLimiter
(),
"AvailableConditionController"
),
}
}
apiServiceInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
// construct an http client that will ignore TLS verification (if someone owns the network and messes with your status
AddFunc
:
c
.
addAPIService
,
// that's not so bad) and sets a very short timeout.
UpdateFunc
:
c
.
updateAPIService
,
discoveryClient
:=
&
http
.
Client
{
DeleteFunc
:
c
.
deleteAPIService
,
Transport
:
&
http
.
Transport
{
})
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
},
// the request should happen quickly.
Timeout
:
5
*
time
.
Second
,
}
if
proxyTransport
!=
nil
{
discoveryClient
.
Transport
=
proxyTransport
}
c
.
discoveryClient
=
discoveryClient
// resync on this one because it is low cardinality and rechecking the actual discovery
// allows us to detect health in a more timely fashion when network connectivity to
// nodes is snipped, but the network still attempts to route there. See
// https://github.com/openshift/origin/issues/17159#issuecomment-341798063
apiServiceInformer
.
Informer
()
.
AddEventHandlerWithResyncPeriod
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
c
.
addAPIService
,
UpdateFunc
:
c
.
updateAPIService
,
DeleteFunc
:
c
.
deleteAPIService
,
},
30
*
time
.
Second
)
serviceInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
serviceInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
c
.
addService
,
AddFunc
:
c
.
addService
,
...
@@ -195,22 +214,10 @@ func (c *AvailableConditionController) sync(key string) error {
...
@@ -195,22 +214,10 @@ func (c *AvailableConditionController) sync(key string) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
// construct an http client that will ignore TLS verification (if someone owns the network and messes with your status
// that's not so bad) and sets a very short timeout.
httpClient
:=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
},
// the request should happen quickly.
Timeout
:
5
*
time
.
Second
,
}
if
c
.
proxyTransport
!=
nil
{
httpClient
.
Transport
=
c
.
proxyTransport
}
errCh
:=
make
(
chan
error
)
errCh
:=
make
(
chan
error
)
go
func
()
{
go
func
()
{
resp
,
err
:=
http
Client
.
Get
(
discoveryURL
.
String
())
resp
,
err
:=
c
.
discovery
Client
.
Get
(
discoveryURL
.
String
())
if
resp
!=
nil
{
if
resp
!=
nil
{
resp
.
Body
.
Close
()
resp
.
Body
.
Close
()
}
}
...
@@ -248,7 +255,7 @@ func (c *AvailableConditionController) sync(key string) error {
...
@@ -248,7 +255,7 @@ func (c *AvailableConditionController) sync(key string) error {
return
err
return
err
}
}
func
(
c
*
AvailableConditionController
)
Run
(
stopCh
<-
chan
struct
{})
{
func
(
c
*
AvailableConditionController
)
Run
(
threadiness
int
,
stopCh
<-
chan
struct
{})
{
defer
utilruntime
.
HandleCrash
()
defer
utilruntime
.
HandleCrash
()
defer
c
.
queue
.
ShutDown
()
defer
c
.
queue
.
ShutDown
()
...
@@ -259,9 +266,9 @@ func (c *AvailableConditionController) Run(stopCh <-chan struct{}) {
...
@@ -259,9 +266,9 @@ func (c *AvailableConditionController) Run(stopCh <-chan struct{}) {
return
return
}
}
// only start one worker thread since its a slow moving API and the aggregation server adding bits
for
i
:=
0
;
i
<
threadiness
;
i
++
{
// aren't threadsafe
go
wait
.
Until
(
c
.
runWorker
,
time
.
Second
,
stopCh
)
go
wait
.
Until
(
c
.
runWorker
,
time
.
Second
,
stopCh
)
}
<-
stopCh
<-
stopCh
}
}
...
...
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