Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit b420762

Browse files
committed
Add hyper logs
1 parent b27806e commit b420762

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

pkg/kubelet/hyper/hyper.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ func (r *runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
270270

271271
var kubepods []*kubecontainer.Pod
272272
for _, podInfo := range podInfos {
273-
if !all && podInfo.Status != "running" {
274-
continue
275-
}
276-
277273
var pod kubecontainer.Pod
278274
var containers []*kubecontainer.Container
279275

@@ -861,8 +857,33 @@ func (r *runtime) RemoveImage(image kubecontainer.ImageSpec) error {
861857
// stream the log. Set 'follow' to false and specify the number of lines (e.g.
862858
// "100" or "all") to tail the log.
863859
func (r *runtime) GetContainerLogs(pod *api.Pod, containerID kubecontainer.ContainerID, logOptions *api.PodLogOptions, stdout, stderr io.Writer) error {
864-
// TODO: get container logs for hyper
865-
return fmt.Errorf("Hyper: GetContainerLogs unimplemented")
860+
glog.V(4).Infof("Hyper: running logs on container %s", containerID.ID)
861+
862+
args := append([]string{}, "logs")
863+
if logOptions.Follow {
864+
args = append(args, "--follow")
865+
}
866+
if *logOptions.SinceSeconds != 0 {
867+
args = append(args, fmt.Sprintf("--since=%d", *logOptions.SinceSeconds))
868+
}
869+
if *logOptions.TailLines != 0 {
870+
args = append(args, fmt.Sprintf("--tail=%d", *logOptions.TailLines))
871+
}
872+
if logOptions.Timestamps {
873+
args = append(args, "--timestamps")
874+
}
875+
876+
command := r.buildCommand(args...)
877+
p, err := kubecontainer.StartPty(command)
878+
if err != nil {
879+
return err
880+
}
881+
defer p.Close()
882+
883+
if stdout != nil {
884+
go io.Copy(stdout, p)
885+
}
886+
return command.Wait()
866887
}
867888

868889
// Runs the command in the container of the specified pod
@@ -909,7 +930,6 @@ func (r *runtime) ExecInContainer(containerID kubecontainer.ContainerID, cmd []s
909930
go io.Copy(stdout, p)
910931
}
911932
return command.Wait()
912-
913933
}
914934

915935
func (r *runtime) AttachContainer(containerID kubecontainer.ContainerID, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool) error {

pkg/kubelet/hyper/hyperclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const (
4141
HYPER_PROTO = "unix"
4242
HYPER_ADDR = "/var/run/hyper.sock"
4343
HYPER_SCHEME = "http"
44-
HYPER_MINVERSION = "0.3.0"
44+
HYPER_MINVERSION = "0.4.0"
4545
DEFAULT_IMAGE_TAG = "latest"
4646

4747
KEY_ID = "id"

0 commit comments

Comments
 (0)