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
c7598e88
Unverified
Commit
c7598e88
authored
Dec 03, 2018
by
Kubernetes Prow Robot
Committed by
GitHub
Dec 03, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71617 from RobertKrawitz/branch-issue71614
Issue 71614: Protect log message maps
parents
8c0542dc
bc091be6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
kuberuntime_manager.go
pkg/kubelet/kuberuntime/kuberuntime_manager.go
+6
-0
remote_runtime.go
pkg/kubelet/remote/remote_runtime.go
+12
-0
No files found.
pkg/kubelet/kuberuntime/kuberuntime_manager.go
View file @
c7598e88
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"os"
"os"
"sync"
"time"
"time"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi
"github.com/google/cadvisor/info/v1"
...
@@ -131,6 +132,7 @@ type kubeGenericRuntimeManager struct {
...
@@ -131,6 +132,7 @@ type kubeGenericRuntimeManager struct {
// Time last per-container error message was printed
// Time last per-container error message was printed
errorPrinted
map
[
string
]
time
.
Time
errorPrinted
map
[
string
]
time
.
Time
errorMapLock
sync
.
Mutex
}
}
// KubeGenericRuntime is a interface contains interfaces for container runtime and command.
// KubeGenericRuntime is a interface contains interfaces for container runtime and command.
...
@@ -830,6 +832,8 @@ func (m *kubeGenericRuntimeManager) killPodWithSyncResult(pod *v1.Pod, runningPo
...
@@ -830,6 +832,8 @@ func (m *kubeGenericRuntimeManager) killPodWithSyncResult(pod *v1.Pod, runningPo
}
}
func
(
m
*
kubeGenericRuntimeManager
)
cleanupErrorTimeouts
()
{
func
(
m
*
kubeGenericRuntimeManager
)
cleanupErrorTimeouts
()
{
m
.
errorMapLock
.
Lock
()
defer
m
.
errorMapLock
.
Unlock
()
for
name
,
timeout
:=
range
m
.
errorPrinted
{
for
name
,
timeout
:=
range
m
.
errorPrinted
{
if
time
.
Now
()
.
Sub
(
timeout
)
>=
identicalErrorDelay
{
if
time
.
Now
()
.
Sub
(
timeout
)
>=
identicalErrorDelay
{
delete
(
m
.
errorPrinted
,
name
)
delete
(
m
.
errorPrinted
,
name
)
...
@@ -886,6 +890,8 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
...
@@ -886,6 +890,8 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
// Get statuses of all containers visible in the pod.
// Get statuses of all containers visible in the pod.
containerStatuses
,
err
:=
m
.
getPodContainerStatuses
(
uid
,
name
,
namespace
)
containerStatuses
,
err
:=
m
.
getPodContainerStatuses
(
uid
,
name
,
namespace
)
m
.
errorMapLock
.
Lock
()
defer
m
.
errorMapLock
.
Unlock
()
if
err
!=
nil
{
if
err
!=
nil
{
lastMsg
,
ok
:=
m
.
lastError
[
podFullName
]
lastMsg
,
ok
:=
m
.
lastError
[
podFullName
]
if
!
ok
||
err
.
Error
()
!=
lastMsg
||
time
.
Now
()
.
Sub
(
m
.
errorPrinted
[
podFullName
])
>=
identicalErrorDelay
{
if
!
ok
||
err
.
Error
()
!=
lastMsg
||
time
.
Now
()
.
Sub
(
m
.
errorPrinted
[
podFullName
])
>=
identicalErrorDelay
{
...
...
pkg/kubelet/remote/remote_runtime.go
View file @
c7598e88
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"strings"
"strings"
"sync"
"time"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc"
...
@@ -40,6 +41,7 @@ type RemoteRuntimeService struct {
...
@@ -40,6 +41,7 @@ type RemoteRuntimeService struct {
lastError
map
[
string
]
string
lastError
map
[
string
]
string
// Time last per-container error message was printed
// Time last per-container error message was printed
errorPrinted
map
[
string
]
time
.
Time
errorPrinted
map
[
string
]
time
.
Time
errorMapLock
sync
.
Mutex
}
}
const
(
const
(
...
@@ -236,8 +238,10 @@ func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64)
...
@@ -236,8 +238,10 @@ func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64)
ctx
,
cancel
:=
getContextWithTimeout
(
t
)
ctx
,
cancel
:=
getContextWithTimeout
(
t
)
defer
cancel
()
defer
cancel
()
r
.
errorMapLock
.
Lock
()
delete
(
r
.
lastError
,
containerID
)
delete
(
r
.
lastError
,
containerID
)
delete
(
r
.
errorPrinted
,
containerID
)
delete
(
r
.
errorPrinted
,
containerID
)
r
.
errorMapLock
.
Unlock
()
_
,
err
:=
r
.
runtimeClient
.
StopContainer
(
ctx
,
&
runtimeapi
.
StopContainerRequest
{
_
,
err
:=
r
.
runtimeClient
.
StopContainer
(
ctx
,
&
runtimeapi
.
StopContainerRequest
{
ContainerId
:
containerID
,
ContainerId
:
containerID
,
Timeout
:
timeout
,
Timeout
:
timeout
,
...
@@ -256,8 +260,10 @@ func (r *RemoteRuntimeService) RemoveContainer(containerID string) error {
...
@@ -256,8 +260,10 @@ func (r *RemoteRuntimeService) RemoveContainer(containerID string) error {
ctx
,
cancel
:=
getContextWithTimeout
(
r
.
timeout
)
ctx
,
cancel
:=
getContextWithTimeout
(
r
.
timeout
)
defer
cancel
()
defer
cancel
()
r
.
errorMapLock
.
Lock
()
delete
(
r
.
lastError
,
containerID
)
delete
(
r
.
lastError
,
containerID
)
delete
(
r
.
errorPrinted
,
containerID
)
delete
(
r
.
errorPrinted
,
containerID
)
r
.
errorMapLock
.
Unlock
()
_
,
err
:=
r
.
runtimeClient
.
RemoveContainer
(
ctx
,
&
runtimeapi
.
RemoveContainerRequest
{
_
,
err
:=
r
.
runtimeClient
.
RemoveContainer
(
ctx
,
&
runtimeapi
.
RemoveContainerRequest
{
ContainerId
:
containerID
,
ContainerId
:
containerID
,
})
})
...
@@ -287,6 +293,8 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter
...
@@ -287,6 +293,8 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter
// Clean up any expired last-error timers
// Clean up any expired last-error timers
func
(
r
*
RemoteRuntimeService
)
cleanupErrorTimeouts
()
{
func
(
r
*
RemoteRuntimeService
)
cleanupErrorTimeouts
()
{
r
.
errorMapLock
.
Lock
()
defer
r
.
errorMapLock
.
Unlock
()
for
ID
,
timeout
:=
range
r
.
errorPrinted
{
for
ID
,
timeout
:=
range
r
.
errorPrinted
{
if
time
.
Now
()
.
Sub
(
timeout
)
>=
identicalErrorDelay
{
if
time
.
Now
()
.
Sub
(
timeout
)
>=
identicalErrorDelay
{
delete
(
r
.
lastError
,
ID
)
delete
(
r
.
lastError
,
ID
)
...
@@ -304,6 +312,8 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi.
...
@@ -304,6 +312,8 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi.
ContainerId
:
containerID
,
ContainerId
:
containerID
,
})
})
r
.
cleanupErrorTimeouts
()
r
.
cleanupErrorTimeouts
()
r
.
errorMapLock
.
Lock
()
defer
r
.
errorMapLock
.
Unlock
()
if
err
!=
nil
{
if
err
!=
nil
{
// Don't spam the log with endless messages about the same failure.
// Don't spam the log with endless messages about the same failure.
lastMsg
,
ok
:=
r
.
lastError
[
containerID
]
lastMsg
,
ok
:=
r
.
lastError
[
containerID
]
...
@@ -491,6 +501,8 @@ func (r *RemoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.C
...
@@ -491,6 +501,8 @@ func (r *RemoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.C
ContainerId
:
containerID
,
ContainerId
:
containerID
,
})
})
r
.
cleanupErrorTimeouts
()
r
.
cleanupErrorTimeouts
()
r
.
errorMapLock
.
Lock
()
defer
r
.
errorMapLock
.
Unlock
()
if
err
!=
nil
{
if
err
!=
nil
{
lastMsg
,
ok
:=
r
.
lastError
[
containerID
]
lastMsg
,
ok
:=
r
.
lastError
[
containerID
]
if
!
ok
||
err
.
Error
()
!=
lastMsg
||
time
.
Now
()
.
Sub
(
r
.
errorPrinted
[
containerID
])
>=
identicalErrorDelay
{
if
!
ok
||
err
.
Error
()
!=
lastMsg
||
time
.
Now
()
.
Sub
(
r
.
errorPrinted
[
containerID
])
>=
identicalErrorDelay
{
...
...
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