set varlink timeout to 1 seconds

Add option to varlink for --timeout.  Input for this option is in milliseconds

Signed-off-by: baude <bbaude@redhat.com>

Closes: #814
Approved by: baude
This commit is contained in:
baude
2018-05-21 09:17:02 -05:00
committed by Atomic Bot
parent 82feafecdd
commit ae7c45968d
4 changed files with 34 additions and 15 deletions

View File

@ -1,6 +1,8 @@
package main
import (
"time"
"github.com/pkg/errors"
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
"github.com/projectatomic/libpod/pkg/varlinkapi"
@ -15,7 +17,13 @@ var (
run varlink interface
`
varlinkFlags = []cli.Flag{}
varlinkFlags = []cli.Flag{
cli.IntFlag{
Name: "timeout, t",
Usage: "time until the varlink session expires in milliseconds. default is 1 second; 0 means no timeout.",
Value: 1000,
},
}
varlinkCommand = cli.Command{
Name: "varlink",
Usage: "Run varlink interface",
@ -31,6 +39,7 @@ func varlinkCmd(c *cli.Context) error {
if len(args) < 1 {
return errors.Errorf("you must provide a varlink URI")
}
timeout := time.Duration(c.Int64("timeout")) * time.Millisecond
var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.New(c)}
// Register varlink service. The metadata can be retrieved with:
@ -52,7 +61,7 @@ func varlinkCmd(c *cli.Context) error {
}
// Run the varlink server at the given address
if err = service.Listen(args[0], 0); err != nil {
if err = service.Listen(args[0], timeout); err != nil {
return errors.Errorf("unable to start varlink service")
}

View File

@ -1652,6 +1652,7 @@ _podman_unpause() {
_podman_varlink() {
local options_with_args="
--help -h
--timeout -t
"
local boolean_options=""
_complete_ "$options_with_args" "$boolean_options"

View File

@ -98,7 +98,7 @@ $PODMAN --version
set -x
# Run podman in background without systemd for test purposes
$PODMAN varlink ${PODMAN_HOST} >/tmp/test_runner.output 2>&1 &
$PODMAN --timeout 0 varlink ${PODMAN_HOST} >/tmp/test_runner.output 2>&1 &
if [[ -z $1 ]]; then
export PYTHONPATH=.

View File

@ -6,34 +6,43 @@
podman\-varlink - Runs the varlink backend interface
## SYNOPSIS
**podman varlink**
**podman varlink** [OPTIONS]
[**--help**|**-h**]
VARLINK_URI
## DESCRIPTION
Starts the varlink service that allows varlink clients to interact with podman.
<!--
More will go here as the docs and api firm up.
-->
Starts the varlink service that allows varlink clients to interact with podman. This should generally be done
with systemd. See _Configuration_ below.
**podman [GLOBAL OPTIONS] varlink **
**podman [GLOBAL OPTIONS] [OPTIONS] varlink VARLINK_URI**
## GLOBAL OPTIONS
**--help, -h**
Print usage statement
## OPTIONS
**--timeout, -t** The time until the varlink session expires in _milliseconds_. The default is 1
second. A value of `0` means no timeout and the session will not expire.
## EXAMPLES
podman varlink unix:/run/podman/io.projectatomic.podman
<!--
TODO: More examples with TCP can be added when that works
as well.
-->
Run the podman varlink service manually and accept the default timeout.
```
$ podman varlink unix:/run/podman/io.projectatomic.podman
```
Run the podman varlink service manually with a 5 second timeout.
```
$ podman varlink --timeout 5000 unix:/run/podman/io.projectatomic.podman
```
## CONFIGURATION
Users of the podman varlink service should enable the io.projectatomic.podman.socket and io.projectatomic.podman.service.
Users of the podman varlink service should enable the _io.projectatomic.podman.socket_ and _io.projectatomic.podman.service_.
This is the preferred method for running the varlink service.
You can do this via systemctl