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
7611c839
Commit
7611c839
authored
Oct 17, 2014
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1873 from derekwaynecarr/kubelet_handleRun_namespace_aware
Make kubelet handleRun work for pods in non-default namespace
parents
be7d5a3d
1f094d97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
server.go
pkg/kubelet/server.go
+11
-10
server_test.go
pkg/kubelet/server_test.go
+6
-4
No files found.
pkg/kubelet/server.go
View file @
7611c839
...
@@ -301,23 +301,24 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
...
@@ -301,23 +301,24 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
return
return
}
}
parts
:=
strings
.
Split
(
u
.
Path
,
"/"
)
parts
:=
strings
.
Split
(
u
.
Path
,
"/"
)
var
podID
,
uuid
,
container
string
var
podNamespace
,
podID
,
uuid
,
container
string
if
len
(
parts
)
==
4
{
if
len
(
parts
)
==
5
{
podID
=
parts
[
2
]
podNamespace
=
parts
[
2
]
container
=
parts
[
3
]
podID
=
parts
[
3
]
}
else
if
len
(
parts
)
==
5
{
podID
=
parts
[
2
]
uuid
=
parts
[
3
]
container
=
parts
[
4
]
container
=
parts
[
4
]
}
else
if
len
(
parts
)
==
6
{
podNamespace
=
parts
[
2
]
podID
=
parts
[
3
]
uuid
=
parts
[
4
]
container
=
parts
[
5
]
}
else
{
}
else
{
http
.
Error
(
w
,
"Unexpected path for command running"
,
http
.
StatusBadRequest
)
http
.
Error
(
w
,
"Unexpected path for command running"
,
http
.
StatusBadRequest
)
return
return
}
}
podFullName
:=
GetPodFullName
(
&
api
.
BoundPod
{
podFullName
:=
GetPodFullName
(
&
api
.
BoundPod
{
TypeMeta
:
api
.
TypeMeta
{
TypeMeta
:
api
.
TypeMeta
{
ID
:
podID
,
ID
:
podID
,
// TODO: I am broken
Namespace
:
podNamespace
,
Namespace
:
api
.
NamespaceDefault
,
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"etcd"
},
Annotations
:
map
[
string
]
string
{
ConfigSourceAnnotationKey
:
"etcd"
},
},
},
})
})
...
...
pkg/kubelet/server_test.go
View file @
7611c839
...
@@ -386,8 +386,9 @@ func TestServeLogs(t *testing.T) {
...
@@ -386,8 +386,9 @@ func TestServeLogs(t *testing.T) {
func
TestServeRunInContainer
(
t
*
testing
.
T
)
{
func
TestServeRunInContainer
(
t
*
testing
.
T
)
{
fw
:=
newServerTest
()
fw
:=
newServerTest
()
output
:=
"foo bar"
output
:=
"foo bar"
podNamespace
:=
"other"
podName
:=
"foo"
podName
:=
"foo"
expectedPodName
:=
podName
+
".
default
.etcd"
expectedPodName
:=
podName
+
".
"
+
podNamespace
+
"
.etcd"
expectedContainerName
:=
"baz"
expectedContainerName
:=
"baz"
expectedCommand
:=
"ls -a"
expectedCommand
:=
"ls -a"
fw
.
fakeKubelet
.
runFunc
=
func
(
podFullName
,
uuid
,
containerName
string
,
cmd
[]
string
)
([]
byte
,
error
)
{
fw
.
fakeKubelet
.
runFunc
=
func
(
podFullName
,
uuid
,
containerName
string
,
cmd
[]
string
)
([]
byte
,
error
)
{
...
@@ -404,7 +405,7 @@ func TestServeRunInContainer(t *testing.T) {
...
@@ -404,7 +405,7 @@ func TestServeRunInContainer(t *testing.T) {
return
[]
byte
(
output
),
nil
return
[]
byte
(
output
),
nil
}
}
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/run/"
+
podName
+
"/"
+
expectedContainerName
+
"?cmd=ls%20-a"
)
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/run/"
+
podName
space
+
"/"
+
podName
+
"/"
+
expectedContainerName
+
"?cmd=ls%20-a"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Got error GETing: %v"
,
err
)
t
.
Fatalf
(
"Got error GETing: %v"
,
err
)
...
@@ -425,8 +426,9 @@ func TestServeRunInContainer(t *testing.T) {
...
@@ -425,8 +426,9 @@ func TestServeRunInContainer(t *testing.T) {
func
TestServeRunInContainerWithUUID
(
t
*
testing
.
T
)
{
func
TestServeRunInContainerWithUUID
(
t
*
testing
.
T
)
{
fw
:=
newServerTest
()
fw
:=
newServerTest
()
output
:=
"foo bar"
output
:=
"foo bar"
podNamespace
:=
"other"
podName
:=
"foo"
podName
:=
"foo"
expectedPodName
:=
podName
+
".
default
.etcd"
expectedPodName
:=
podName
+
".
"
+
podNamespace
+
"
.etcd"
expectedUuid
:=
"7e00838d_-_3523_-_11e4_-_8421_-_42010af0a720"
expectedUuid
:=
"7e00838d_-_3523_-_11e4_-_8421_-_42010af0a720"
expectedContainerName
:=
"baz"
expectedContainerName
:=
"baz"
expectedCommand
:=
"ls -a"
expectedCommand
:=
"ls -a"
...
@@ -447,7 +449,7 @@ func TestServeRunInContainerWithUUID(t *testing.T) {
...
@@ -447,7 +449,7 @@ func TestServeRunInContainerWithUUID(t *testing.T) {
return
[]
byte
(
output
),
nil
return
[]
byte
(
output
),
nil
}
}
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/run/"
+
podName
+
"/"
+
expectedUuid
+
"/"
+
expectedContainerName
+
"?cmd=ls%20-a"
)
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/run/"
+
podName
space
+
"/"
+
podName
+
"/"
+
expectedUuid
+
"/"
+
expectedContainerName
+
"?cmd=ls%20-a"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Got error GETing: %v"
,
err
)
t
.
Fatalf
(
"Got error GETing: %v"
,
err
)
...
...
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