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
c23a8a85
Unverified
Commit
c23a8a85
authored
Mar 29, 2018
by
Mikhail Mazurskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use range in loops; misc fixes
parent
4685df26
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
30 additions
and
57 deletions
+30
-57
resize.go
pkg/kubelet/container/resize.go
+1
-5
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+20
-27
pod_container_deletor.go
pkg/kubelet/pod_container_deletor.go
+2
-4
recycler_client.go
pkg/volume/util/recyclerclient/recycler_client.go
+1
-1
filter.go
staging/src/k8s.io/apimachinery/pkg/watch/filter.go
+1
-5
mux.go
staging/src/k8s.io/apimachinery/pkg/watch/mux.go
+1
-5
store.go
...c/k8s.io/apiserver/pkg/registry/generic/registry/store.go
+2
-5
event.go
staging/src/k8s.io/client-go/tools/record/event.go
+1
-5
watch.go
test/e2e/apimachinery/watch.go
+1
-0
No files found.
pkg/kubelet/container/resize.go
View file @
c23a8a85
...
@@ -32,11 +32,7 @@ func HandleResizing(resize <-chan remotecommand.TerminalSize, resizeFunc func(si
...
@@ -32,11 +32,7 @@ func HandleResizing(resize <-chan remotecommand.TerminalSize, resizeFunc func(si
go
func
()
{
go
func
()
{
defer
runtime
.
HandleCrash
()
defer
runtime
.
HandleCrash
()
for
{
for
size
:=
range
resize
{
size
,
ok
:=
<-
resize
if
!
ok
{
return
}
if
size
.
Height
<
1
||
size
.
Width
<
1
{
if
size
.
Height
<
1
||
size
.
Width
<
1
{
continue
continue
}
}
...
...
pkg/kubelet/kubelet_pods.go
View file @
c23a8a85
...
@@ -1099,35 +1099,28 @@ func (kl *Kubelet) podKiller() {
...
@@ -1099,35 +1099,28 @@ func (kl *Kubelet) podKiller() {
killing
:=
sets
.
NewString
()
killing
:=
sets
.
NewString
()
// guard for the killing set
// guard for the killing set
lock
:=
sync
.
Mutex
{}
lock
:=
sync
.
Mutex
{}
for
{
for
podPair
:=
range
kl
.
podKillingCh
{
select
{
runningPod
:=
podPair
.
RunningPod
case
podPair
,
ok
:=
<-
kl
.
podKillingCh
:
apiPod
:=
podPair
.
APIPod
if
!
ok
{
return
}
runningPod
:=
podPair
.
RunningPod
apiPod
:=
podPair
.
APIPod
lock
.
Lock
()
lock
.
Lock
()
exists
:=
killing
.
Has
(
string
(
runningPod
.
ID
))
exists
:=
killing
.
Has
(
string
(
runningPod
.
ID
))
if
!
exists
{
if
!
exists
{
killing
.
Insert
(
string
(
runningPod
.
ID
))
killing
.
Insert
(
string
(
runningPod
.
ID
))
}
}
lock
.
Unlock
()
lock
.
Unlock
()
if
!
exists
{
if
!
exists
{
go
func
(
apiPod
*
v1
.
Pod
,
runningPod
*
kubecontainer
.
Pod
)
{
go
func
(
apiPod
*
v1
.
Pod
,
runningPod
*
kubecontainer
.
Pod
)
{
glog
.
V
(
2
)
.
Infof
(
"Killing unwanted pod %q"
,
runningPod
.
Name
)
glog
.
V
(
2
)
.
Infof
(
"Killing unwanted pod %q"
,
runningPod
.
Name
)
err
:=
kl
.
killPod
(
apiPod
,
runningPod
,
nil
,
nil
)
err
:=
kl
.
killPod
(
apiPod
,
runningPod
,
nil
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed killing the pod %q: %v"
,
runningPod
.
Name
,
err
)
glog
.
Errorf
(
"Failed killing the pod %q: %v"
,
runningPod
.
Name
,
err
)
}
}
lock
.
Lock
()
lock
.
Lock
()
killing
.
Delete
(
string
(
runningPod
.
ID
))
killing
.
Delete
(
string
(
runningPod
.
ID
))
lock
.
Unlock
()
lock
.
Unlock
()
}(
apiPod
,
runningPod
)
}(
apiPod
,
runningPod
)
}
}
}
}
}
}
}
...
...
pkg/kubelet/pod_container_deletor.go
View file @
c23a8a85
...
@@ -45,10 +45,8 @@ func newPodContainerDeletor(runtime kubecontainer.Runtime, containersToKeep int)
...
@@ -45,10 +45,8 @@ func newPodContainerDeletor(runtime kubecontainer.Runtime, containersToKeep int)
buffer
:=
make
(
chan
kubecontainer
.
ContainerID
,
containerDeletorBufferLimit
)
buffer
:=
make
(
chan
kubecontainer
.
ContainerID
,
containerDeletorBufferLimit
)
go
wait
.
Until
(
func
()
{
go
wait
.
Until
(
func
()
{
for
{
for
{
select
{
id
:=
<-
buffer
case
id
:=
<-
buffer
:
runtime
.
DeleteContainer
(
id
)
runtime
.
DeleteContainer
(
id
)
}
}
}
},
0
,
wait
.
NeverStop
)
},
0
,
wait
.
NeverStop
)
...
...
pkg/volume/util/recyclerclient/recycler_client.go
View file @
c23a8a85
...
@@ -226,7 +226,7 @@ func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan s
...
@@ -226,7 +226,7 @@ func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan s
var
eventWatchChannelClosed
bool
var
eventWatchChannelClosed
bool
for
{
for
{
select
{
select
{
case
_
=
<-
stopChannel
:
case
<-
stopChannel
:
return
return
case
podEvent
,
ok
:=
<-
podWatch
.
ResultChan
()
:
case
podEvent
,
ok
:=
<-
podWatch
.
ResultChan
()
:
...
...
staging/src/k8s.io/apimachinery/pkg/watch/filter.go
View file @
c23a8a85
...
@@ -62,11 +62,7 @@ func (fw *filteredWatch) Stop() {
...
@@ -62,11 +62,7 @@ func (fw *filteredWatch) Stop() {
// loop waits for new values, filters them, and resends them.
// loop waits for new values, filters them, and resends them.
func
(
fw
*
filteredWatch
)
loop
()
{
func
(
fw
*
filteredWatch
)
loop
()
{
defer
close
(
fw
.
result
)
defer
close
(
fw
.
result
)
for
{
for
event
:=
range
fw
.
incoming
.
ResultChan
()
{
event
,
ok
:=
<-
fw
.
incoming
.
ResultChan
()
if
!
ok
{
break
}
filtered
,
keep
:=
fw
.
f
(
event
)
filtered
,
keep
:=
fw
.
f
(
event
)
if
keep
{
if
keep
{
fw
.
result
<-
filtered
fw
.
result
<-
filtered
...
...
staging/src/k8s.io/apimachinery/pkg/watch/mux.go
View file @
c23a8a85
...
@@ -204,11 +204,7 @@ func (m *Broadcaster) Shutdown() {
...
@@ -204,11 +204,7 @@ func (m *Broadcaster) Shutdown() {
func
(
m
*
Broadcaster
)
loop
()
{
func
(
m
*
Broadcaster
)
loop
()
{
// Deliberately not catching crashes here. Yes, bring down the process if there's a
// Deliberately not catching crashes here. Yes, bring down the process if there's a
// bug in watch.Broadcaster.
// bug in watch.Broadcaster.
for
{
for
event
:=
range
m
.
incoming
{
event
,
ok
:=
<-
m
.
incoming
if
!
ok
{
break
}
if
event
.
Type
==
internalRunFunctionMarker
{
if
event
.
Type
==
internalRunFunctionMarker
{
event
.
Object
.
(
functionFakeRuntimeObject
)()
event
.
Object
.
(
functionFakeRuntimeObject
)()
continue
continue
...
...
staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go
View file @
c23a8a85
...
@@ -445,6 +445,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob
...
@@ -445,6 +445,7 @@ func (e *Store) WaitForInitialized(ctx genericapirequest.Context, obj runtime.Ob
}
}
}
}
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
}
}
}
}
...
@@ -1070,11 +1071,7 @@ func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.
...
@@ -1070,11 +1071,7 @@ func (e *Store) DeleteCollection(ctx genericapirequest.Context, options *metav1.
})
})
defer
wg
.
Done
()
defer
wg
.
Done
()
for
{
for
index
:=
range
toProcess
{
index
,
ok
:=
<-
toProcess
if
!
ok
{
return
}
accessor
,
err
:=
meta
.
Accessor
(
items
[
index
])
accessor
,
err
:=
meta
.
Accessor
(
items
[
index
])
if
err
!=
nil
{
if
err
!=
nil
{
errs
<-
err
errs
<-
err
...
...
staging/src/k8s.io/client-go/tools/record/event.go
View file @
c23a8a85
...
@@ -225,11 +225,7 @@ func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler fun
...
@@ -225,11 +225,7 @@ func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler fun
watcher
:=
eventBroadcaster
.
Watch
()
watcher
:=
eventBroadcaster
.
Watch
()
go
func
()
{
go
func
()
{
defer
utilruntime
.
HandleCrash
()
defer
utilruntime
.
HandleCrash
()
for
{
for
watchEvent
:=
range
watcher
.
ResultChan
()
{
watchEvent
,
open
:=
<-
watcher
.
ResultChan
()
if
!
open
{
return
}
event
,
ok
:=
watchEvent
.
Object
.
(
*
v1
.
Event
)
event
,
ok
:=
watchEvent
.
Object
.
(
*
v1
.
Event
)
if
!
ok
{
if
!
ok
{
// This is all local, so there's no reason this should
// This is all local, so there's no reason this should
...
...
test/e2e/apimachinery/watch.go
View file @
c23a8a85
...
@@ -192,6 +192,7 @@ func expectNoEvent(w watch.Interface, eventType watch.EventType, object runtime.
...
@@ -192,6 +192,7 @@ func expectNoEvent(w watch.Interface, eventType watch.EventType, object runtime.
func
waitForEvent
(
w
watch
.
Interface
,
expectType
watch
.
EventType
,
expectObject
runtime
.
Object
)
(
watch
.
Event
,
bool
)
{
func
waitForEvent
(
w
watch
.
Interface
,
expectType
watch
.
EventType
,
expectObject
runtime
.
Object
)
(
watch
.
Event
,
bool
)
{
stopTimer
:=
time
.
NewTimer
(
1
*
time
.
Minute
)
stopTimer
:=
time
.
NewTimer
(
1
*
time
.
Minute
)
defer
stopTimer
.
Stop
()
for
{
for
{
select
{
select
{
case
actual
:=
<-
w
.
ResultChan
()
:
case
actual
:=
<-
w
.
ResultChan
()
:
...
...
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