Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Janitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Janitor
Commits
1c18b3d1
Commit
1c18b3d1
authored
1 year ago
by
Łukasz Łopatowski
Browse files
Options
Downloads
Patches
Plain Diff
Added support for container names for pod logs access
parent
59276e1f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/proto/v1/config-service.proto
+1
-0
1 addition, 0 deletions
api/proto/v1/config-service.proto
pkg/service/v1/config-service.go
+13
-3
13 additions, 3 deletions
pkg/service/v1/config-service.go
with
14 additions
and
3 deletions
api/proto/v1/config-service.proto
+
1
−
0
View file @
1c18b3d1
...
@@ -25,6 +25,7 @@ message Credentials {
...
@@ -25,6 +25,7 @@ message Credentials {
message
PodInfo
{
message
PodInfo
{
string
name
=
1
;
string
name
=
1
;
string
displayName
=
2
;
string
displayName
=
2
;
repeated
string
containers
=
3
;
}
}
message
InstanceRequest
{
message
InstanceRequest
{
...
...
This diff is collapsed.
Click to expand it.
pkg/service/v1/config-service.go
+
13
−
3
View file @
1c18b3d1
...
@@ -640,7 +640,10 @@ func (s *podServiceServer) RetrievePodList(ctx context.Context, req *v1.Instance
...
@@ -640,7 +640,10 @@ func (s *podServiceServer) RetrievePodList(ctx context.Context, req *v1.Instance
logLine
(
fmt
.
Sprintf
(
"Filtering pods by deployment %s"
,
depl
.
Uid
))
logLine
(
fmt
.
Sprintf
(
"Filtering pods by deployment %s"
,
depl
.
Uid
))
for
_
,
pod
:=
range
allPods
.
Items
{
for
_
,
pod
:=
range
allPods
.
Items
{
if
(
strings
.
HasPrefix
(
pod
.
Name
,
depl
.
Uid
+
"-"
))
{
if
(
strings
.
HasPrefix
(
pod
.
Name
,
depl
.
Uid
+
"-"
))
{
newPod
:=
&
v1
.
PodInfo
{
Name
:
pod
.
Name
,
DisplayName
:
pod
.
Name
,}
newPod
:=
&
v1
.
PodInfo
{
Name
:
pod
.
Name
,
DisplayName
:
pod
.
Name
,
Containers
:
make
([]
string
,
0
)}
for
container
:=
range
pod
.
Spec
.
Containers
{
newPod
.
Containers
=
append
(
newPod
.
Containers
,
pod
.
Spec
.
Containers
[
container
]
.
Name
)
}
matchingPods
=
append
(
matchingPods
,
newPod
)
matchingPods
=
append
(
matchingPods
,
newPod
)
}
}
}
}
...
@@ -672,8 +675,15 @@ func (s *podServiceServer) RetrievePodLogs(ctx context.Context, req *v1.PodReque
...
@@ -672,8 +675,15 @@ func (s *podServiceServer) RetrievePodLogs(ctx context.Context, req *v1.PodReque
}
}
//collecting logs from given pod
//collecting logs from given pod
logLine
(
fmt
.
Sprintf
(
"Collecting logs from pod %s in namespace %s"
,
pod
.
Name
,
depl
.
Namespace
))
var
opts
apiv1
.
PodLogOptions
logsRequest
:=
s
.
kubeAPI
.
CoreV1
()
.
Pods
(
depl
.
Namespace
)
.
GetLogs
(
pod
.
Name
,
&
apiv1
.
PodLogOptions
{})
if
len
(
pod
.
Containers
)
==
0
{
opts
=
apiv1
.
PodLogOptions
{}
}
else
{
opts
=
apiv1
.
PodLogOptions
{
Container
:
pod
.
Containers
[
0
]}
}
logLine
(
fmt
.
Sprintf
(
"Collecting logs from pod/container %s/%s in namespace %s"
,
pod
.
Name
,
opts
.
Container
,
depl
.
Namespace
))
logsRequest
:=
s
.
kubeAPI
.
CoreV1
()
.
Pods
(
depl
.
Namespace
)
.
GetLogs
(
pod
.
Name
,
&
opts
)
podLogs
,
err
:=
logsRequest
.
Stream
(
ctx
)
podLogs
,
err
:=
logsRequest
.
Stream
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment