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
b1a6ee26
Commit
b1a6ee26
authored
Mar 04, 2016
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore "no such container" error when generating pod status
This allows the pod continue to sync if one container in a corrupt state.
parent
3e948a6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
manager.go
pkg/kubelet/dockertools/manager.go
+14
-2
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+52
-0
No files found.
pkg/kubelet/dockertools/manager.go
View file @
b1a6ee26
...
@@ -2110,10 +2110,22 @@ func (dm *DockerManager) GetPodStatus(uid types.UID, name, namespace string) (*k
...
@@ -2110,10 +2110,22 @@ func (dm *DockerManager) GetPodStatus(uid types.UID, name, namespace string) (*k
if
dockerName
.
PodUID
!=
uid
{
if
dockerName
.
PodUID
!=
uid
{
continue
continue
}
}
result
,
ip
,
err
:=
dm
.
inspectContainer
(
c
.
ID
,
name
,
namespace
)
result
,
ip
,
err
:=
dm
.
inspectContainer
(
c
.
ID
,
name
,
namespace
)
if
err
!=
nil
{
if
err
!=
nil
{
return
podStatus
,
err
if
_
,
ok
:=
err
.
(
*
docker
.
NoSuchContainer
);
ok
{
// https://github.com/kubernetes/kubernetes/issues/22541
// Sometimes when docker's state is corrupt, a container can be listed
// but couldn't be inspected. We fake a status for this container so
// that we can still return a status for the pod to sync.
result
=
&
kubecontainer
.
ContainerStatus
{
ID
:
kubecontainer
.
DockerID
(
c
.
ID
)
.
ContainerID
(),
Name
:
dockerName
.
ContainerName
,
State
:
kubecontainer
.
ContainerStateUnknown
,
}
glog
.
Errorf
(
"Unable to inspect container %q: %v"
,
c
.
ID
,
err
)
}
else
{
return
podStatus
,
err
}
}
}
containerStatuses
=
append
(
containerStatuses
,
result
)
containerStatuses
=
append
(
containerStatuses
,
result
)
if
ip
!=
""
{
if
ip
!=
""
{
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
b1a6ee26
...
@@ -1887,3 +1887,55 @@ func TestCheckVersionCompatibility(t *testing.T) {
...
@@ -1887,3 +1887,55 @@ func TestCheckVersionCompatibility(t *testing.T) {
}
}
}
}
}
}
func
TestGetPodStatusNoSuchContainer
(
t
*
testing
.
T
)
{
const
(
noSuchContainerID
=
"nosuchcontainer"
infraContainerID
=
"9876"
)
dm
,
fakeDocker
:=
newTestDockerManager
()
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Name
:
"nosuchcontainer"
}},
},
}
fakeDocker
.
SetFakeContainers
([]
*
docker
.
Container
{
{
ID
:
noSuchContainerID
,
Name
:
"/k8s_nosuchcontainer_foo_new_12345678_42"
,
State
:
docker
.
State
{
ExitCode
:
0
,
StartedAt
:
time
.
Now
(),
FinishedAt
:
time
.
Now
(),
Running
:
false
,
},
},
{
ID
:
infraContainerID
,
Name
:
"/k8s_POD."
+
strconv
.
FormatUint
(
generatePodInfraContainerHash
(
pod
),
16
)
+
"_foo_new_12345678_42"
,
State
:
docker
.
State
{
ExitCode
:
0
,
StartedAt
:
time
.
Now
(),
FinishedAt
:
time
.
Now
(),
Running
:
false
,
},
}})
fakeDocker
.
Errors
=
map
[
string
]
error
{
"inspect"
:
&
docker
.
NoSuchContainer
{}}
runSyncPod
(
t
,
dm
,
fakeDocker
,
pod
,
nil
,
false
)
// Verify that we will try to start new contrainers even if the inspections
// failed.
verifyCalls
(
t
,
fakeDocker
,
[]
string
{
// Start a new infra container.
"create"
,
"start"
,
"inspect_container"
,
"inspect_container"
,
// Start a new container.
"create"
,
"start"
,
"inspect_container"
,
})
}
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