aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/varlink/io.projectatomic.podman.varlink3
-rw-r--r--pkg/varlinkapi/containers.go33
-rw-r--r--pkg/varlinkapi/system.go2
3 files changed, 31 insertions, 7 deletions
diff --git a/cmd/podman/varlink/io.projectatomic.podman.varlink b/cmd/podman/varlink/io.projectatomic.podman.varlink
index 5463562c2..37b4c2591 100644
--- a/cmd/podman/varlink/io.projectatomic.podman.varlink
+++ b/cmd/podman/varlink/io.projectatomic.podman.varlink
@@ -126,12 +126,9 @@ method ListContainers() -> (containers: []ListContainerData)
method GetContainer(name: string) -> (container: ListContainerData)
method CreateContainer() -> (notimplemented: NotImplemented)
method InspectContainer(name: string) -> (container: string)
-# TODO: Should this be made into a streaming response as opposed to a one off?
method ListContainerProcesses(name: string, opts: []string) -> (container: []string)
-# TODO: Should this be made into a streaming response as opposed to a one off?
method GetContainerLogs(name: string) -> (container: []string)
method ListContainerChanges(name: string) -> (container: [string]string)
-# TODO: This should be made into a streaming response
method ExportContainer(name: string, path: string) -> (tarfile: string)
method GetContainerStats(name: string) -> (container: ContainerStats)
method ResizeContainerTty() -> (notimplemented: NotImplemented)
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go
index ece33556b..79eea4aa7 100644
--- a/pkg/varlinkapi/containers.go
+++ b/pkg/varlinkapi/containers.go
@@ -4,8 +4,10 @@ import (
"bufio"
"encoding/json"
"fmt"
+ "io"
"os"
"syscall"
+ "time"
"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/batchcontainer"
@@ -117,6 +119,7 @@ func (i *LibpodAPI) ListContainerProcesses(call ioprojectatomicpodman.VarlinkCal
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
+
return call.ReplyListContainerProcesses(psOutput)
}
@@ -148,12 +151,36 @@ func (i *LibpodAPI) GetContainerLogs(call ioprojectatomicpodman.VarlinkCall, nam
}
defer file.Close()
reader := bufio.NewReader(file)
+ if call.WantsMore() {
+ call.Continues = true
+ }
for {
line, err := reader.ReadString('\n')
- if err != nil {
- break
+ // We've read the entire file
+ if err == io.EOF {
+ if !call.WantsMore() {
+ // If this is a non-following log request, we return what we have
+ break
+ } else {
+ // If we want to follow, return what we have, wipe the slice, and make
+ // sure the container is still running before iterating.
+ call.ReplyGetContainerLogs(logs)
+ logs = []string{}
+ time.Sleep(1 * time.Second)
+ state, err := ctr.State()
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ if state != libpod.ContainerStateRunning && state != libpod.ContainerStatePaused {
+ return call.ReplyErrorOccurred(fmt.Sprintf("%s is no longer running", ctr.ID()))
+ }
+
+ }
+ } else if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ } else {
+ logs = append(logs, line)
}
- logs = append(logs, line)
}
return call.ReplyGetContainerLogs(logs)
}
diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go
index 976dfc682..418db6445 100644
--- a/pkg/varlinkapi/system.go
+++ b/pkg/varlinkapi/system.go
@@ -1,7 +1,7 @@
package varlinkapi
import (
- ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
+ "github.com/projectatomic/libpod/cmd/podman/varlink"
"github.com/projectatomic/libpod/libpod"
)