| @@ -56,7 +56,7 @@ gotest.tools/v3                                     v3.0.2 | |||||||
| github.com/cilium/ebpf                              4032b1d8aae306b7bb94a2a11002932caf88c644 | github.com/cilium/ebpf                              4032b1d8aae306b7bb94a2a11002932caf88c644 | ||||||
|  |  | ||||||
| # cri dependencies | # cri dependencies | ||||||
| github.com/containerd/cri                           c744b66a3b655f140426f846cf64ef50ea8419c8 # master | github.com/containerd/cri                           8898550e348932e406049e937d98fb7564ac4e7a # master | ||||||
| github.com/davecgh/go-spew                          v1.1.1 | github.com/davecgh/go-spew                          v1.1.1 | ||||||
| github.com/docker/docker                            4634ce647cf2ce2c6031129ccd109e557244986f | github.com/docker/docker                            4634ce647cf2ce2c6031129ccd109e557244986f | ||||||
| github.com/docker/spdystream                        449fdfce4d962303d702fec724ef0ad181c92528 | github.com/docker/spdystream                        449fdfce4d962303d702fec724ef0ad181c92528 | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/config/config.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/config/config.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -52,6 +52,8 @@ type Runtime struct { | |||||||
| 	// PrivilegedWithoutHostDevices overloads the default behaviour for adding host devices to the | 	// PrivilegedWithoutHostDevices overloads the default behaviour for adding host devices to the | ||||||
| 	// runtime spec when the container is privileged. Defaults to false. | 	// runtime spec when the container is privileged. Defaults to false. | ||||||
| 	PrivilegedWithoutHostDevices bool `toml:"privileged_without_host_devices" json:"privileged_without_host_devices"` | 	PrivilegedWithoutHostDevices bool `toml:"privileged_without_host_devices" json:"privileged_without_host_devices"` | ||||||
|  | 	// BaseRuntimeSpec is a json file with OCI spec to use as base spec that all container's will be created from. | ||||||
|  | 	BaseRuntimeSpec string `toml:"base_runtime_spec" json:"baseRuntimeSpec"` | ||||||
| } | } | ||||||
|  |  | ||||||
| // ContainerdConfig contains toml config related to containerd | // ContainerdConfig contains toml config related to containerd | ||||||
|   | |||||||
							
								
								
									
										32
									
								
								vendor/github.com/containerd/cri/pkg/server/container_create.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/github.com/containerd/cri/pkg/server/container_create.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -297,12 +297,36 @@ func (c *criService) volumeMounts(containerRootDir string, criMounts []*runtime. | |||||||
| } | } | ||||||
|  |  | ||||||
| // runtimeSpec returns a default runtime spec used in cri-containerd. | // runtimeSpec returns a default runtime spec used in cri-containerd. | ||||||
| func runtimeSpec(id string, opts ...oci.SpecOpts) (*runtimespec.Spec, error) { | func (c *criService) runtimeSpec(id string, baseSpecFile string, opts ...oci.SpecOpts) (*runtimespec.Spec, error) { | ||||||
| 	// GenerateSpec needs namespace. | 	// GenerateSpec needs namespace. | ||||||
| 	ctx := ctrdutil.NamespacedContext() | 	ctx := ctrdutil.NamespacedContext() | ||||||
| 	spec, err := oci.GenerateSpec(ctx, nil, &containers.Container{ID: id}, opts...) | 	container := &containers.Container{ID: id} | ||||||
| 	if err != nil { |  | ||||||
| 		return nil, err | 	if baseSpecFile != "" { | ||||||
|  | 		baseSpec, ok := c.baseOCISpecs[baseSpecFile] | ||||||
|  | 		if !ok { | ||||||
|  | 			return nil, errors.Errorf("can't find base OCI spec %q", baseSpecFile) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		spec := oci.Spec{} | ||||||
|  | 		if err := util.DeepCopy(&spec, &baseSpec); err != nil { | ||||||
|  | 			return nil, errors.Wrap(err, "failed to clone OCI spec") | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// Fix up cgroups path | ||||||
|  | 		applyOpts := append([]oci.SpecOpts{oci.WithNamespacedCgroup()}, opts...) | ||||||
|  |  | ||||||
|  | 		if err := oci.ApplyOpts(ctx, nil, container, &spec, applyOpts...); err != nil { | ||||||
|  | 			return nil, errors.Wrap(err, "failed to apply OCI options") | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		return &spec, nil | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	spec, err := oci.GenerateSpec(ctx, nil, container, opts...) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, errors.Wrap(err, "failed to generate spec") | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return spec, nil | 	return spec, nil | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/server/container_create_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/server/container_create_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -262,7 +262,7 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3 | |||||||
| 				Type: runtimespec.CgroupNamespace, | 				Type: runtimespec.CgroupNamespace, | ||||||
| 			})) | 			})) | ||||||
| 	} | 	} | ||||||
| 	return runtimeSpec(id, specOpts...) | 	return c.runtimeSpec(id, ociRuntime.BaseRuntimeSpec, specOpts...) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (c *criService) containerSpecOpts(config *runtime.ContainerConfig, imageConfig *imagespec.ImageConfig) ([]oci.SpecOpts, error) { | func (c *criService) containerSpecOpts(config *runtime.ContainerConfig, imageConfig *imagespec.ImageConfig) ([]oci.SpecOpts, error) { | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								vendor/github.com/containerd/cri/pkg/server/container_create_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/containerd/cri/pkg/server/container_create_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -91,8 +91,7 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3 | |||||||
| 		customopts.WithAnnotation(annotations.SandboxID, sandboxID), | 		customopts.WithAnnotation(annotations.SandboxID, sandboxID), | ||||||
| 		customopts.WithAnnotation(annotations.ContainerName, containerName), | 		customopts.WithAnnotation(annotations.ContainerName, containerName), | ||||||
| 	) | 	) | ||||||
|  | 	return c.runtimeSpec(id, ociRuntime.BaseRuntimeSpec, specOpts...) | ||||||
| 	return runtimeSpec(id, specOpts...) |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // No extra spec options needed for windows. | // No extra spec options needed for windows. | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/server/sandbox_run_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/server/sandbox_run_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -156,7 +156,7 @@ func (c *criService) sandboxContainerSpec(id string, config *runtime.PodSandboxC | |||||||
| 		customopts.WithAnnotation(annotations.SandboxLogDir, config.GetLogDirectory()), | 		customopts.WithAnnotation(annotations.SandboxLogDir, config.GetLogDirectory()), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
| 	return runtimeSpec(id, specOpts...) | 	return c.runtimeSpec(id, "", specOpts...) | ||||||
| } | } | ||||||
|  |  | ||||||
| // sandboxContainerSpecOpts generates OCI spec options for | // sandboxContainerSpecOpts generates OCI spec options for | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/server/sandbox_run_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/cri/pkg/server/sandbox_run_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -67,7 +67,7 @@ func (c *criService) sandboxContainerSpec(id string, config *runtime.PodSandboxC | |||||||
| 		customopts.WithAnnotation(annotations.SandboxLogDir, config.GetLogDirectory()), | 		customopts.WithAnnotation(annotations.SandboxLogDir, config.GetLogDirectory()), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
| 	return runtimeSpec(id, specOpts...) | 	return c.runtimeSpec(id, "", specOpts...) | ||||||
| } | } | ||||||
|  |  | ||||||
| // No sandbox container spec options for windows yet. | // No sandbox container spec options for windows yet. | ||||||
|   | |||||||
							
								
								
									
										52
									
								
								vendor/github.com/containerd/cri/pkg/server/service.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								vendor/github.com/containerd/cri/pkg/server/service.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,15 +17,17 @@ | |||||||
