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
45e3a1f5
Commit
45e3a1f5
authored
Jan 27, 2016
by
Random-Liu
Committed by
Lantao Liu
Feb 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old reason cache
parent
2b7d0182
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
73 deletions
+1
-73
manager.go
pkg/kubelet/dockertools/manager.go
+1
-73
No files found.
pkg/kubelet/dockertools/manager.go
View file @
45e3a1f5
...
...
@@ -33,7 +33,6 @@ import (
"github.com/coreos/go-semver/semver"
docker
"github.com/fsouza/go-dockerclient"
"github.com/golang/glog"
"github.com/golang/groupcache/lru"
cadvisorapi
"github.com/google/cadvisor/info/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
...
...
@@ -62,8 +61,6 @@ const (
MinimumDockerAPIVersion
=
"1.18"
maxReasonCacheEntries
=
200
// ndots specifies the minimum number of dots that a domain name must contain for the resolver to consider it as FQDN (fully-qualified)
// we want to able to consider SRV lookup names like _dns._udp.kube-dns.default.svc to be considered relative.
// hence, setting ndots to be 5.
...
...
@@ -98,15 +95,7 @@ type DockerManager struct {
// The image name of the pod infra container.
podInfraContainerImage
string
// reasonCache stores the failure reason of the last container creation
// and/or start in a string, keyed by <pod_UID>_<container_name>. The goal
// is to propagate this reason to the container status. This endeavor is
// "best-effort" for two reasons:
// 1. The cache is not persisted.
// 2. We use an LRU cache to avoid extra garbage collection work. This
// means that some entries may be recycled before a pod has been
// deleted.
reasonCache
reasonInfoCache
// TODO(yifan): Record the pull failure so we can eliminate the image checking?
// Lower level docker image puller.
dockerPuller
DockerPuller
...
...
@@ -185,8 +174,6 @@ func NewDockerManager(
glog
.
Infof
(
"Setting dockerRoot to %s"
,
dockerRoot
)
}
reasonCache
:=
reasonInfoCache
{
cache
:
lru
.
New
(
maxReasonCacheEntries
)}
dm
:=
&
DockerManager
{
client
:
client
,
recorder
:
recorder
,
...
...
@@ -194,7 +181,6 @@ func NewDockerManager(
os
:
osInterface
,
machineInfo
:
machineInfo
,
podInfraContainerImage
:
podInfraContainerImage
,
reasonCache
:
reasonCache
,
dockerPuller
:
newDockerPuller
(
client
,
qps
,
burst
),
dockerRoot
:
dockerRoot
,
containerLogsDir
:
containerLogsDir
,
...
...
@@ -218,43 +204,6 @@ func NewDockerManager(
return
dm
}
// A cache which stores strings keyed by <pod_UID>_<container_name>.
type
reasonInfoCache
struct
{
lock
sync
.
RWMutex
cache
*
lru
.
Cache
}
type
reasonInfo
struct
{
reason
string
message
string
}
func
(
sc
*
reasonInfoCache
)
composeKey
(
uid
types
.
UID
,
name
string
)
string
{
return
fmt
.
Sprintf
(
"%s_%s"
,
uid
,
name
)
}
func
(
sc
*
reasonInfoCache
)
Add
(
uid
types
.
UID
,
name
string
,
reason
,
message
string
)
{
sc
.
lock
.
Lock
()
defer
sc
.
lock
.
Unlock
()
sc
.
cache
.
Add
(
sc
.
composeKey
(
uid
,
name
),
reasonInfo
{
reason
,
message
})
}
func
(
sc
*
reasonInfoCache
)
Remove
(
uid
types
.
UID
,
name
string
)
{
sc
.
lock
.
Lock
()
defer
sc
.
lock
.
Unlock
()
sc
.
cache
.
Remove
(
sc
.
composeKey
(
uid
,
name
))
}
func
(
sc
*
reasonInfoCache
)
Get
(
uid
types
.
UID
,
name
string
)
(
reasonInfo
,
bool
)
{
sc
.
lock
.
RLock
()
defer
sc
.
lock
.
RUnlock
()
value
,
ok
:=
sc
.
cache
.
Get
(
sc
.
composeKey
(
uid
,
name
))
if
ok
{
return
value
.
(
reasonInfo
),
ok
}
else
{
return
reasonInfo
{
""
,
""
},
ok
}
}
// GetContainerLogs returns logs of a specific container. By
// default, it returns a snapshot of the container log. Set 'follow' to true to
// stream the log. Set 'follow' to false and specify the number of lines (e.g.
...
...
@@ -1682,20 +1631,6 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, podStatus *kub
},
nil
}
// updateReasonCache updates the failure reason based on the registered error.
func
(
dm
*
DockerManager
)
updateReasonCache
(
pod
*
api
.
Pod
,
container
*
api
.
Container
,
briefError
string
,
err
error
)
{
if
briefError
==
""
||
err
==
nil
{
return
}
errString
:=
err
.
Error
()
dm
.
reasonCache
.
Add
(
pod
.
UID
,
container
.
Name
,
briefError
,
errString
)
}
// clearReasonCache removes the entry in the reason cache.
func
(
dm
*
DockerManager
)
clearReasonCache
(
pod
*
api
.
Pod
,
container
*
api
.
Container
)
{
dm
.
reasonCache
.
Remove
(
pod
.
UID
,
container
.
Name
)
}
// Sync the running pod to match the specified desired pod.
func
(
dm
*
DockerManager
)
SyncPod
(
pod
*
api
.
Pod
,
_
api
.
PodStatus
,
podStatus
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
(
result
kubecontainer
.
PodSyncResult
)
{
start
:=
time
.
Now
()
...
...
@@ -1836,13 +1771,11 @@ func (dm *DockerManager) SyncPod(pod *api.Pod, _ api.PodStatus, podStatus *kubec
err
,
msg
:=
dm
.
imagePuller
.
PullImage
(
pod
,
container
,
pullSecrets
)
if
err
!=
nil
{
startContainerResult
.
Fail
(
err
,
msg
)
dm
.
updateReasonCache
(
pod
,
container
,
err
.
Error
(),
errors
.
New
(
msg
))
continue
}
if
container
.
SecurityContext
!=
nil
&&
container
.
SecurityContext
.
RunAsNonRoot
!=
nil
&&
*
container
.
SecurityContext
.
RunAsNonRoot
{
err
:=
dm
.
verifyNonRoot
(
container
)
dm
.
updateReasonCache
(
pod
,
container
,
kubecontainer
.
ErrVerifyNonRoot
.
Error
(),
err
)
if
err
!=
nil
{
startContainerResult
.
Fail
(
kubecontainer
.
ErrVerifyNonRoot
,
err
.
Error
())
glog
.
Errorf
(
"Error running pod %q container %q: %v"
,
format
.
Pod
(
pod
),
container
.
Name
,
err
)
...
...
@@ -1863,7 +1796,6 @@ func (dm *DockerManager) SyncPod(pod *api.Pod, _ api.PodStatus, podStatus *kubec
// See createPodInfraContainer for infra container setup.
namespaceMode
:=
fmt
.
Sprintf
(
"container:%v"
,
podInfraContainerID
)
_
,
err
=
dm
.
runContainerInPod
(
pod
,
container
,
namespaceMode
,
namespaceMode
,
getPidMode
(
pod
),
restartCount
)
dm
.
updateReasonCache
(
pod
,
container
,
kubecontainer
.
ErrRunContainer
.
Error
(),
err
)
if
err
!=
nil
{
startContainerResult
.
Fail
(
kubecontainer
.
ErrRunContainer
,
err
.
Error
())
// TODO(bburns) : Perhaps blacklist a container after N failures?
...
...
@@ -1871,8 +1803,6 @@ func (dm *DockerManager) SyncPod(pod *api.Pod, _ api.PodStatus, podStatus *kubec
continue
}
// Successfully started the container; clear the entry in the failure
// reason cache.
dm
.
clearReasonCache
(
pod
,
container
)
}
return
}
...
...
@@ -1955,14 +1885,12 @@ func (dm *DockerManager) doBackOff(pod *api.Pod, container *api.Container, podSt
dm
.
recorder
.
Eventf
(
ref
,
api
.
EventTypeWarning
,
kubecontainer
.
BackOffStartContainer
,
"Back-off restarting failed docker container"
)
}
err
:=
fmt
.
Errorf
(
"Back-off %s restarting failed container=%s pod=%s"
,
backOff
.
Get
(
stableName
),
container
.
Name
,
format
.
Pod
(
pod
))
dm
.
updateReasonCache
(
pod
,
container
,
kubecontainer
.
ErrCrashLoopBackOff
.
Error
(),
err
)
glog
.
Infof
(
"%s"
,
err
.
Error
())
return
true
,
kubecontainer
.
ErrCrashLoopBackOff
,
err
.
Error
()
}
backOff
.
Next
(
stableName
,
ts
)
}
dm
.
clearReasonCache
(
pod
,
container
)
return
false
,
nil
,
""
}
...
...
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