Make one runtime for the varlink service

Rather than making a runtime each time a client hits a varlink endpoint, we now
make a single runtime when the varlink service starts up.  This fixes a problem
where we hit a max inotify limit from CNI.

Resolves: #1211

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

Closes: #1215
Approved by: rhatdan
This commit is contained in:
baude
2018-08-04 10:12:27 -05:00
committed by Atomic Bot
parent debf23c72a
commit a1e3e542ff
6 changed files with 57 additions and 186 deletions

View File

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/signal"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/projectatomic/libpod/cmd/podman/varlink"
"github.com/projectatomic/libpod/libpod"
"github.com/projectatomic/libpod/libpod/image"
@ -22,22 +21,16 @@ import (
// CreateContainer ...
func (i *LibpodAPI) CreateContainer(call ioprojectatomicpodman.VarlinkCall, config ioprojectatomicpodman.Create) error {
runtime, err := libpodruntime.GetRuntime(i.Cli)
if err != nil {
return call.ReplyRuntimeError(err.Error())
}
defer runtime.Shutdown(false)
rtc := runtime.GetConfig()
rtc := i.Runtime.GetConfig()
ctx := getContext()
newImage, err := runtime.ImageRuntime().New(ctx, config.Image, rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
newImage, err := i.Runtime.ImageRuntime().New(ctx, config.Image, rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
data, err := newImage.Inspect(ctx)
createConfig, err := varlinkCreateToCreateConfig(ctx, config, runtime, config.Image, data)
createConfig, err := varlinkCreateToCreateConfig(ctx, config, i.Runtime, config.Image, data)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
@ -47,12 +40,12 @@ func (i *LibpodAPI) CreateContainer(call ioprojectatomicpodman.VarlinkCall, conf
return call.ReplyErrorOccurred(err.Error())
}
options, err := createConfig.GetContainerCreateOptions(runtime)
options, err := createConfig.GetContainerCreateOptions(i.Runtime)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)
ctr, err := i.Runtime.NewContainer(ctx, runtimeSpec, options...)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}