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
c848fa44
Commit
c848fa44
authored
Apr 28, 2015
by
Yifan Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubelet: Refactor isPodRunning() in runonce.go
Replace InspectContainer() with generic GetPodStatus().
parent
44e71093
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
runonce.go
pkg/kubelet/runonce.go
+9
-13
runonce_test.go
pkg/kubelet/runonce_test.go
+1
-0
No files found.
pkg/kubelet/runonce.go
View file @
c848fa44
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -119,19 +120,14 @@ func (kl *Kubelet) runPod(pod *api.Pod, retryDelay time.Duration) error {
...
@@ -119,19 +120,14 @@ func (kl *Kubelet) runPod(pod *api.Pod, retryDelay time.Duration) error {
// isPodRunning returns true if all containers of a manifest are running.
// isPodRunning returns true if all containers of a manifest are running.
func
(
kl
*
Kubelet
)
isPodRunning
(
pod
*
api
.
Pod
,
runningPod
container
.
Pod
)
(
bool
,
error
)
{
func
(
kl
*
Kubelet
)
isPodRunning
(
pod
*
api
.
Pod
,
runningPod
container
.
Pod
)
(
bool
,
error
)
{
for
_
,
container
:=
range
pod
.
Spec
.
Containers
{
status
,
err
:=
kl
.
containerManager
.
GetPodStatus
(
pod
)
c
:=
runningPod
.
FindContainerByName
(
container
.
Name
)
if
err
!=
nil
{
if
c
==
nil
{
glog
.
Infof
(
"Failed to get the status of pod %q: %v"
,
kubecontainer
.
GetPodFullName
(
pod
),
err
)
glog
.
Infof
(
"container %q not found"
,
container
.
Name
)
return
false
,
err
return
false
,
nil
}
}
for
_
,
st
:=
range
status
.
ContainerStatuses
{
inspectResult
,
err
:=
kl
.
dockerClient
.
InspectContainer
(
string
(
c
.
ID
))
if
st
.
State
.
Running
==
nil
{
if
err
!=
nil
{
glog
.
Infof
(
"Container %q not running: %#v"
,
st
.
Name
,
st
.
State
)
glog
.
Infof
(
"failed to inspect container %q: %v"
,
container
.
Name
,
err
)
return
false
,
err
}
if
!
inspectResult
.
State
.
Running
{
glog
.
Infof
(
"container %q not running: %#v"
,
container
.
Name
,
inspectResult
.
State
)
return
false
,
nil
return
false
,
nil
}
}
}
}
...
...
pkg/kubelet/runonce_test.go
View file @
c848fa44
...
@@ -113,6 +113,7 @@ func TestRunOnce(t *testing.T) {
...
@@ -113,6 +113,7 @@ func TestRunOnce(t *testing.T) {
{
label
:
"list pod container"
,
containers
:
[]
docker
.
APIContainers
{}},
{
label
:
"list pod container"
,
containers
:
[]
docker
.
APIContainers
{}},
{
label
:
"syncPod"
,
containers
:
podContainers
},
{
label
:
"syncPod"
,
containers
:
podContainers
},
{
label
:
"list pod container"
,
containers
:
podContainers
},
{
label
:
"list pod container"
,
containers
:
podContainers
},
{
label
:
"list pod container"
,
containers
:
podContainers
},
},
},
inspectContainersResults
:
[]
inspectContainersResult
{
inspectContainersResults
:
[]
inspectContainersResult
{
{
{
...
...
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