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
9f3d28c7
Commit
9f3d28c7
authored
Dec 11, 2015
by
Jeff Lowdermilk
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18305 from yujuhong/podfullname
Replace podFullName with format.Pod() in logging messages
parents
f6686ba3
c6462555
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
73 deletions
+52
-73
helpers.go
pkg/kubelet/container/helpers.go
+5
-8
manager.go
pkg/kubelet/dockertools/manager.go
+23
-28
kubelet.go
pkg/kubelet/kubelet.go
+15
-18
rkt.go
pkg/kubelet/rkt/rkt.go
+2
-4
runonce.go
pkg/kubelet/runonce.go
+3
-3
pod.go
pkg/kubelet/util/format/pod.go
+4
-12
No files found.
pkg/kubelet/container/helpers.go
View file @
9f3d28c7
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/third_party/golang/expansion"
"k8s.io/kubernetes/third_party/golang/expansion"
...
@@ -44,8 +45,6 @@ type RunContainerOptionsGenerator interface {
...
@@ -44,8 +45,6 @@ type RunContainerOptionsGenerator interface {
// ShouldContainerBeRestarted checks whether a container needs to be restarted.
// ShouldContainerBeRestarted checks whether a container needs to be restarted.
// TODO(yifan): Think about how to refactor this.
// TODO(yifan): Think about how to refactor this.
func
ShouldContainerBeRestarted
(
container
*
api
.
Container
,
pod
*
api
.
Pod
,
podStatus
*
PodStatus
)
bool
{
func
ShouldContainerBeRestarted
(
container
*
api
.
Container
,
pod
*
api
.
Pod
,
podStatus
*
PodStatus
)
bool
{
podFullName
:=
GetPodFullName
(
pod
)
// Get all dead container status.
// Get all dead container status.
var
resultStatus
[]
*
ContainerStatus
var
resultStatus
[]
*
ContainerStatus
for
_
,
containerStatus
:=
range
podStatus
.
ContainerStatuses
{
for
_
,
containerStatus
:=
range
podStatus
.
ContainerStatuses
{
...
@@ -57,14 +56,14 @@ func ShouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu
...
@@ -57,14 +56,14 @@ func ShouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu
// Check RestartPolicy for dead container.
// Check RestartPolicy for dead container.
if
len
(
resultStatus
)
>
0
{
if
len
(
resultStatus
)
>
0
{
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyNever
{
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyNever
{
glog
.
V
(
4
)
.
Infof
(
"Already ran container %q of pod %q, do nothing"
,
container
.
Name
,
podFullName
)
glog
.
V
(
4
)
.
Infof
(
"Already ran container %q of pod %q, do nothing"
,
container
.
Name
,
format
.
Pod
(
pod
)
)
return
false
return
false
}
}
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyOnFailure
{
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyOnFailure
{
// Check the exit code of last run. Note: This assumes the result is sorted
// Check the exit code of last run. Note: This assumes the result is sorted
// by the created time in reverse order.
// by the created time in reverse order.
if
resultStatus
[
0
]
.
ExitCode
==
0
{
if
resultStatus
[
0
]
.
ExitCode
==
0
{
glog
.
V
(
4
)
.
Infof
(
"Already successfully ran container %q of pod %q, do nothing"
,
container
.
Name
,
podFullName
)
glog
.
V
(
4
)
.
Infof
(
"Already successfully ran container %q of pod %q, do nothing"
,
container
.
Name
,
format
.
Pod
(
pod
)
)
return
false
return
false
}
}
}
}
...
@@ -74,8 +73,6 @@ func ShouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu
...
@@ -74,8 +73,6 @@ func ShouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu
// TODO (random-liu) This should be removed soon after rkt implements GetPodStatus.
// TODO (random-liu) This should be removed soon after rkt implements GetPodStatus.
func
ShouldContainerBeRestartedOldVersion
(
container
*
api
.
Container
,
pod
*
api
.
Pod
,
podStatus
*
api
.
PodStatus
)
bool
{
func
ShouldContainerBeRestartedOldVersion
(
container
*
api
.
Container
,
pod
*
api
.
Pod
,
podStatus
*
api
.
PodStatus
)
bool
{
podFullName
:=
GetPodFullName
(
pod
)
// Get all dead container status.
// Get all dead container status.
var
resultStatus
[]
*
api
.
ContainerStatus
var
resultStatus
[]
*
api
.
ContainerStatus
for
i
,
containerStatus
:=
range
podStatus
.
ContainerStatuses
{
for
i
,
containerStatus
:=
range
podStatus
.
ContainerStatuses
{
...
@@ -87,14 +84,14 @@ func ShouldContainerBeRestartedOldVersion(container *api.Container, pod *api.Pod
...
@@ -87,14 +84,14 @@ func ShouldContainerBeRestartedOldVersion(container *api.Container, pod *api.Pod
// Check RestartPolicy for dead container.
// Check RestartPolicy for dead container.
if
len
(
resultStatus
)
>
0
{
if
len
(
resultStatus
)
>
0
{
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyNever
{
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyNever
{
glog
.
V
(
4
)
.
Infof
(
"Already ran container %q of pod %q, do nothing"
,
container
.
Name
,
podFullName
)
glog
.
V
(
4
)
.
Infof
(
"Already ran container %q of pod %q, do nothing"
,
container
.
Name
,
format
.
Pod
(
pod
)
)
return
false
return
false
}
}
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyOnFailure
{
if
pod
.
Spec
.
RestartPolicy
==
api
.
RestartPolicyOnFailure
{
// Check the exit code of last run. Note: This assumes the result is sorted
// Check the exit code of last run. Note: This assumes the result is sorted
// by the created time in reverse order.
// by the created time in reverse order.
if
resultStatus
[
0
]
.
State
.
Terminated
.
ExitCode
==
0
{
if
resultStatus
[
0
]
.
State
.
Terminated
.
ExitCode
==
0
{
glog
.
V
(
4
)
.
Infof
(
"Already successfully ran container %q of pod %q, do nothing"
,
container
.
Name
,
podFullName
)
glog
.
V
(
4
)
.
Infof
(
"Already successfully ran container %q of pod %q, do nothing"
,
container
.
Name
,
format
.
Pod
(
pod
)
)
return
false
return
false
}
}
}
}
...
...
pkg/kubelet/dockertools/manager.go
View file @
9f3d28c7
This diff is collapsed.
Click to expand it.
pkg/kubelet/kubelet.go
View file @
9f3d28c7
...
@@ -1595,8 +1595,6 @@ func (kl *Kubelet) makePodDataDirs(pod *api.Pod) error {
...
@@ -1595,8 +1595,6 @@ func (kl *Kubelet) makePodDataDirs(pod *api.Pod) error {
}
}
func
(
kl
*
Kubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kubetypes
.
SyncPodType
)
(
syncErr
error
)
{
func
(
kl
*
Kubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
updateType
kubetypes
.
SyncPodType
)
(
syncErr
error
)
{
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
uid
:=
pod
.
UID
start
:=
time
.
Now
()
start
:=
time
.
Now
()
var
firstSeenTime
time
.
Time
var
firstSeenTime
time
.
Time
if
firstSeenTimeStr
,
ok
:=
pod
.
Annotations
[
kubetypes
.
ConfigFirstSeenAnnotationKey
];
!
ok
{
if
firstSeenTimeStr
,
ok
:=
pod
.
Annotations
[
kubetypes
.
ConfigFirstSeenAnnotationKey
];
!
ok
{
...
@@ -1609,7 +1607,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1609,7 +1607,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
defer
func
()
{
defer
func
()
{
status
,
err
:=
kl
.
generatePodStatus
(
pod
)
status
,
err
:=
kl
.
generatePodStatus
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Unable to generate status for pod
with name %q and uid %q info with error(%v)"
,
podFullName
,
uid
,
err
)
glog
.
Errorf
(
"Unable to generate status for pod
%q with error(%v)"
,
format
.
Pod
(
pod
)
,
err
)
// Propagate the error upstream.
// Propagate the error upstream.
syncErr
=
err
syncErr
=
err
}
else
{
}
else
{
...
@@ -1632,18 +1630,19 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1632,18 +1630,19 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
// Create Mirror Pod for Static Pod if it doesn't already exist
// Create Mirror Pod for Static Pod if it doesn't already exist
if
kubepod
.
IsStaticPod
(
pod
)
{
if
kubepod
.
IsStaticPod
(
pod
)
{
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
if
mirrorPod
!=
nil
&&
!
kl
.
podManager
.
IsMirrorPodOf
(
mirrorPod
,
pod
)
{
if
mirrorPod
!=
nil
&&
!
kl
.
podManager
.
IsMirrorPodOf
(
mirrorPod
,
pod
)
{
// The mirror pod is semantically different from the static pod. Remove
// The mirror pod is semantically different from the static pod. Remove
// it. The mirror pod will get recreated later.
// it. The mirror pod will get recreated later.
glog
.
Errorf
(
"Deleting mirror pod %q because it is outdated"
,
podFullName
)
glog
.
Errorf
(
"Deleting mirror pod %q because it is outdated"
,
format
.
Pod
(
mirrorPod
)
)
if
err
:=
kl
.
podManager
.
DeleteMirrorPod
(
podFullName
);
err
!=
nil
{
if
err
:=
kl
.
podManager
.
DeleteMirrorPod
(
podFullName
);
err
!=
nil
{
glog
.
Errorf
(
"Failed deleting mirror pod %q: %v"
,
podFullName
,
err
)
glog
.
Errorf
(
"Failed deleting mirror pod %q: %v"
,
format
.
Pod
(
mirrorPod
)
,
err
)
}
}
}
}
if
mirrorPod
==
nil
{
if
mirrorPod
==
nil
{
glog
.
V
(
3
)
.
Infof
(
"Creating a mirror pod for static pod %q"
,
podFullName
)
glog
.
V
(
3
)
.
Infof
(
"Creating a mirror pod for static pod %q"
,
format
.
Pod
(
pod
)
)
if
err
:=
kl
.
podManager
.
CreateMirrorPod
(
pod
);
err
!=
nil
{
if
err
:=
kl
.
podManager
.
CreateMirrorPod
(
pod
);
err
!=
nil
{
glog
.
Errorf
(
"Failed creating a mirror pod
%q: %v"
,
podFullName
,
err
)
glog
.
Errorf
(
"Failed creating a mirror pod
for %q: %v"
,
format
.
Pod
(
pod
)
,
err
)
}
}
_
,
ok
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
_
,
ok
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
...
@@ -1654,7 +1653,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1654,7 +1653,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
}
}
if
err
:=
kl
.
makePodDataDirs
(
pod
);
err
!=
nil
{
if
err
:=
kl
.
makePodDataDirs
(
pod
);
err
!=
nil
{
glog
.
Errorf
(
"Unable to make pod data directories for pod %q
(uid %q): %v"
,
podFullName
,
uid
,
err
)
glog
.
Errorf
(
"Unable to make pod data directories for pod %q
: %v"
,
format
.
Pod
(
pod
)
,
err
)
return
err
return
err
}
}
...
@@ -1663,8 +1662,8 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1663,8 +1662,8 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
if
err
!=
nil
{
if
err
!=
nil
{
ref
,
errGetRef
:=
api
.
GetReference
(
pod
)
ref
,
errGetRef
:=
api
.
GetReference
(
pod
)
if
errGetRef
==
nil
&&
ref
!=
nil
{
if
errGetRef
==
nil
&&
ref
!=
nil
{
kl
.
recorder
.
Eventf
(
ref
,
api
.
EventTypeWarning
,
kubecontainer
.
FailedMountVolume
,
"Unable to mount volumes for pod %q: %v"
,
podFullName
,
err
)
kl
.
recorder
.
Eventf
(
ref
,
api
.
EventTypeWarning
,
kubecontainer
.
FailedMountVolume
,
"Unable to mount volumes for pod %q: %v"
,
format
.
Pod
(
pod
)
,
err
)
glog
.
Errorf
(
"Unable to mount volumes for pod %q: %v; skipping pod"
,
podFullName
,
err
)
glog
.
Errorf
(
"Unable to mount volumes for pod %q: %v; skipping pod"
,
format
.
Pod
(
pod
)
,
err
)
return
err
return
err
}
}
}
}
...
@@ -1706,11 +1705,11 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1706,11 +1705,11 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
Name
:
pod
.
Name
,
Name
:
pod
.
Name
,
Namespace
:
pod
.
Namespace
,
Namespace
:
pod
.
Namespace
,
}
}
glog
.
V
(
3
)
.
Infof
(
"Not generating pod status for new pod %q"
,
podFullName
)
glog
.
V
(
3
)
.
Infof
(
"Not generating pod status for new pod %q"
,
format
.
Pod
(
pod
)
)
}
else
{
}
else
{
podStatusPtr
,
apiPodStatusPtr
,
err
:=
kl
.
containerRuntime
.
GetPodStatusAndAPIPodStatus
(
pod
)
podStatusPtr
,
apiPodStatusPtr
,
err
:=
kl
.
containerRuntime
.
GetPodStatusAndAPIPodStatus
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Unable to get status for pod %q
(uid %q): %v"
,
podFullName
,
uid
,
err
)
glog
.
Errorf
(
"Unable to get status for pod %q
: %v"
,
format
.
Pod
(
pod
)
,
err
)
return
err
return
err
}
}
apiPodStatus
=
*
apiPodStatusPtr
apiPodStatus
=
*
apiPodStatusPtr
...
@@ -1719,7 +1718,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
...
@@ -1719,7 +1718,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
pullSecrets
,
err
:=
kl
.
getPullSecretsForPod
(
pod
)
pullSecrets
,
err
:=
kl
.
getPullSecretsForPod
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Unable to get pull secrets for pod %q
(uid %q): %v"
,
podFullName
,
uid
,
err
)
glog
.
Errorf
(
"Unable to get pull secrets for pod %q
: %v"
,
format
.
Pod
(
pod
)
,
err
)
return
err
return
err
}
}
...
@@ -1912,8 +1911,7 @@ func (kl *Kubelet) cleanupTerminatedPods(pods []*api.Pod, runningPods []*kubecon
...
@@ -1912,8 +1911,7 @@ func (kl *Kubelet) cleanupTerminatedPods(pods []*api.Pod, runningPods []*kubecon
}
}
}
}
if
found
{
if
found
{
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
glog
.
V
(
5
)
.
Infof
(
"Keeping terminated pod %q, still running"
,
format
.
Pod
(
pod
))
glog
.
V
(
5
)
.
Infof
(
"Keeping terminated pod %q and uid %q, still running"
,
podFullName
,
pod
.
UID
)
continue
continue
}
}
terminating
=
append
(
terminating
,
pod
)
terminating
=
append
(
terminating
,
pod
)
...
@@ -3079,8 +3077,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
...
@@ -3079,8 +3077,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
metrics
.
PodStatusLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
PodStatusLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
glog
.
V
(
3
)
.
Infof
(
"Generating status for %q"
,
format
.
Pod
(
pod
))
glog
.
V
(
3
)
.
Infof
(
"Generating status for %q"
,
podFullName
)
// TODO: Consider include the container information.
// TODO: Consider include the container information.
if
kl
.
pastActiveDeadline
(
pod
)
{
if
kl
.
pastActiveDeadline
(
pod
)
{
...
@@ -3097,7 +3094,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
...
@@ -3097,7 +3094,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
if
err
!=
nil
{
if
err
!=
nil
{
// Error handling
// Error handling
glog
.
Infof
(
"Query container info for pod %q failed with error (%v)"
,
podFullName
,
err
)
glog
.
Infof
(
"Query container info for pod %q failed with error (%v)"
,
format
.
Pod
(
pod
)
,
err
)
if
strings
.
Contains
(
err
.
Error
(),
"resource temporarily unavailable"
)
{
if
strings
.
Contains
(
err
.
Error
(),
"resource temporarily unavailable"
)
{
// Leave upstream layer to decide what to do
// Leave upstream layer to decide what to do
return
api
.
PodStatus
{},
err
return
api
.
PodStatus
{},
err
...
...
pkg/kubelet/rkt/rkt.go
View file @
9f3d28c7
...
@@ -1154,8 +1154,6 @@ func (r *Runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error) {
...
@@ -1154,8 +1154,6 @@ func (r *Runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error) {
// SyncPod syncs the running pod to match the specified desired pod.
// SyncPod syncs the running pod to match the specified desired pod.
func
(
r
*
Runtime
)
SyncPod
(
pod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
podStatus
api
.
PodStatus
,
_
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
func
(
r
*
Runtime
)
SyncPod
(
pod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
,
podStatus
api
.
PodStatus
,
_
*
kubecontainer
.
PodStatus
,
pullSecrets
[]
api
.
Secret
,
backOff
*
util
.
Backoff
)
error
{
podFullName
:=
format
.
Pod
(
pod
)
// Add references to all containers.
// Add references to all containers.
unidentifiedContainers
:=
make
(
map
[
kubecontainer
.
ContainerID
]
*
kubecontainer
.
Container
)
unidentifiedContainers
:=
make
(
map
[
kubecontainer
.
ContainerID
]
*
kubecontainer
.
Container
)
for
_
,
c
:=
range
runningPod
.
Containers
{
for
_
,
c
:=
range
runningPod
.
Containers
{
...
@@ -1183,14 +1181,14 @@ func (r *Runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
...
@@ -1183,14 +1181,14 @@ func (r *Runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
// TODO(yifan): Take care of host network change.
// TODO(yifan): Take care of host network change.
containerChanged
:=
c
.
Hash
!=
0
&&
c
.
Hash
!=
expectedHash
containerChanged
:=
c
.
Hash
!=
0
&&
c
.
Hash
!=
expectedHash
if
containerChanged
{
if
containerChanged
{
glog
.
Infof
(
"Pod %q container %q hash changed (%d vs %d), it will be killed and re-created."
,
podFullName
,
container
.
Name
,
c
.
Hash
,
expectedHash
)
glog
.
Infof
(
"Pod %q container %q hash changed (%d vs %d), it will be killed and re-created."
,
format
.
Pod
(
pod
)
,
container
.
Name
,
c
.
Hash
,
expectedHash
)
restartPod
=
true
restartPod
=
true
break
break
}
}
liveness
,
found
:=
r
.
livenessManager
.
Get
(
c
.
ID
)
liveness
,
found
:=
r
.
livenessManager
.
Get
(
c
.
ID
)
if
found
&&
liveness
!=
proberesults
.
Success
&&
pod
.
Spec
.
RestartPolicy
!=
api
.
RestartPolicyNever
{
if
found
&&
liveness
!=
proberesults
.
Success
&&
pod
.
Spec
.
RestartPolicy
!=
api
.
RestartPolicyNever
{
glog
.
Infof
(
"Pod %q container %q is unhealthy, it will be killed and re-created."
,
podFullName
,
container
.
Name
)
glog
.
Infof
(
"Pod %q container %q is unhealthy, it will be killed and re-created."
,
format
.
Pod
(
pod
)
,
container
.
Name
)
restartPod
=
true
restartPod
=
true
break
break
}
}
...
...
pkg/kubelet/runonce.go
View file @
9f3d28c7
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/util/format"
)
)
const
(
const
(
...
@@ -109,10 +110,9 @@ func (kl *Kubelet) runPod(pod *api.Pod, retryDelay time.Duration) error {
...
@@ -109,10 +110,9 @@ func (kl *Kubelet) runPod(pod *api.Pod, retryDelay time.Duration) error {
}
}
glog
.
Infof
(
"pod %q containers not running: syncing"
,
pod
.
Name
)
glog
.
Infof
(
"pod %q containers not running: syncing"
,
pod
.
Name
)
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
glog
.
Infof
(
"Creating a mirror pod for static pod %q"
,
format
.
Pod
(
pod
))
glog
.
Infof
(
"Creating a mirror pod for static pod %q"
,
podFullName
)
if
err
:=
kl
.
podManager
.
CreateMirrorPod
(
pod
);
err
!=
nil
{
if
err
:=
kl
.
podManager
.
CreateMirrorPod
(
pod
);
err
!=
nil
{
glog
.
Errorf
(
"Failed creating a mirror pod %q: %v"
,
podFullName
,
err
)
glog
.
Errorf
(
"Failed creating a mirror pod %q: %v"
,
format
.
Pod
(
pod
)
,
err
)
}
}
mirrorPod
,
_
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
mirrorPod
,
_
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
...
...
pkg/kubelet/util/format/pod.go
View file @
9f3d28c7
...
@@ -25,26 +25,18 @@ import (
...
@@ -25,26 +25,18 @@ import (
type
podHandler
func
(
*
api
.
Pod
)
string
type
podHandler
func
(
*
api
.
Pod
)
string
// Pod returns a string representating a pod in a human readable
// Pod returns a string reprenetating a pod in a human readable format,
// format. This function currently is the same as GetPodFullName in
// with pod UID as part of the string.
// kubelet/containers, but may differ in the future. As opposed to
// GetPodFullName, this function is mainly used for logging.
func
Pod
(
pod
*
api
.
Pod
)
string
{
func
Pod
(
pod
*
api
.
Pod
)
string
{
// Use underscore as the delimiter because it is not allowed in pod name
// Use underscore as the delimiter because it is not allowed in pod name
// (DNS subdomain format), while allowed in the container name format.
// (DNS subdomain format), while allowed in the container name format.
return
fmt
.
Sprintf
(
"%s_%s"
,
pod
.
Name
,
pod
.
Namespace
)
return
fmt
.
Sprintf
(
"%s_%s(%s)"
,
pod
.
Name
,
pod
.
Namespace
,
pod
.
UID
)
}
// PodWithUID returns a string reprenetating a pod in a human readable format,
// with pod UID as part of the string.
func
PodWithUID
(
pod
*
api
.
Pod
)
string
{
return
fmt
.
Sprintf
(
"%s(%s)"
,
Pod
(
pod
),
pod
.
UID
)
}
}
// Pods returns a string representating a list of pods in a human
// Pods returns a string representating a list of pods in a human
// readable format.
// readable format.
func
Pods
(
pods
[]
*
api
.
Pod
)
string
{
func
Pods
(
pods
[]
*
api
.
Pod
)
string
{
return
aggregatePods
(
pods
,
Pod
WithUID
)
return
aggregatePods
(
pods
,
Pod
)
}
}
func
aggregatePods
(
pods
[]
*
api
.
Pod
,
handler
podHandler
)
string
{
func
aggregatePods
(
pods
[]
*
api
.
Pod
,
handler
podHandler
)
string
{
...
...
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