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
7a7fe3ab
Commit
7a7fe3ab
authored
May 16, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent namespace cleanup hotloop
parent
8d90427c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
24 deletions
+35
-24
namespace_controller.go
pkg/controller/namespace/namespace_controller.go
+35
-24
No files found.
pkg/controller/namespace/namespace_controller.go
View file @
7a7fe3ab
...
@@ -47,7 +47,7 @@ type NamespaceController struct {
...
@@ -47,7 +47,7 @@ type NamespaceController struct {
// controller that observes the namespaces
// controller that observes the namespaces
controller
*
framework
.
Controller
controller
*
framework
.
Controller
// namespaces that have been queued up for processing by workers
// namespaces that have been queued up for processing by workers
queue
*
workqueue
.
Typ
e
queue
workqueue
.
RateLimitingInterfac
e
// list of preferred group versions and their corresponding resource set for namespace deletion
// list of preferred group versions and their corresponding resource set for namespace deletion
groupVersionResources
[]
unversioned
.
GroupVersionResource
groupVersionResources
[]
unversioned
.
GroupVersionResource
// opCache is a cache to remember if a particular operation is not supported to aid dynamic client.
// opCache is a cache to remember if a particular operation is not supported to aid dynamic client.
...
@@ -67,7 +67,7 @@ func NewNamespaceController(
...
@@ -67,7 +67,7 @@ func NewNamespaceController(
namespaceController
:=
&
NamespaceController
{
namespaceController
:=
&
NamespaceController
{
kubeClient
:
kubeClient
,
kubeClient
:
kubeClient
,
clientPool
:
clientPool
,
clientPool
:
clientPool
,
queue
:
workqueue
.
New
(
),
queue
:
workqueue
.
New
RateLimitingQueue
(
workqueue
.
DefaultControllerRateLimiter
()
),
groupVersionResources
:
groupVersionResources
,
groupVersionResources
:
groupVersionResources
,
opCache
:
operationNotSupportedCache
{},
opCache
:
operationNotSupportedCache
{},
finalizerToken
:
finalizerToken
,
finalizerToken
:
finalizerToken
,
...
@@ -122,29 +122,40 @@ func (nm *NamespaceController) enqueueNamespace(obj interface{}) {
...
@@ -122,29 +122,40 @@ func (nm *NamespaceController) enqueueNamespace(obj interface{}) {
// The system ensures that no two workers can process
// The system ensures that no two workers can process
// the same namespace at the same time.
// the same namespace at the same time.
func
(
nm
*
NamespaceController
)
worker
()
{
func
(
nm
*
NamespaceController
)
worker
()
{
workFunc
:=
func
()
bool
{
key
,
quit
:=
nm
.
queue
.
Get
()
if
quit
{
return
true
}
defer
nm
.
queue
.
Done
(
key
)
err
:=
nm
.
syncNamespaceFromKey
(
key
.
(
string
))
if
err
==
nil
{
// no error, forget this entry and return
nm
.
queue
.
Forget
(
key
)
return
false
}
if
estimate
,
ok
:=
err
.
(
*
contentRemainingError
);
ok
{
t
:=
estimate
.
Estimate
/
2
+
1
glog
.
V
(
4
)
.
Infof
(
"Content remaining in namespace %s, waiting %d seconds"
,
key
,
t
)
nm
.
queue
.
AddAfter
(
key
,
time
.
Duration
(
t
)
*
time
.
Second
)
}
else
{
// rather than wait for a full resync, re-add the namespace to the queue to be processed
nm
.
queue
.
AddRateLimited
(
key
)
utilruntime
.
HandleError
(
err
)
}
return
false
}
for
{
for
{
func
()
{
quit
:=
workFunc
()
key
,
quit
:=
nm
.
queue
.
Get
()
if
quit
{
if
quit
{
return
return
}
}
defer
nm
.
queue
.
Done
(
key
)
if
err
:=
nm
.
syncNamespaceFromKey
(
key
.
(
string
));
err
!=
nil
{
if
estimate
,
ok
:=
err
.
(
*
contentRemainingError
);
ok
{
go
func
()
{
defer
utilruntime
.
HandleCrash
()
t
:=
estimate
.
Estimate
/
2
+
1
glog
.
V
(
4
)
.
Infof
(
"Content remaining in namespace %s, waiting %d seconds"
,
key
,
t
)
time
.
Sleep
(
time
.
Duration
(
t
)
*
time
.
Second
)
nm
.
queue
.
Add
(
key
)
}()
}
else
{
// rather than wait for a full resync, re-add the namespace to the queue to be processed
nm
.
queue
.
Add
(
key
)
utilruntime
.
HandleError
(
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