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
682c68c2
Commit
682c68c2
authored
Sep 01, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address comments, and fix some bugs in kubectl.
parent
7f4bca80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
log.go
pkg/kubectl/cmd/log.go
+4
-0
run.go
pkg/kubectl/cmd/run.go
+14
-6
kubectl.go
test/e2e/kubectl.go
+3
-5
No files found.
pkg/kubectl/cmd/log.go
View file @
682c68c2
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
libutil
"k8s.io/kubernetes/pkg/util"
libutil
"k8s.io/kubernetes/pkg/util"
)
)
...
@@ -145,7 +146,10 @@ func RunLog(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
...
@@ -145,7 +146,10 @@ func RunLog(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
if
cmdutil
.
GetFlagBool
(
cmd
,
"previous"
)
{
if
cmdutil
.
GetFlagBool
(
cmd
,
"previous"
)
{
previous
=
true
previous
=
true
}
}
return
handleLog
(
client
,
namespace
,
podID
,
container
,
follow
,
previous
,
out
)
}
func
handleLog
(
client
*
client
.
Client
,
namespace
,
podID
,
container
string
,
follow
,
previous
bool
,
out
io
.
Writer
)
error
{
readCloser
,
err
:=
client
.
RESTClient
.
Get
()
.
readCloser
,
err
:=
client
.
RESTClient
.
Get
()
.
Namespace
(
namespace
)
.
Namespace
(
namespace
)
.
Name
(
podID
)
.
Name
(
podID
)
.
...
...
pkg/kubectl/cmd/run.go
View file @
682c68c2
...
@@ -239,14 +239,15 @@ func Run(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cob
...
@@ -239,14 +239,15 @@ func Run(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cob
return
nil
return
nil
}
}
func
waitForPodRunning
(
c
*
client
.
Client
,
pod
*
api
.
Pod
,
out
io
.
Writer
)
error
{
func
waitForPodRunning
(
c
*
client
.
Client
,
pod
*
api
.
Pod
,
out
io
.
Writer
)
(
status
api
.
PodPhase
,
err
error
)
{
for
{
for
{
pod
,
err
:=
c
.
Pods
(
pod
.
Namespace
)
.
Get
(
pod
.
Name
)
pod
,
err
:=
c
.
Pods
(
pod
.
Namespace
)
.
Get
(
pod
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
api
.
PodUnknown
,
err
}
}
ready
:=
false
if
pod
.
Status
.
Phase
==
api
.
PodRunning
{
if
pod
.
Status
.
Phase
==
api
.
PodRunning
{
ready
:
=
true
ready
=
true
for
_
,
status
:=
range
pod
.
Status
.
ContainerStatuses
{
for
_
,
status
:=
range
pod
.
Status
.
ContainerStatuses
{
if
!
status
.
Ready
{
if
!
status
.
Ready
{
ready
=
false
ready
=
false
...
@@ -254,10 +255,13 @@ func waitForPodRunning(c *client.Client, pod *api.Pod, out io.Writer) error {
...
@@ -254,10 +255,13 @@ func waitForPodRunning(c *client.Client, pod *api.Pod, out io.Writer) error {
}
}
}
}
if
ready
{
if
ready
{
return
nil
return
api
.
PodRunning
,
nil
}
}
}
}
fmt
.
Fprintf
(
out
,
"Waiting for pod %s/%s to be running
\n
"
,
pod
.
Namespace
,
pod
.
Name
)
if
pod
.
Status
.
Phase
==
api
.
PodSucceeded
||
pod
.
Status
.
Phase
==
api
.
PodFailed
{
return
pod
.
Status
.
Phase
,
nil
}
fmt
.
Fprintf
(
out
,
"Waiting for pod %s/%s to be running, status is %s, pod ready: %v
\n
"
,
pod
.
Namespace
,
pod
.
Name
,
pod
.
Status
.
Phase
,
ready
)
time
.
Sleep
(
2
*
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
continue
continue
}
}
...
@@ -280,9 +284,13 @@ func handleAttachReplicationController(c *client.Client, controller *api.Replica
...
@@ -280,9 +284,13 @@ func handleAttachReplicationController(c *client.Client, controller *api.Replica
}
}
func
handleAttachPod
(
c
*
client
.
Client
,
pod
*
api
.
Pod
,
opts
*
AttachOptions
)
error
{
func
handleAttachPod
(
c
*
client
.
Client
,
pod
*
api
.
Pod
,
opts
*
AttachOptions
)
error
{
if
err
:=
waitForPodRunning
(
c
,
pod
,
opts
.
Out
);
err
!=
nil
{
status
,
err
:=
waitForPodRunning
(
c
,
pod
,
opts
.
Out
)
if
err
!=
nil
{
return
err
return
err
}
}
if
status
==
api
.
PodSucceeded
||
status
==
api
.
PodFailed
{
return
handleLog
(
c
,
pod
.
Namespace
,
pod
.
Name
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
false
,
false
,
opts
.
Out
)
}
opts
.
Client
=
c
opts
.
Client
=
c
opts
.
PodName
=
pod
.
Name
opts
.
PodName
=
pod
.
Name
opts
.
Namespace
=
pod
.
Namespace
opts
.
Namespace
=
pod
.
Namespace
...
...
test/e2e/kubectl.go
View file @
682c68c2
...
@@ -190,12 +190,10 @@ var _ = Describe("Kubectl client", func() {
...
@@ -190,12 +190,10 @@ var _ = Describe("Kubectl client", func() {
It
(
"should support inline execution and attach"
,
func
()
{
It
(
"should support inline execution and attach"
,
func
()
{
By
(
"executing a command with run and attach"
)
By
(
"executing a command with run and attach"
)
runOutput
:=
runKubectl
(
"run"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
),
"run"
,
"run-test"
,
"--image=busybox"
,
"--restart=Never"
,
"--attach
"
,
"echo"
,
"running"
,
"in"
,
"container"
)
runOutput
:=
runKubectl
(
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
),
"run"
,
"run-test"
,
"--image=busybox"
,
"--restart=Never"
,
"--attach=true
"
,
"echo"
,
"running"
,
"in"
,
"container"
)
expectedRunOutput
:=
"running in container"
expectedRunOutput
:=
"running in container"
if
runOutput
!=
expectedRunOutput
{
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
expectedRunOutput
))
Failf
(
"Unexpected kubectl exec output. Wanted '%s', got '%s'"
,
runOutput
,
expectedRunOutput
)
// everything in the ns will be deleted at the end of the test
}
runKubectl
(
"delete"
,
"pods"
,
"run-test"
)
})
})
It
(
"should support port-forward"
,
func
()
{
It
(
"should support port-forward"
,
func
()
{
...
...
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