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
897f1b3a
Commit
897f1b3a
authored
Oct 17, 2014
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handleContainerLogs needs a namespace to address a pod
parent
99e1e2fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
server.go
pkg/kubelet/server.go
+12
-7
server_test.go
pkg/kubelet/server_test.go
+9
-6
No files found.
pkg/kubelet/server.go
View file @
897f1b3a
...
@@ -175,10 +175,12 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
...
@@ -175,10 +175,12 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
}
}
parts
:=
strings
.
Split
(
u
.
Path
,
"/"
)
parts
:=
strings
.
Split
(
u
.
Path
,
"/"
)
var
podID
,
containerName
string
// req URI: /containerLogs/<podNamespace>/<podID>/<containerName>
if
len
(
parts
)
==
4
{
var
podNamespace
,
podID
,
containerName
string
podID
=
parts
[
2
]
if
len
(
parts
)
==
5
{
containerName
=
parts
[
3
]
podNamespace
=
parts
[
2
]
podID
=
parts
[
3
]
containerName
=
parts
[
4
]
}
else
{
}
else
{
http
.
Error
(
w
,
"Unexpected path for command running"
,
http
.
StatusBadRequest
)
http
.
Error
(
w
,
"Unexpected path for command running"
,
http
.
StatusBadRequest
)
return
return
...
@@ -192,6 +194,10 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
...
@@ -192,6 +194,10 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
http
.
Error
(
w
,
`{"message": "Missing container name."}`
,
http
.
StatusBadRequest
)
http
.
Error
(
w
,
`{"message": "Missing container name."}`
,
http
.
StatusBadRequest
)
return
return
}
}
if
len
(
podNamespace
)
==
0
{
http
.
Error
(
w
,
`{"message": "Missing podNamespace."}`
,
http
.
StatusBadRequest
)
return
}
uriValues
:=
u
.
Query
()
uriValues
:=
u
.
Query
()
follow
,
_
:=
strconv
.
ParseBool
(
uriValues
.
Get
(
"follow"
))
follow
,
_
:=
strconv
.
ParseBool
(
uriValues
.
Get
(
"follow"
))
...
@@ -199,9 +205,8 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
...
@@ -199,9 +205,8 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
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 @
897f1b3a
...
@@ -468,8 +468,9 @@ func TestServeRunInContainerWithUUID(t *testing.T) {
...
@@ -468,8 +468,9 @@ func TestServeRunInContainerWithUUID(t *testing.T) {
func
TestContainerLogs
(
t
*
testing
.
T
)
{
func
TestContainerLogs
(
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
+
".
other
.etcd"
expectedContainerName
:=
"baz"
expectedContainerName
:=
"baz"
expectedTail
:=
""
expectedTail
:=
""
expectedFollow
:=
false
expectedFollow
:=
false
...
@@ -488,7 +489,7 @@ func TestContainerLogs(t *testing.T) {
...
@@ -488,7 +489,7 @@ func TestContainerLogs(t *testing.T) {
}
}
return
nil
return
nil
}
}
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/containerLogs/"
+
podName
+
"/"
+
expectedContainerName
)
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/containerLogs/"
+
podName
space
+
"/"
+
podName
+
"/"
+
expectedContainerName
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Got error GETing: %v"
,
err
)
t
.
Errorf
(
"Got error GETing: %v"
,
err
)
}
}
...
@@ -507,8 +508,9 @@ func TestContainerLogs(t *testing.T) {
...
@@ -507,8 +508,9 @@ func TestContainerLogs(t *testing.T) {
func
TestContainerLogsWithTail
(
t
*
testing
.
T
)
{
func
TestContainerLogsWithTail
(
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
+
".
other
.etcd"
expectedContainerName
:=
"baz"
expectedContainerName
:=
"baz"
expectedTail
:=
"5"
expectedTail
:=
"5"
expectedFollow
:=
false
expectedFollow
:=
false
...
@@ -527,7 +529,7 @@ func TestContainerLogsWithTail(t *testing.T) {
...
@@ -527,7 +529,7 @@ func TestContainerLogsWithTail(t *testing.T) {
}
}
return
nil
return
nil
}
}
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/containerLogs/"
+
podName
+
"/"
+
expectedContainerName
+
"?tail=5"
)
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/containerLogs/"
+
podName
space
+
"/"
+
podName
+
"/"
+
expectedContainerName
+
"?tail=5"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Got error GETing: %v"
,
err
)
t
.
Errorf
(
"Got error GETing: %v"
,
err
)
}
}
...
@@ -546,8 +548,9 @@ func TestContainerLogsWithTail(t *testing.T) {
...
@@ -546,8 +548,9 @@ func TestContainerLogsWithTail(t *testing.T) {
func
TestContainerLogsWithFollow
(
t
*
testing
.
T
)
{
func
TestContainerLogsWithFollow
(
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
+
".
other
.etcd"
expectedContainerName
:=
"baz"
expectedContainerName
:=
"baz"
expectedTail
:=
""
expectedTail
:=
""
expectedFollow
:=
true
expectedFollow
:=
true
...
@@ -566,7 +569,7 @@ func TestContainerLogsWithFollow(t *testing.T) {
...
@@ -566,7 +569,7 @@ func TestContainerLogsWithFollow(t *testing.T) {
}
}
return
nil
return
nil
}
}
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/containerLogs/"
+
podName
+
"/"
+
expectedContainerName
+
"?follow=1"
)
resp
,
err
:=
http
.
Get
(
fw
.
testHTTPServer
.
URL
+
"/containerLogs/"
+
podName
space
+
"/"
+
podName
+
"/"
+
expectedContainerName
+
"?follow=1"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Got error GETing: %v"
,
err
)
t
.
Errorf
(
"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