From 02a3007397c6b7e636b9e97ccd2207cd24c269a5 Mon Sep 17 00:00:00 2001 From: "YiLin.Li" Date: Mon, 7 Sep 2020 13:00:29 +0000 Subject: [PATCH] shim/runtime: Store inclavare-containers configuration Signed-off-by: Yilin Li --- shim/runtime/v2/rune/v2/service.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/shim/runtime/v2/rune/v2/service.go b/shim/runtime/v2/rune/v2/service.go index 691639e..cd2bde9 100644 --- a/shim/runtime/v2/rune/v2/service.go +++ b/shim/runtime/v2/rune/v2/service.go @@ -93,6 +93,7 @@ func New(ctx context.Context, id string, publisher shim.Publisher, shutdown func ep: ep, cancel: shutdown, containers: make(map[string]*runc.Container), + config: make(map[string]*containerConfiguration), } go s.processExits() runcC.Monitor = reaper.Default @@ -104,6 +105,11 @@ func New(ctx context.Context, id string, publisher shim.Publisher, shutdown func return s, nil } +type containerConfiguration struct { + binary string + root string +} + // service is the shim implementation of a remote shim over GRPC type service struct { mu sync.Mutex @@ -119,6 +125,7 @@ type service struct { id string containers map[string]*runc.Container + config map[string]*containerConfiguration cancel func() } @@ -374,7 +381,26 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ * //go attestation.Attestation_main(ctx, result) } + ns, err := namespaces.NamespaceRequired(ctx) + if err != nil { + return nil, err + } + + var runeRootGlobalOption string = process.RuncRoot + if opts.Root != "" { + runeRootGlobalOption = opts.Root + } + runeRootGlobalOption = filepath.Join(runeRootGlobalOption, ns) + + config := &containerConfiguration{ + binary: opts.BinaryName, + root: runeRootGlobalOption, + } s.containers[r.ID] = container + s.config[r.ID] = config + + logrus.Infof("s.config[%v] = %v", r.ID, s.config[r.ID]) + s.send(&eventstypes.TaskCreate{ ContainerID: r.ID, Bundle: r.Bundle, -- GitLab