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
4935e119
Commit
4935e119
authored
May 19, 2017
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix kuberuntime GetPods.
parent
b6211c6e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
helpers.go
pkg/kubelet/kuberuntime/helpers.go
+2
-2
helpers_test.go
pkg/kubelet/kuberuntime/helpers_test.go
+36
-0
No files found.
pkg/kubelet/kuberuntime/helpers.go
View file @
4935e119
...
@@ -105,11 +105,11 @@ func (m *kubeGenericRuntimeManager) toKubeContainer(c *runtimeapi.Container) (*k
...
@@ -105,11 +105,11 @@ func (m *kubeGenericRuntimeManager) toKubeContainer(c *runtimeapi.Container) (*k
return
nil
,
fmt
.
Errorf
(
"unable to convert a nil pointer to a runtime container"
)
return
nil
,
fmt
.
Errorf
(
"unable to convert a nil pointer to a runtime container"
)
}
}
labeledInfo
:=
getContainerInfoFromLabels
(
c
.
Labels
)
annotatedInfo
:=
getContainerInfoFromAnnotations
(
c
.
Annotations
)
annotatedInfo
:=
getContainerInfoFromAnnotations
(
c
.
Annotations
)
return
&
kubecontainer
.
Container
{
return
&
kubecontainer
.
Container
{
ID
:
kubecontainer
.
ContainerID
{
Type
:
m
.
runtimeName
,
ID
:
c
.
Id
},
ID
:
kubecontainer
.
ContainerID
{
Type
:
m
.
runtimeName
,
ID
:
c
.
Id
},
Name
:
labeledInfo
.
ContainerName
,
Name
:
c
.
GetMetadata
()
.
GetName
(),
ImageID
:
c
.
ImageRef
,
Image
:
c
.
Image
.
Image
,
Image
:
c
.
Image
.
Image
,
Hash
:
annotatedInfo
.
Hash
,
Hash
:
annotatedInfo
.
Hash
,
State
:
toKubeContainerState
(
c
.
State
),
State
:
toKubeContainerState
(
c
.
State
),
...
...
pkg/kubelet/kuberuntime/helpers_test.go
View file @
4935e119
...
@@ -22,6 +22,9 @@ import (
...
@@ -22,6 +22,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
runtimetesting
"k8s.io/kubernetes/pkg/kubelet/apis/cri/testing"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
)
)
func
TestStableKey
(
t
*
testing
.
T
)
{
func
TestStableKey
(
t
*
testing
.
T
)
{
...
@@ -86,3 +89,36 @@ func TestGetSystclsFromAnnotations(t *testing.T) {
...
@@ -86,3 +89,36 @@ func TestGetSystclsFromAnnotations(t *testing.T) {
assert
.
Equal
(
t
,
test
.
expectedSysctls
,
actualSysctls
,
"TestCase[%d]"
,
i
)
assert
.
Equal
(
t
,
test
.
expectedSysctls
,
actualSysctls
,
"TestCase[%d]"
,
i
)
}
}
}
}
func
TestToKubeContainer
(
t
*
testing
.
T
)
{
c
:=
&
runtimeapi
.
Container
{
Id
:
"test-id"
,
Metadata
:
&
runtimeapi
.
ContainerMetadata
{
Name
:
"test-name"
,
Attempt
:
1
,
},
Image
:
&
runtimeapi
.
ImageSpec
{
Image
:
"test-image"
},
ImageRef
:
"test-image-ref"
,
State
:
runtimeapi
.
ContainerState_CONTAINER_RUNNING
,
Annotations
:
map
[
string
]
string
{
containerHashLabel
:
"1234"
,
},
}
expect
:=
&
kubecontainer
.
Container
{
ID
:
kubecontainer
.
ContainerID
{
Type
:
runtimetesting
.
FakeRuntimeName
,
ID
:
"test-id"
,
},
Name
:
"test-name"
,
ImageID
:
"test-image-ref"
,
Image
:
"test-image"
,
Hash
:
uint64
(
0x1234
),
State
:
kubecontainer
.
ContainerStateRunning
,
}
_
,
_
,
m
,
err
:=
createTestRuntimeManager
()
assert
.
NoError
(
t
,
err
)
got
,
err
:=
m
.
toKubeContainer
(
c
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
expect
,
got
)
}
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