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
a6aad159
Commit
a6aad159
authored
Oct 06, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure GetPodStatus can get statuses of all containers in a pod.
parent
6a9d56b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
kuberuntime_container.go
pkg/kubelet/kuberuntime/kuberuntime_container.go
+7
-5
kuberuntime_manager.go
pkg/kubelet/kuberuntime/kuberuntime_manager.go
+8
-9
No files found.
pkg/kubelet/kuberuntime/kuberuntime_container.go
View file @
a6aad159
...
...
@@ -35,8 +35,9 @@ import (
"k8s.io/kubernetes/pkg/kubelet/dockershim"
"k8s.io/kubernetes/pkg/kubelet/events"
"k8s.io/kubernetes/pkg/kubelet/qos"
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/types"
kubetypes
"k8s.io/kubernetes/pkg/types"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/util/term"
...
...
@@ -115,7 +116,7 @@ func (m *kubeGenericRuntimeManager) startContainer(podSandboxID string, podSandb
}
// getContainerLogsPath gets log path for container.
func
getContainerLogsPath
(
containerName
string
,
podUID
types
.
UID
)
string
{
func
getContainerLogsPath
(
containerName
string
,
podUID
kube
types
.
UID
)
string
{
return
path
.
Join
(
podLogsRootDirectory
,
string
(
podUID
),
fmt
.
Sprintf
(
"%s.log"
,
containerName
))
}
...
...
@@ -345,10 +346,11 @@ func getTerminationMessage(status *runtimeApi.ContainerStatus, kubeStatus *kubec
return
message
}
// getKubeletContainerStatuses gets all containers' status for the pod sandbox.
func
(
m
*
kubeGenericRuntimeManager
)
getKubeletContainerStatuses
(
podSandboxID
string
)
([]
*
kubecontainer
.
ContainerStatus
,
error
)
{
// getPodContainerStatuses gets all containers' statuses for the pod.
func
(
m
*
kubeGenericRuntimeManager
)
getPodContainerStatuses
(
uid
kubetypes
.
UID
,
name
,
namespace
string
)
([]
*
kubecontainer
.
ContainerStatus
,
error
)
{
// Select all containers of the given pod.
containers
,
err
:=
m
.
runtimeService
.
ListContainers
(
&
runtimeApi
.
ContainerFilter
{
PodSandboxId
:
&
podSandboxID
,
LabelSelector
:
map
[
string
]
string
{
types
.
KubernetesPodUIDLabel
:
string
(
uid
)}
,
})
if
err
!=
nil
{
glog
.
Errorf
(
"ListContainers error: %v"
,
err
)
...
...
pkg/kubelet/kuberuntime/kuberuntime_manager.go
View file @
a6aad159
...
...
@@ -876,15 +876,14 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
UID
:
uid
,
},
})
glog
.
V
(
4
)
.
Infof
(
"getSandboxIDByPodUID got sandbox IDs %q for pod %q
(UID:%q)"
,
podSandboxIDs
,
podFullName
,
string
(
uid
)
)
glog
.
V
(
4
)
.
Infof
(
"getSandboxIDByPodUID got sandbox IDs %q for pod %q
"
,
podSandboxIDs
,
podFullName
)
sandboxStatuses
:=
make
([]
*
runtimeApi
.
PodSandboxStatus
,
len
(
podSandboxIDs
))
containerStatuses
:=
[]
*
kubecontainer
.
ContainerStatus
{}
podIP
:=
""
for
idx
,
podSandboxID
:=
range
podSandboxIDs
{
podSandboxStatus
,
err
:=
m
.
runtimeService
.
PodSandboxStatus
(
podSandboxID
)
if
err
!=
nil
{
glog
.
Errorf
(
"PodSandboxStatus
for pod (uid:%v, name:%s, namespace:%s) error: %v"
,
uid
,
name
,
namespac
e
,
err
)
glog
.
Errorf
(
"PodSandboxStatus
of sandbox %q for pod %q error: %v"
,
podSandboxID
,
podFullNam
e
,
err
)
return
nil
,
err
}
sandboxStatuses
[
idx
]
=
podSandboxStatus
...
...
@@ -893,13 +892,13 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
if
idx
==
0
&&
podSandboxStatus
.
GetState
()
==
runtimeApi
.
PodSandBoxState_READY
{
podIP
=
m
.
determinePodSandboxIP
(
namespace
,
name
,
podSandboxStatus
)
}
}
statuses
,
err
:=
m
.
getKubeletContainerStatuses
(
podSandboxID
)
if
err
!=
nil
{
glog
.
Errorf
(
"getKubeletContainerStatuses for sandbox %s failed: %v"
,
podSandboxID
,
err
)
return
nil
,
err
}
containerStatuses
=
append
(
containerStatuses
,
statuses
...
)
// Get statuses of all containers visible in the pod.
containerStatuses
,
err
:=
m
.
getPodContainerStatuses
(
uid
,
name
,
namespace
)
if
err
!=
nil
{
glog
.
Errorf
(
"getPodContainerStatuses for pod %q failed: %v"
,
podFullName
,
err
)
return
nil
,
err
}
return
&
kubecontainer
.
PodStatus
{
...
...
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