mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
podman-varlink: log timeouts
The default timeout of one second when using podman-varlink can confuse users as podman exits in silence after this timeout in case no connection to the endpoint is alive. Print a log (info level) that the varlink service has expired to guide the user. This change requires to vendor in the latest master of varlink/go. Signed-off-by: Valentin Rothberg <vrothberg@suse.com> Closes: #899 Approved by: rhatdan
This commit is contained in:

committed by
Atomic Bot

parent
03cf4ac60a
commit
7965bf5404
@ -7,6 +7,7 @@ import (
|
||||
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/pkg/varlinkapi"
|
||||
"github.com/projectatomic/libpod/version"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/varlink/go/varlink"
|
||||
)
|
||||
@ -62,8 +63,14 @@ func varlinkCmd(c *cli.Context) error {
|
||||
|
||||
// Run the varlink server at the given address
|
||||
if err = service.Listen(args[0], timeout); err != nil {
|
||||
switch err.(type) {
|
||||
case varlink.ServiceTimeoutError:
|
||||
logrus.Infof("varlink service expired (use --timeout to increase session time beyond %d ms)", c.Int64("timeout"))
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("unable to start varlink service")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
97
vendor/github.com/containers/storage/pkg/archive/example_changes.go
generated
vendored
97
vendor/github.com/containers/storage/pkg/archive/example_changes.go
generated
vendored
@ -1,97 +0,0 @@
|
||||
// +build ignore
|
||||
|
||||
// Simple tool to create an archive stream from an old and new directory
|
||||
//
|
||||
// By default it will stream the comparison of two temporary directories with junk files
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
flDebug = flag.Bool("D", false, "debugging output")
|
||||
flNewDir = flag.String("newdir", "", "")
|
||||
flOldDir = flag.String("olddir", "", "")
|
||||
log = logrus.New()
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Usage = func() {
|
||||
fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)")
|
||||
fmt.Printf("%s [OPTIONS]\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
flag.Parse()
|
||||
log.Out = os.Stderr
|
||||
if (len(os.Getenv("DEBUG")) > 0) || *flDebug {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
var newDir, oldDir string
|
||||
|
||||
if len(*flNewDir) == 0 {
|
||||
var err error
|
||||
newDir, err = ioutil.TempDir("", "storage-test-newDir")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(newDir)
|
||||
if _, err := prepareUntarSourceDirectory(100, newDir, true); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
newDir = *flNewDir
|
||||
}
|
||||
|
||||
if len(*flOldDir) == 0 {
|
||||
oldDir, err := ioutil.TempDir("", "storage-test-oldDir")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(oldDir)
|
||||
} else {
|
||||
oldDir = *flOldDir
|
||||
}
|
||||
|
||||
changes, err := archive.ChangesDirs(newDir, oldDir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
a, err := archive.ExportChanges(newDir, changes)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer a.Close()
|
||||
|
||||
i, err := io.Copy(os.Stdout, a)
|
||||
if err != nil && err != io.EOF {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "wrote archive of %d bytes", i)
|
||||
}
|
||||
|
||||
func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks bool) (int, error) {
|
||||
fileData := []byte("fooo")
|
||||
for n := 0; n < numberOfFiles; n++ {
|
||||
fileName := fmt.Sprintf("file-%d", n)
|
||||
if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if makeLinks {
|
||||
if err := os.Link(path.Join(targetPath, fileName), path.Join(targetPath, fileName+"-link")); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
}
|
||||
totalSize := numberOfFiles * len(fileData)
|
||||
return totalSize, nil
|
||||
}
|
9
vendor/github.com/varlink/go/varlink/service.go
generated
vendored
9
vendor/github.com/varlink/go/varlink/service.go
generated
vendored
@ -51,6 +51,13 @@ type Service struct {
|
||||
address string
|
||||
}
|
||||
|
||||
// ServiceTimoutError helps API users to special-case timeouts.
|
||||
type ServiceTimeoutError struct {}
|
||||
|
||||
func (ServiceTimeoutError) Error() string {
|
||||
return "service timeout"
|
||||
}
|
||||
|
||||
func (s *Service) getInfo(c Call) error {
|
||||
return c.replyGetInfo(s.vendor, s.product, s.version, s.url, s.names)
|
||||
}
|
||||
@ -297,7 +304,7 @@ func (s *Service) Listen(address string, timeout time.Duration) error {
|
||||
s.mutex.Lock()
|
||||
if s.conncounter == 0 {
|
||||
s.mutex.Unlock()
|
||||
return nil
|
||||
return ServiceTimeoutError{}
|
||||
}
|
||||
s.mutex.Unlock()
|
||||
continue
|
||||
|
Reference in New Issue
Block a user