| package server | package server | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"net/http" | 	"net/http" | ||||||
|  | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/containerd/containerd" | 	"github.com/containerd/containerd" | ||||||
|  | 	"github.com/containerd/containerd/oci" | ||||||
| 	"github.com/containerd/containerd/plugin" | 	"github.com/containerd/containerd/plugin" | ||||||
| 	"github.com/containerd/cri/pkg/store/label" |  | ||||||
| 	cni "github.com/containerd/go-cni" | 	cni "github.com/containerd/go-cni" | ||||||
| 	"github.com/pkg/errors" | 	"github.com/pkg/errors" | ||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
| @@ -33,6 +35,8 @@ import ( | |||||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" | 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" | ||||||
| 	"k8s.io/kubernetes/pkg/kubelet/server/streaming" | 	"k8s.io/kubernetes/pkg/kubelet/server/streaming" | ||||||
|  |  | ||||||
|  | 	"github.com/containerd/cri/pkg/store/label" | ||||||
|  |  | ||||||
| 	"github.com/containerd/cri/pkg/atomic" | 	"github.com/containerd/cri/pkg/atomic" | ||||||
| 	criconfig "github.com/containerd/cri/pkg/config" | 	criconfig "github.com/containerd/cri/pkg/config" | ||||||
| 	ctrdutil "github.com/containerd/cri/pkg/containerd/util" | 	ctrdutil "github.com/containerd/cri/pkg/containerd/util" | ||||||
| @@ -95,6 +99,8 @@ type criService struct { | |||||||
| 	// cniNetConfMonitor is used to reload cni network conf if there is | 	// cniNetConfMonitor is used to reload cni network conf if there is | ||||||
| 	// any valid fs change events from cni network conf dir. | 	// any valid fs change events from cni network conf dir. | ||||||
| 	cniNetConfMonitor *cniNetConfSyncer | 	cniNetConfMonitor *cniNetConfSyncer | ||||||
|  | 	// baseOCISpecs contains cached OCI specs loaded via `Runtime.BaseRuntimeSpec` | ||||||
|  | 	baseOCISpecs map[string]*oci.Spec | ||||||
| } | } | ||||||
|  |  | ||||||
| // NewCRIService returns a new instance of CRIService | // NewCRIService returns a new instance of CRIService | ||||||
| @@ -138,6 +144,12 @@ func NewCRIService(config criconfig.Config, client *containerd.Client) (CRIServi | |||||||
| 		return nil, errors.Wrap(err, "failed to create cni conf monitor") | 		return nil, errors.Wrap(err, "failed to create cni conf monitor") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// Preload base OCI specs | ||||||
|  | 	c.baseOCISpecs, err = loadBaseOCISpecs(&config) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return c, nil | 	return c, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -273,3 +285,41 @@ func (c *criService) register(s *grpc.Server) error { | |||||||
| func imageFSPath(rootDir, snapshotter string) string { | func imageFSPath(rootDir, snapshotter string) string { | ||||||
| 	return filepath.Join(rootDir, fmt.Sprintf("%s.%s", plugin.SnapshotPlugin, snapshotter)) | 	return filepath.Join(rootDir, fmt.Sprintf("%s.%s", plugin.SnapshotPlugin, snapshotter)) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func loadOCISpec(filename string) (*oci.Spec, error) { | ||||||
|  | 	file, err := os.Open(filename) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, errors.Wrapf(err, "failed to open base OCI spec: %s", filename) | ||||||
|  | 	} | ||||||
|  | 	defer file.Close() | ||||||
|  |  | ||||||
|  | 	spec := oci.Spec{} | ||||||
|  | 	if err := json.NewDecoder(file).Decode(&spec); err != nil { | ||||||
|  | 		return nil, errors.Wrap(err, "failed to parse base OCI spec file") | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return &spec, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func loadBaseOCISpecs(config *criconfig.Config) (map[string]*oci.Spec, error) { | ||||||
|  | 	specs := map[string]*oci.Spec{} | ||||||
|  | 	for _, cfg := range config.Runtimes { | ||||||
|  | 		if cfg.BaseRuntimeSpec == "" { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		// Don't load same file twice | ||||||
|  | 		if _, ok := specs[cfg.BaseRuntimeSpec]; ok { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		spec, err := loadOCISpec(cfg.BaseRuntimeSpec) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return nil, errors.Wrapf(err, "failed to load base OCI spec from file: %s", cfg.BaseRuntimeSpec) | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		specs[cfg.BaseRuntimeSpec] = spec | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return specs, nil | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Phil Estes
					Phil Estes