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
59c31c89
Commit
59c31c89
authored
Aug 07, 2017
by
tcharding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplicate logging code
parent
ae4fac41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
26 deletions
+28
-26
run.go
pkg/kubectl/cmd/run.go
+28
-26
No files found.
pkg/kubectl/cmd/run.go
View file @
59c31c89
...
...
@@ -455,42 +455,44 @@ func handleAttachPod(f cmdutil.Factory, podClient coreclient.PodsGetter, ns, nam
if
err
!=
nil
&&
err
!=
conditions
.
ErrPodCompleted
{
return
err
}
ctrName
,
err
:=
opts
.
GetContainerName
(
pod
)
if
err
!=
nil
{
return
err
}
if
pod
.
Status
.
Phase
==
api
.
PodSucceeded
||
pod
.
Status
.
Phase
==
api
.
PodFailed
{
req
,
err
:=
f
.
LogsForObject
(
pod
,
&
api
.
PodLogOptions
{
Container
:
ctrName
},
opts
.
GetPodTimeout
)
if
err
!=
nil
{
return
err
}
readCloser
,
err
:=
req
.
Stream
()
if
err
!=
nil
{
return
err
}
defer
readCloser
.
Close
()
_
,
err
=
io
.
Copy
(
opts
.
Out
,
readCloser
)
return
err
return
logOpts
(
f
,
pod
,
opts
)
}
opts
.
PodClient
=
podClient
opts
.
PodName
=
name
opts
.
Namespace
=
ns
// TODO: opts.Run sets opts.Err to nil, we need to find a better way
stderr
:=
opts
.
Err
if
err
:=
opts
.
Run
();
err
!=
nil
{
fmt
.
Fprintf
(
stderr
,
"Error attaching, falling back to logs: %v
\n
"
,
err
)
req
,
err
:=
f
.
LogsForObject
(
pod
,
&
api
.
PodLogOptions
{
Container
:
ctrName
},
opts
.
GetPodTimeout
)
if
err
!=
nil
{
return
err
}
readCloser
,
err
:=
req
.
Stream
()
if
err
!=
nil
{
return
err
}
defer
readCloser
.
Close
()
_
,
err
=
io
.
Copy
(
opts
.
Out
,
readCloser
)
return
logOpts
(
f
,
pod
,
opts
)
}
return
nil
}
// logOpts logs output from opts to the pods log.
func
logOpts
(
f
cmdutil
.
Factory
,
pod
*
api
.
Pod
,
opts
*
AttachOptions
)
error
{
ctrName
,
err
:=
opts
.
GetContainerName
(
pod
)
if
err
!=
nil
{
return
err
}
req
,
err
:=
f
.
LogsForObject
(
pod
,
&
api
.
PodLogOptions
{
Container
:
ctrName
},
opts
.
GetPodTimeout
)
if
err
!=
nil
{
return
err
}
readCloser
,
err
:=
req
.
Stream
()
if
err
!=
nil
{
return
err
}
defer
readCloser
.
Close
()
_
,
err
=
io
.
Copy
(
opts
.
Out
,
readCloser
)
if
err
!=
nil
{
return
err
}
return
nil
...
...
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