shim: Add PullImage support

Add a new PullImage endpoint to the shim API.
Add new PullImage functions to the virtcontainers files, which allows
the PullImage endpoint on the agent to be called.
Update the containerd vendor files to support new PullImage API changes.

Fixes #2651

Signed-off-by: Dave Hay <david_hay@uk.ibm.com>
Co-authored-by: ashleyrobertson <ashleyro@uk.ibm.com>
Co-authored-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
Dave Hay
2021-10-12 04:00:10 -07:00
committed by stevenhorsman
parent 18834810e6
commit 02f6db595c
18 changed files with 996 additions and 452 deletions

View File

@@ -751,6 +751,32 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptyp
return empty, err
}
// Pull image and unbundle ready for container creation
func (s *service) PullImage(ctx context.Context, r *taskAPI.PullImageRequest) (_ *ptypes.Empty, err error) {
shimLog.WithField("id", r.ID).Debug("PullImage() start")
defer shimLog.WithField("id", r.ID).Debug("PullImage() end")
span, spanCtx := katatrace.Trace(s.rootCtx, shimLog, "PullImage", shimTracingTags)
defer span.End()
start := time.Now()
defer func() {
err = toGRPC(err)
rpcDurationsHistogram.WithLabelValues("pullimage").Observe(float64(time.Since(start).Nanoseconds() / int64(time.Millisecond)))
}()
s.mu.Lock()
defer s.mu.Unlock()
shimLog.WithFields(logrus.Fields{
"image": r.Image,
"new_container_id": r.NewContainerID,
}).Debug("Making image pull request")
err = s.sandbox.PullImage(spanCtx, r.Image, r.NewContainerID)
return empty, err
}
// Kill a process with the provided signal
func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *ptypes.Empty, err error) {
shimLog.WithField("container", r.ID).Debug("Kill() start")