mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
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:
@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
|
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||||
"github.com/projectatomic/libpod/pkg/varlinkapi"
|
"github.com/projectatomic/libpod/pkg/varlinkapi"
|
||||||
@ -15,7 +17,13 @@ var (
|
|||||||
|
|
||||||
run varlink interface
|
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{
|
varlinkCommand = cli.Command{
|
||||||
Name: "varlink",
|
Name: "varlink",
|
||||||
Usage: "Run varlink interface",
|
Usage: "Run varlink interface",
|
||||||
@ -31,6 +39,7 @@ func varlinkCmd(c *cli.Context) error {
|
|||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return errors.Errorf("you must provide a varlink URI")
|
return errors.Errorf("you must provide a varlink URI")
|
||||||
}
|
}
|
||||||
|
timeout := time.Duration(c.Int64("timeout")) * time.Millisecond
|
||||||
|
|
||||||
var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.New(c)}
|
var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.New(c)}
|
||||||
// Register varlink service. The metadata can be retrieved with:
|
// 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
|
// 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")
|
return errors.Errorf("unable to start varlink service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1652,6 +1652,7 @@ _podman_unpause() {
|
|||||||
_podman_varlink() {
|
_podman_varlink() {
|
||||||
local options_with_args="
|
local options_with_args="
|
||||||
--help -h
|
--help -h
|
||||||
|
--timeout -t
|
||||||
"
|
"
|
||||||
local boolean_options=""
|
local boolean_options=""
|
||||||
_complete_ "$options_with_args" "$boolean_options"
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
|
@ -98,7 +98,7 @@ $PODMAN --version
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
# Run podman in background without systemd for test purposes
|
# 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
|
if [[ -z $1 ]]; then
|
||||||
export PYTHONPATH=.
|
export PYTHONPATH=.
|
||||||
|
@ -6,34 +6,43 @@
|
|||||||
podman\-varlink - Runs the varlink backend interface
|
podman\-varlink - Runs the varlink backend interface
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman varlink**
|
**podman varlink** [OPTIONS]
|
||||||
[**--help**|**-h**]
|
[**--help**|**-h**]
|
||||||
VARLINK_URI
|
VARLINK_URI
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
Starts the varlink service that allows varlink clients to interact with podman.
|
Starts the varlink service that allows varlink clients to interact with podman. This should generally be done
|
||||||
<!--
|
with systemd. See _Configuration_ below.
|
||||||
More will go here as the docs and api firm up.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**podman [GLOBAL OPTIONS] varlink **
|
**podman [GLOBAL OPTIONS] [OPTIONS] varlink VARLINK_URI**
|
||||||
|
|
||||||
## GLOBAL OPTIONS
|
## GLOBAL OPTIONS
|
||||||
|
|
||||||
**--help, -h**
|
**--help, -h**
|
||||||
Print usage statement
|
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
|
## EXAMPLES
|
||||||
|
|
||||||
podman varlink unix:/run/podman/io.projectatomic.podman
|
Run the podman varlink service manually and accept the default timeout.
|
||||||
<!--
|
|
||||||
TODO: More examples with TCP can be added when that works
|
```
|
||||||
as well.
|
$ 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
|
## 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
|
You can do this via systemctl
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user