k3s/vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go

35 lines
999 B
Go
Raw Normal View History

2019-01-12 04:58:27 +00:00
package wclayer
import (
2020-08-10 17:43:49 +00:00
"context"
"strings"
2019-01-12 04:58:27 +00:00
"github.com/Microsoft/hcsshim/internal/hcserror"
2020-08-10 17:43:49 +00:00
"github.com/Microsoft/hcsshim/internal/oc"
"go.opencensus.io/trace"
2019-01-12 04:58:27 +00:00
)
// CreateScratchLayer creates and populates new read-write layer for use by a container.
// This requires the full list of paths to all parent layers up to the base
2020-08-10 17:43:49 +00:00
func CreateScratchLayer(ctx context.Context, path string, parentLayerPaths []string) (err error) {
2019-07-10 00:29:38 +00:00
title := "hcsshim::CreateScratchLayer"
2020-08-10 17:43:49 +00:00
ctx, span := trace.StartSpan(ctx, title)
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(
trace.StringAttribute("path", path),
trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", ")))
2019-01-12 04:58:27 +00:00
// Generate layer descriptors
2020-08-10 17:43:49 +00:00
layers, err := layerPathsToDescriptors(ctx, parentLayerPaths)
2019-01-12 04:58:27 +00:00
if err != nil {
return err
}
err = createSandboxLayer(&stdDriverInfo, path, 0, layers)
if err != nil {
2019-07-10 00:29:38 +00:00
return hcserror.New(err, title+" - failed", "")
2019-01-12 04:58:27 +00:00
}
return nil
}