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
b1c06eb5
Commit
b1c06eb5
authored
Mar 25, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5969 from yujuhong/selflink
Kubelet: no need to overwrite SelfLink for pods from the apiserver
parents
5936760b
4e909c6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
20 deletions
+7
-20
apiserver.go
pkg/kubelet/config/apiserver.go
+1
-4
apiserver_test.go
pkg/kubelet/config/apiserver_test.go
+6
-16
No files found.
pkg/kubelet/config/apiserver.go
View file @
b1c06eb5
...
...
@@ -36,10 +36,7 @@ func newSourceApiserverFromLW(lw cache.ListerWatcher, updates chan<- interface{}
send
:=
func
(
objs
[]
interface
{})
{
var
pods
[]
api
.
Pod
for
_
,
o
:=
range
objs
{
pod
:=
o
.
(
*
api
.
Pod
)
// Make a dummy self link so that references to this pod will work.
pod
.
SelfLink
=
"/api/v1beta1/pods/"
+
pod
.
Name
pods
=
append
(
pods
,
*
pod
)
pods
=
append
(
pods
,
*
o
.
(
*
api
.
Pod
))
}
updates
<-
kubelet
.
PodUpdate
{
pods
,
kubelet
.
SET
,
kubelet
.
ApiserverSource
}
}
...
...
pkg/kubelet/config/apiserver_test.go
View file @
b1c06eb5
...
...
@@ -52,16 +52,6 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"q"
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"image/blah"
}}}}
expectedPod1v1
:=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"p"
,
SelfLink
:
"/api/v1beta1/pods/p"
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"image/one"
}}}}
expectedPod1v2
:=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"p"
,
SelfLink
:
"/api/v1beta1/pods/p"
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"image/two"
}}}}
expectedPod2
:=
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"q"
,
SelfLink
:
"/api/v1beta1/pods/q"
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"image/blah"
}}}}
// Setup fake api client.
fakeWatch
:=
watch
.
NewFake
()
lw
:=
fakePodLW
{
...
...
@@ -78,7 +68,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
:=
got
.
(
kubelet
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
expectedP
od1v1
)
expected
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
p
od1v1
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
...
...
@@ -91,8 +81,8 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
update
=
got
.
(
kubelet
.
PodUpdate
)
// Could be sorted either of these two ways:
expectedA
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
expectedPod1v1
,
expectedP
od2
)
expectedB
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
expectedPod2
,
expectedP
od1v1
)
expectedA
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
pod1v1
,
p
od2
)
expectedB
:=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
pod2
,
p
od1v1
)
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
...
...
@@ -105,8 +95,8 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kubelet
.
PodUpdate
)
expectedA
=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
expectedPod1v2
,
expectedP
od2
)
expectedB
=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
expectedPod2
,
expectedP
od1v2
)
expectedA
=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
pod1v2
,
p
od2
)
expectedB
=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
pod2
,
p
od1v2
)
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
...
...
@@ -119,7 +109,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
update
=
got
.
(
kubelet
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
expectedP
od2
)
expected
=
CreatePodUpdate
(
kubelet
.
SET
,
kubelet
.
ApiserverSource
,
p
od2
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
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