Update cri to f1d492b0cd.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
10
vendor/github.com/containerd/cri/README.md
generated
vendored
10
vendor/github.com/containerd/cri/README.md
generated
vendored
@@ -41,14 +41,16 @@ See [test dashboard](https://k8s-testgrid.appspot.com/sig-node-containerd)
|
||||
|
||||
**Note:** The support table above specifies the Kubernetes Version that was supported at time of release of the containerd - cri integration.
|
||||
|
||||
The following is the current support table for containerd CRI integration taking into account that Kubernetes only supports n-3 minor release versions and 1.10 is now end-of-life.
|
||||
The following is the current support table for containerd CRI integration taking into account that Kubernetes only supports n-3 minor release versions and 1.10 and 1.11 are now end-of-life.
|
||||
|
||||
| Containerd Version | Kubernetes Version | CRI Version |
|
||||
|:------------------:|:------------------:|:-----------:|
|
||||
| v1.1 | 1.11+ | v1alpha2 |
|
||||
| v1.2 | 1.11+ | v1alpha2 |
|
||||
| HEAD | 1.11+ | v1alpha2 |
|
||||
| v1.1 | 1.12+ | v1alpha2 |
|
||||
| v1.2 | 1.12+ | v1alpha2 |
|
||||
| HEAD | 1.12+ | v1alpha2 |
|
||||
|
||||
***Although not recommended, if you still plan to use containerd 1.2+ with Kubernetes
|
||||
<=1.11, please be sure to set `disable_proc_mount=true`.***
|
||||
|
||||
## Production Quality Cluster on GCE
|
||||
For a production quality cluster on GCE brought up with `kube-up.sh` refer [here](docs/kube-up.md).
|
||||
|
||||
67
vendor/github.com/containerd/cri/cri.go
generated
vendored
67
vendor/github.com/containerd/cri/cri.go
generated
vendored
@@ -17,10 +17,8 @@ limitations under the License.
|
||||
package cri
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/api/services/containers/v1"
|
||||
@@ -74,8 +72,8 @@ func initCRIService(ic *plugin.InitContext) (interface{}, error) {
|
||||
}
|
||||
log.G(ctx).Infof("Start cri plugin with config %+v", c)
|
||||
|
||||
if err := validateConfig(ctx, &c); err != nil {
|
||||
return nil, errors.Wrap(err, "invalid config")
|
||||
if err := criconfig.ValidatePluginConfig(ctx, pluginConfig); err != nil {
|
||||
return nil, errors.Wrap(err, "invalid plugin config")
|
||||
}
|
||||
|
||||
if err := setGLogLevel(); err != nil {
|
||||
@@ -111,67 +109,6 @@ func initCRIService(ic *plugin.InitContext) (interface{}, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// validateConfig validates the given configuration.
|
||||
func validateConfig(ctx context.Context, c *criconfig.Config) error {
|
||||
if c.ContainerdConfig.Runtimes == nil {
|
||||
c.ContainerdConfig.Runtimes = make(map[string]criconfig.Runtime)
|
||||
}
|
||||
|
||||
// Validation for deprecated untrusted_workload_runtime.
|
||||
if c.ContainerdConfig.UntrustedWorkloadRuntime.Type != "" {
|
||||
log.G(ctx).Warning("`untrusted_workload_runtime` is deprecated, please use `untrusted` runtime in `runtimes` instead")
|
||||
if _, ok := c.ContainerdConfig.Runtimes[criconfig.RuntimeUntrusted]; ok {
|
||||
return errors.Errorf("conflicting definitions: configuration includes both `untrusted_workload_runtime` and `runtimes[%q]`", criconfig.RuntimeUntrusted)
|
||||
}
|
||||
c.ContainerdConfig.Runtimes[criconfig.RuntimeUntrusted] = c.ContainerdConfig.UntrustedWorkloadRuntime
|
||||
}
|
||||
|
||||
// Validation for deprecated default_runtime field.
|
||||
if c.ContainerdConfig.DefaultRuntime.Type != "" {
|
||||
log.G(ctx).Warning("`default_runtime` is deprecated, please use `default_runtime_name` to reference the default configuration you have defined in `runtimes`")
|
||||
c.ContainerdConfig.DefaultRuntimeName = criconfig.RuntimeDefault
|
||||
c.ContainerdConfig.Runtimes[criconfig.RuntimeDefault] = c.ContainerdConfig.DefaultRuntime
|
||||
}
|
||||
|
||||
// Validation for default_runtime_name
|
||||
if c.ContainerdConfig.DefaultRuntimeName == "" {
|
||||
return errors.New("`default_runtime_name` is empty")
|
||||
}
|
||||
if _, ok := c.ContainerdConfig.Runtimes[c.ContainerdConfig.DefaultRuntimeName]; !ok {
|
||||
return errors.New("no corresponding runtime configured in `runtimes` for `default_runtime_name`")
|
||||
}
|
||||
|
||||
// Validation for deprecated runtime options.
|
||||
if c.SystemdCgroup {
|
||||
if c.ContainerdConfig.Runtimes[c.ContainerdConfig.DefaultRuntimeName].Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`systemd_cgroup` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
log.G(ctx).Warning("`systemd_cgroup` is deprecated, please use runtime `options` instead")
|
||||
}
|
||||
for _, r := range c.ContainerdConfig.Runtimes {
|
||||
if r.Engine != "" {
|
||||
if r.Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`runtime_engine` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
log.G(ctx).Warning("`runtime_engine` is deprecated, please use runtime `options` instead")
|
||||
}
|
||||
if r.Root != "" {
|
||||
if r.Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`runtime_root` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
log.G(ctx).Warning("`runtime_root` is deprecated, please use runtime `options` instead")
|
||||
}
|
||||
}
|
||||
|
||||
// Validation for stream_idle_timeout
|
||||
if c.StreamIdleTimeout != "" {
|
||||
if _, err := time.ParseDuration(c.StreamIdleTimeout); err != nil {
|
||||
return errors.Wrap(err, "invalid stream idle timeout")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// getServicesOpts get service options from plugin context.
|
||||
func getServicesOpts(ic *plugin.InitContext) ([]containerd.ServicesOpt, error) {
|
||||
plugins, err := ic.GetByType(plugin.ServicePlugin)
|
||||
|
||||
107
vendor/github.com/containerd/cri/pkg/config/config.go
generated
vendored
107
vendor/github.com/containerd/cri/pkg/config/config.go
generated
vendored
@@ -17,8 +17,14 @@ limitations under the License.
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server/streaming"
|
||||
)
|
||||
|
||||
@@ -41,6 +47,9 @@ type Runtime struct {
|
||||
// Options are config options for the runtime. If options is loaded
|
||||
// from toml config, it will be toml.Primitive.
|
||||
Options *toml.Primitive `toml:"options" json:"options"`
|
||||
// PrivilegedWithoutHostDevices overloads the default behaviour for adding host devices to the
|
||||
// runtime spec when the container is privileged. Defaults to false.
|
||||
PrivilegedWithoutHostDevices bool `toml:"privileged_without_host_devices" json:"privileged_without_host_devices"`
|
||||
}
|
||||
|
||||
// ContainerdConfig contains toml config related to containerd
|
||||
@@ -61,7 +70,6 @@ type ContainerdConfig struct {
|
||||
Runtimes map[string]Runtime `toml:"runtimes" json:"runtimes"`
|
||||
// NoPivot disables pivot-root (linux only), required when running a container in a RamDisk with runc
|
||||
// This only works for runtime type "io.containerd.runtime.v1.linux".
|
||||
// DEPRECATED: use Runtime.Options instead. Remove when shim v1 is deprecated.
|
||||
NoPivot bool `toml:"no_pivot" json:"noPivot"`
|
||||
}
|
||||
|
||||
@@ -93,6 +101,7 @@ type Mirror struct {
|
||||
// Endpoints are endpoints for a namespace. CRI plugin will try the endpoints
|
||||
// one by one until a working one is found. The endpoint must be a valid url
|
||||
// with host specified.
|
||||
// The scheme, host and path from the endpoint URL will be used.
|
||||
Endpoints []string `toml:"endpoint" json:"endpoint"`
|
||||
}
|
||||
|
||||
@@ -121,12 +130,23 @@ type TLSConfig struct {
|
||||
type Registry struct {
|
||||
// Mirrors are namespace to mirror mapping for all namespaces.
|
||||
Mirrors map[string]Mirror `toml:"mirrors" json:"mirrors"`
|
||||
// Configs are configs for each registry.
|
||||
// The key is the FDQN or IP of the registry.
|
||||
Configs map[string]RegistryConfig `toml:"configs" json:"configs"`
|
||||
|
||||
// Auths are registry endpoint to auth config mapping. The registry endpoint must
|
||||
// be a valid url with host specified.
|
||||
// DEPRECATED: Use Configs instead. Remove in containerd 1.4.
|
||||
Auths map[string]AuthConfig `toml:"auths" json:"auths"`
|
||||
// TLSConfigs are pairs of CA/Cert/Key which then are used when creating the transport
|
||||
}
|
||||
|
||||
// RegistryConfig contains configuration used to communicate with the registry.
|
||||
type RegistryConfig struct {
|
||||
// Auth contains information to authenticate to the registry.
|
||||
Auth *AuthConfig `toml:"auth" json:"auth"`
|
||||
// TLS is a pair of CA/Cert/Key which then are used when creating the transport
|
||||
// that communicates with the registry.
|
||||
TLSConfigs map[string]TLSConfig `toml:"tls_configs" json:"tlsConfigs"`
|
||||
TLS *TLSConfig `toml:"tls" json:"tls"`
|
||||
}
|
||||
|
||||
// PluginConfig contains toml config related to CRI plugin,
|
||||
@@ -258,3 +278,84 @@ const (
|
||||
// RuntimeDefault is the implicit runtime defined for ContainerdConfig.DefaultRuntime
|
||||
RuntimeDefault = "default"
|
||||
)
|
||||
|
||||
// ValidatePluginConfig validates the given plugin configuration.
|
||||
func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
|
||||
if c.ContainerdConfig.Runtimes == nil {
|
||||
c.ContainerdConfig.Runtimes = make(map[string]Runtime)
|
||||
}
|
||||
|
||||
// Validation for deprecated untrusted_workload_runtime.
|
||||
if c.ContainerdConfig.UntrustedWorkloadRuntime.Type != "" {
|
||||
log.G(ctx).Warning("`untrusted_workload_runtime` is deprecated, please use `untrusted` runtime in `runtimes` instead")
|
||||
if _, ok := c.ContainerdConfig.Runtimes[RuntimeUntrusted]; ok {
|
||||
return errors.Errorf("conflicting definitions: configuration includes both `untrusted_workload_runtime` and `runtimes[%q]`", RuntimeUntrusted)
|
||||
}
|
||||
c.ContainerdConfig.Runtimes[RuntimeUntrusted] = c.ContainerdConfig.UntrustedWorkloadRuntime
|
||||
}
|
||||
|
||||
// Validation for deprecated default_runtime field.
|
||||
if c.ContainerdConfig.DefaultRuntime.Type != "" {
|
||||
log.G(ctx).Warning("`default_runtime` is deprecated, please use `default_runtime_name` to reference the default configuration you have defined in `runtimes`")
|
||||
c.ContainerdConfig.DefaultRuntimeName = RuntimeDefault
|
||||
c.ContainerdConfig.Runtimes[RuntimeDefault] = c.ContainerdConfig.DefaultRuntime
|
||||
}
|
||||
|
||||
// Validation for default_runtime_name
|
||||
if c.ContainerdConfig.DefaultRuntimeName == "" {
|
||||
return errors.New("`default_runtime_name` is empty")
|
||||
}
|
||||
if _, ok := c.ContainerdConfig.Runtimes[c.ContainerdConfig.DefaultRuntimeName]; !ok {
|
||||
return errors.New("no corresponding runtime configured in `runtimes` for `default_runtime_name`")
|
||||
}
|
||||
|
||||
// Validation for deprecated runtime options.
|
||||
if c.SystemdCgroup {
|
||||
if c.ContainerdConfig.Runtimes[c.ContainerdConfig.DefaultRuntimeName].Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`systemd_cgroup` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
log.G(ctx).Warning("`systemd_cgroup` is deprecated, please use runtime `options` instead")
|
||||
}
|
||||
if c.NoPivot {
|
||||
if c.ContainerdConfig.Runtimes[c.ContainerdConfig.DefaultRuntimeName].Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`no_pivot` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
// NoPivot can't be deprecated yet, because there is no alternative config option
|
||||
// for `io.containerd.runtime.v1.linux`.
|
||||
}
|
||||
for _, r := range c.ContainerdConfig.Runtimes {
|
||||
if r.Engine != "" {
|
||||
if r.Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`runtime_engine` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
log.G(ctx).Warning("`runtime_engine` is deprecated, please use runtime `options` instead")
|
||||
}
|
||||
if r.Root != "" {
|
||||
if r.Type != plugin.RuntimeLinuxV1 {
|
||||
return errors.Errorf("`runtime_root` only works for runtime %s", plugin.RuntimeLinuxV1)
|
||||
}
|
||||
log.G(ctx).Warning("`runtime_root` is deprecated, please use runtime `options` instead")
|
||||
}
|
||||
}
|
||||
|
||||
// Validation for deprecated auths options and mapping it to configs.
|
||||
if len(c.Registry.Auths) != 0 {
|
||||
if c.Registry.Configs == nil {
|
||||
c.Registry.Configs = make(map[string]RegistryConfig)
|
||||
}
|
||||
for endpoint, auth := range c.Registry.Auths {
|
||||
config := c.Registry.Configs[endpoint]
|
||||
config.Auth = &auth
|
||||
c.Registry.Configs[endpoint] = config
|
||||
}
|
||||
log.G(ctx).Warning("`auths` is deprecated, please use registry`configs` instead")
|
||||
}
|
||||
|
||||
// Validation for stream_idle_timeout
|
||||
if c.StreamIdleTimeout != "" {
|
||||
if _, err := time.ParseDuration(c.StreamIdleTimeout); err != nil {
|
||||
return errors.Wrap(err, "invalid stream idle timeout")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
4
vendor/github.com/containerd/cri/pkg/containerd/opts/container.go
generated
vendored
4
vendor/github.com/containerd/cri/pkg/containerd/opts/container.go
generated
vendored
@@ -25,10 +25,10 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/continuity/fs"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// WithNewSnapshot wraps `containerd.WithNewSnapshot` so that if creating the
|
||||
@@ -80,7 +80,7 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
|
||||
}
|
||||
defer func() {
|
||||
if uerr := mount.Unmount(root, 0); uerr != nil {
|
||||
logrus.WithError(uerr).Errorf("Failed to unmount snapshot %q", c.SnapshotKey)
|
||||
log.G(ctx).WithError(uerr).Errorf("Failed to unmount snapshot %q", c.SnapshotKey)
|
||||
if err == nil {
|
||||
err = uerr
|
||||
}
|
||||
|
||||
10
vendor/github.com/containerd/cri/pkg/containerd/opts/spec.go
generated
vendored
10
vendor/github.com/containerd/cri/pkg/containerd/opts/spec.go
generated
vendored
@@ -27,18 +27,20 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/oci"
|
||||
osinterface "github.com/containerd/cri/pkg/os"
|
||||
"github.com/containerd/cri/pkg/util"
|
||||
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/opencontainers/runc/libcontainer/devices"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
osinterface "github.com/containerd/cri/pkg/os"
|
||||
"github.com/containerd/cri/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -250,7 +252,7 @@ func WithMounts(osi osinterface.OS, config *runtime.ContainerConfig, extra []*ru
|
||||
s.Linux.RootfsPropagation = "rslave"
|
||||
}
|
||||
default:
|
||||
logrus.Warnf("Unknown propagation mode for hostPath %q", mount.HostPath)
|
||||
log.G(ctx).Warnf("Unknown propagation mode for hostPath %q", mount.HostPath)
|
||||
options = append(options, "rprivate")
|
||||
}
|
||||
|
||||
|
||||
29
vendor/github.com/containerd/cri/pkg/log/log.go
generated
vendored
29
vendor/github.com/containerd/cri/pkg/log/log.go
generated
vendored
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package log
|
||||
|
||||
import "github.com/containerd/containerd/log"
|
||||
|
||||
// Trace logs a message at level Trace on the standard logger.
|
||||
func Trace(args ...interface{}) {
|
||||
log.Trace(log.L, args...)
|
||||
}
|
||||
|
||||
// Tracef logs a message at level Trace on the standard logger.
|
||||
func Tracef(format string, args ...interface{}) {
|
||||
log.Tracef(log.L, format, args...)
|
||||
}
|
||||
4
vendor/github.com/containerd/cri/pkg/server/container_attach.go
generated
vendored
4
vendor/github.com/containerd/cri/pkg/server/container_attach.go
generated
vendored
@@ -20,8 +20,8 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
@@ -62,7 +62,7 @@ func (c *criService) attachContainer(ctx context.Context, id string, stdin io.Re
|
||||
}
|
||||
handleResizing(resize, func(size remotecommand.TerminalSize) {
|
||||
if err := task.Resize(ctx, uint32(size.Width), uint32(size.Height)); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to resize task %q console", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to resize task %q console", id)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
79
vendor/github.com/containerd/cri/pkg/server/container_create.go
generated
vendored
79
vendor/github.com/containerd/cri/pkg/server/container_create.go
generated
vendored
@@ -26,22 +26,22 @@ import (
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/contrib/apparmor"
|
||||
"github.com/containerd/containerd/contrib/seccomp"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/containerd/cri/pkg/annotations"
|
||||
"github.com/containerd/cri/pkg/config"
|
||||
customopts "github.com/containerd/cri/pkg/containerd/opts"
|
||||
ctrdutil "github.com/containerd/cri/pkg/containerd/util"
|
||||
cio "github.com/containerd/cri/pkg/server/io"
|
||||
containerstore "github.com/containerd/cri/pkg/store/container"
|
||||
"github.com/containerd/cri/pkg/util"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -67,7 +67,7 @@ func init() {
|
||||
// CreateContainer creates a new container in the given PodSandbox.
|
||||
func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (_ *runtime.CreateContainerResponse, retErr error) {
|
||||
config := r.GetConfig()
|
||||
logrus.Debugf("Container config %+v", config)
|
||||
log.G(ctx).Debugf("Container config %+v", config)
|
||||
sandboxConfig := r.GetSandboxConfig()
|
||||
sandbox, err := c.sandboxStore.Get(r.GetPodSandboxId())
|
||||
if err != nil {
|
||||
@@ -89,7 +89,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
return nil, errors.New("container config must include metadata")
|
||||
}
|
||||
name := makeContainerName(metadata, sandboxConfig.GetMetadata())
|
||||
logrus.Debugf("Generated id %q for container %q", id, name)
|
||||
log.G(ctx).Debugf("Generated id %q for container %q", id, name)
|
||||
if err = c.containerNameIndex.Reserve(name, id); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to reserve container name %q", name)
|
||||
}
|
||||
@@ -135,7 +135,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
if retErr != nil {
|
||||
// Cleanup the container root directory.
|
||||
if err = c.os.RemoveAll(containerRootDir); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to remove container root directory %q",
|
||||
log.G(ctx).WithError(err).Errorf("Failed to remove container root directory %q",
|
||||
containerRootDir)
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
if retErr != nil {
|
||||
// Cleanup the volatile container root directory.
|
||||
if err = c.os.RemoveAll(volatileContainerRootDir); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to remove volatile container root directory %q",
|
||||
log.G(ctx).WithError(err).Errorf("Failed to remove volatile container root directory %q",
|
||||
volatileContainerRootDir)
|
||||
}
|
||||
}
|
||||
@@ -165,15 +165,15 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get sandbox runtime")
|
||||
}
|
||||
logrus.Debugf("Use OCI runtime %+v for sandbox %q and container %q", ociRuntime, sandboxID, id)
|
||||
log.G(ctx).Debugf("Use OCI runtime %+v for sandbox %q and container %q", ociRuntime, sandboxID, id)
|
||||
|
||||
spec, err := c.generateContainerSpec(id, sandboxID, sandboxPid, config, sandboxConfig,
|
||||
&image.ImageSpec.Config, append(mounts, volumeMounts...), ociRuntime.PodAnnotations)
|
||||
&image.ImageSpec.Config, append(mounts, volumeMounts...), ociRuntime)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to generate container %q spec", id)
|
||||
}
|
||||
|
||||
logrus.Debugf("Container %q spec: %#+v", id, spew.NewFormatter(spec))
|
||||
log.G(ctx).Debugf("Container %q spec: %#+v", id, spew.NewFormatter(spec))
|
||||
|
||||
// Set snapshotter before any other options.
|
||||
opts := []containerd.NewContainerOpts{
|
||||
@@ -199,10 +199,10 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
// Validate log paths and compose full container log path.
|
||||
if sandboxConfig.GetLogDirectory() != "" && config.GetLogPath() != "" {
|
||||
meta.LogPath = filepath.Join(sandboxConfig.GetLogDirectory(), config.GetLogPath())
|
||||
logrus.Debugf("Composed container full log path %q using sandbox log dir %q and container log path %q",
|
||||
log.G(ctx).Debugf("Composed container full log path %q using sandbox log dir %q and container log path %q",
|
||||
meta.LogPath, sandboxConfig.GetLogDirectory(), config.GetLogPath())
|
||||
} else {
|
||||
logrus.Infof("Logging will be disabled due to empty log paths for sandbox (%q) or container (%q)",
|
||||
log.G(ctx).Infof("Logging will be disabled due to empty log paths for sandbox (%q) or container (%q)",
|
||||
sandboxConfig.GetLogDirectory(), config.GetLogPath())
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
if err := containerIO.Close(); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to close container io %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to close container io %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -227,11 +227,16 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
userstr, err := generateUserString(
|
||||
securityContext.GetRunAsUsername(),
|
||||
securityContext.GetRunAsUser(),
|
||||
securityContext.GetRunAsGroup(),
|
||||
)
|
||||
securityContext.GetRunAsGroup())
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to generate user string")
|
||||
}
|
||||
if userstr == "" {
|
||||
// Lastly, since no user override was passed via CRI try to set via OCI
|
||||
// Image
|
||||
userstr = image.ImageSpec.Config.User
|
||||
}
|
||||
if userstr != "" {
|
||||
specOpts = append(specOpts, oci.WithUser(userstr))
|
||||
}
|
||||
@@ -286,7 +291,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
deferCtx, deferCancel := ctrdutil.DeferContext()
|
||||
defer deferCancel()
|
||||
if err := cntr.Delete(deferCtx, containerd.WithSnapshotCleanup); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to delete containerd container %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to delete containerd container %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -304,7 +309,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
if retErr != nil {
|
||||
// Cleanup container checkpoint on error.
|
||||
if err := container.Delete(); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to cleanup container checkpoint for %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to cleanup container checkpoint for %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -318,7 +323,8 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
|
||||
}
|
||||
|
||||
func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxPid uint32, config *runtime.ContainerConfig,
|
||||
sandboxConfig *runtime.PodSandboxConfig, imageConfig *imagespec.ImageConfig, extraMounts []*runtime.Mount, runtimePodAnnotations []string) (*runtimespec.Spec, error) {
|
||||
sandboxConfig *runtime.PodSandboxConfig, imageConfig *imagespec.ImageConfig, extraMounts []*runtime.Mount,
|
||||
ociRuntime config.Runtime) (*runtimespec.Spec, error) {
|
||||
|
||||
specOpts := []oci.SpecOpts{
|
||||
customopts.WithoutRunMount,
|
||||
@@ -380,7 +386,10 @@ func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxP
|
||||
if !sandboxConfig.GetLinux().GetSecurityContext().GetPrivileged() {
|
||||
return nil, errors.New("no privileged container allowed in sandbox")
|
||||
}
|
||||
specOpts = append(specOpts, oci.WithPrivileged, customopts.WithPrivilegedDevices)
|
||||
specOpts = append(specOpts, oci.WithPrivileged)
|
||||
if !ociRuntime.PrivilegedWithoutHostDevices {
|
||||
specOpts = append(specOpts, customopts.WithPrivilegedDevices)
|
||||
}
|
||||
} else { // not privileged
|
||||
specOpts = append(specOpts, customopts.WithDevices(c.os, config), customopts.WithCapabilities(securityContext))
|
||||
}
|
||||
@@ -408,8 +417,7 @@ func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxP
|
||||
} else {
|
||||
specOpts = append(specOpts, customopts.WithResources(config.GetLinux().GetResources()))
|
||||
if sandboxConfig.GetLinux().GetCgroupParent() != "" {
|
||||
cgroupsPath := getCgroupsPath(sandboxConfig.GetLinux().GetCgroupParent(), id,
|
||||
c.config.SystemdCgroup)
|
||||
cgroupsPath := getCgroupsPath(sandboxConfig.GetLinux().GetCgroupParent(), id)
|
||||
specOpts = append(specOpts, oci.WithCgroup(cgroupsPath))
|
||||
}
|
||||
}
|
||||
@@ -417,7 +425,7 @@ func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxP
|
||||
supplementalGroups := securityContext.GetSupplementalGroups()
|
||||
|
||||
for pKey, pValue := range getPassthroughAnnotations(sandboxConfig.Annotations,
|
||||
runtimePodAnnotations) {
|
||||
ociRuntime.PodAnnotations) {
|
||||
specOpts = append(specOpts, customopts.WithAnnotation(pKey, pValue))
|
||||
}
|
||||
|
||||
@@ -590,7 +598,20 @@ func generateApparmorSpecOpts(apparmorProf string, privileged, apparmorEnabled b
|
||||
}
|
||||
}
|
||||
|
||||
// generateUserString generates valid user string based on OCI Image Spec v1.0.0.
|
||||
// generateUserString generates valid user string based on OCI Image Spec
|
||||
// v1.0.0.
|
||||
//
|
||||
// CRI defines that the following combinations are valid:
|
||||
//
|
||||
// (none) -> ""
|
||||
// username -> username
|
||||
// username, uid -> username
|
||||
// username, uid, gid -> username:gid
|
||||
// username, gid -> username:gid
|
||||
// uid -> uid
|
||||
// uid, gid -> uid:gid
|
||||
// gid -> error
|
||||
//
|
||||
// TODO(random-liu): Add group name support in CRI.
|
||||
func generateUserString(username string, uid, gid *runtime.Int64Value) (string, error) {
|
||||
var userstr, groupstr string
|
||||
|
||||
18
vendor/github.com/containerd/cri/pkg/server/container_execsync.go
generated
vendored
18
vendor/github.com/containerd/cri/pkg/server/container_execsync.go
generated
vendored
@@ -25,9 +25,9 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
@@ -104,7 +104,7 @@ func (c *criService) execInContainer(ctx context.Context, id string, opts execOp
|
||||
|
||||
pspec.Terminal = opts.tty
|
||||
if opts.tty {
|
||||
if err := oci.WithEnv([]string{"TERM=xterm"})(nil, nil, nil, spec); err != nil {
|
||||
if err := oci.WithEnv([]string{"TERM=xterm"})(ctx, nil, nil, spec); err != nil {
|
||||
return nil, errors.Wrap(err, "add TERM env var to spec")
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (c *criService) execInContainer(ctx context.Context, id string, opts execOp
|
||||
opts.stderr = cio.NewDiscardLogger()
|
||||
}
|
||||
execID := util.GenerateID()
|
||||
logrus.Debugf("Generated exec id %q for container %q", execID, id)
|
||||
log.G(ctx).Debugf("Generated exec id %q for container %q", execID, id)
|
||||
volatileRootDir := c.getVolatileContainerRootDir(id)
|
||||
var execIO *cio.ExecIO
|
||||
process, err := task.Exec(ctx, execID, pspec,
|
||||
@@ -135,7 +135,7 @@ func (c *criService) execInContainer(ctx context.Context, id string, opts execOp
|
||||
deferCtx, deferCancel := ctrdutil.DeferContext()
|
||||
defer deferCancel()
|
||||
if _, err := process.Delete(deferCtx, containerd.WithProcessKill); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to delete exec process %q for container %q", execID, id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to delete exec process %q for container %q", execID, id)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -149,7 +149,7 @@ func (c *criService) execInContainer(ctx context.Context, id string, opts execOp
|
||||
|
||||
handleResizing(opts.resize, func(size remotecommand.TerminalSize) {
|
||||
if err := process.Resize(ctx, uint32(size.Width), uint32(size.Height)); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to resize process %q console for container %q", execID, id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to resize process %q console for container %q", execID, id)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -179,19 +179,19 @@ func (c *criService) execInContainer(ctx context.Context, id string, opts execOp
|
||||
}
|
||||
// Wait for the process to be killed.
|
||||
exitRes := <-exitCh
|
||||
logrus.Infof("Timeout received while waiting for exec process kill %q code %d and error %v",
|
||||
log.G(ctx).Infof("Timeout received while waiting for exec process kill %q code %d and error %v",
|
||||
execID, exitRes.ExitCode(), exitRes.Error())
|
||||
<-attachDone
|
||||
logrus.Debugf("Stream pipe for exec process %q done", execID)
|
||||
log.G(ctx).Debugf("Stream pipe for exec process %q done", execID)
|
||||
return nil, errors.Wrapf(execCtx.Err(), "timeout %v exceeded", opts.timeout)
|
||||
case exitRes := <-exitCh:
|
||||
code, _, err := exitRes.Result()
|
||||
logrus.Infof("Exec process %q exits with exit code %d and error %v", execID, code, err)
|
||||
log.G(ctx).Infof("Exec process %q exits with exit code %d and error %v", execID, code, err)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed while waiting for exec %q", execID)
|
||||
}
|
||||
<-attachDone
|
||||
logrus.Debugf("Stream pipe for exec process %q done", execID)
|
||||
log.G(ctx).Debugf("Stream pipe for exec process %q done", execID)
|
||||
return &code, nil
|
||||
}
|
||||
}
|
||||
|
||||
9
vendor/github.com/containerd/cri/pkg/server/container_remove.go
generated
vendored
9
vendor/github.com/containerd/cri/pkg/server/container_remove.go
generated
vendored
@@ -19,13 +19,12 @@ package server
|
||||
import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/containerd/cri/pkg/log"
|
||||
"github.com/containerd/cri/pkg/store"
|
||||
containerstore "github.com/containerd/cri/pkg/store/container"
|
||||
)
|
||||
@@ -39,7 +38,7 @@ func (c *criService) RemoveContainer(ctx context.Context, r *runtime.RemoveConta
|
||||
return nil, errors.Wrapf(err, "an error occurred when try to find container %q", r.GetContainerId())
|
||||
}
|
||||
// Do not return error if container metadata doesn't exist.
|
||||
log.Tracef("RemoveContainer called for container %q that does not exist", r.GetContainerId())
|
||||
log.G(ctx).Tracef("RemoveContainer called for container %q that does not exist", r.GetContainerId())
|
||||
return &runtime.RemoveContainerResponse{}, nil
|
||||
}
|
||||
id := container.ID
|
||||
@@ -53,7 +52,7 @@ func (c *criService) RemoveContainer(ctx context.Context, r *runtime.RemoveConta
|
||||
if retErr != nil {
|
||||
// Reset removing if remove failed.
|
||||
if err := resetContainerRemoving(container); err != nil {
|
||||
logrus.WithError(err).Errorf("failed to reset removing state for container %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("failed to reset removing state for container %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -68,7 +67,7 @@ func (c *criService) RemoveContainer(ctx context.Context, r *runtime.RemoveConta
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return nil, errors.Wrapf(err, "failed to delete containerd container %q", id)
|
||||
}
|
||||
log.Tracef("Remove called for containerd container %q that does not exist", id)
|
||||
log.G(ctx).Tracef("Remove called for containerd container %q that does not exist", id)
|
||||
}
|
||||
|
||||
// Delete container checkpoint.
|
||||
|
||||
7
vendor/github.com/containerd/cri/pkg/server/container_start.go
generated
vendored
7
vendor/github.com/containerd/cri/pkg/server/container_start.go
generated
vendored
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -65,11 +66,11 @@ func (c *criService) StartContainer(ctx context.Context, r *runtime.StartContain
|
||||
status.Message = retErr.Error()
|
||||
return status, nil
|
||||
}); err != nil {
|
||||
logrus.WithError(err).Errorf("failed to set start failure state for container %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("failed to set start failure state for container %q", id)
|
||||
}
|
||||
}
|
||||
if err := resetContainerStarting(cntr); err != nil {
|
||||
logrus.WithError(err).Errorf("failed to reset starting state for container %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("failed to reset starting state for container %q", id)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -113,7 +114,7 @@ func (c *criService) StartContainer(ctx context.Context, r *runtime.StartContain
|
||||
defer deferCancel()
|
||||
// It's possible that task is deleted by event monitor.
|
||||
if _, err := task.Delete(deferCtx, containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {
|
||||
logrus.WithError(err).Errorf("Failed to delete containerd task %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to delete containerd task %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
12
vendor/github.com/containerd/cri/pkg/server/container_stop.go
generated
vendored
12
vendor/github.com/containerd/cri/pkg/server/container_stop.go
generated
vendored
@@ -23,8 +23,8 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
eventtypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
@@ -57,7 +57,7 @@ func (c *criService) stopContainer(ctx context.Context, container containerstore
|
||||
state := container.Status.Get().State()
|
||||
if state != runtime.ContainerState_CONTAINER_RUNNING &&
|
||||
state != runtime.ContainerState_CONTAINER_UNKNOWN {
|
||||
logrus.Infof("Container to stop %q must be in running or unknown state, current state %q",
|
||||
log.G(ctx).Infof("Container to stop %q must be in running or unknown state, current state %q",
|
||||
id, criContainerStateToString(state))
|
||||
return nil
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (c *criService) stopContainer(ctx context.Context, container containerstore
|
||||
if err != store.ErrNotExist {
|
||||
return errors.Wrapf(err, "failed to get image %q", container.ImageRef)
|
||||
}
|
||||
logrus.Warningf("Image %q not found, stop container with signal %q", container.ImageRef, stopSignal)
|
||||
log.G(ctx).Warningf("Image %q not found, stop container with signal %q", container.ImageRef, stopSignal)
|
||||
} else {
|
||||
if image.ImageSpec.Config.StopSignal != "" {
|
||||
stopSignal = image.ImageSpec.Config.StopSignal
|
||||
@@ -129,7 +129,7 @@ func (c *criService) stopContainer(ctx context.Context, container containerstore
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to parse stop signal %q", stopSignal)
|
||||
}
|
||||
logrus.Infof("Stop container %q with signal %v", id, sig)
|
||||
log.G(ctx).Infof("Stop container %q with signal %v", id, sig)
|
||||
if err = task.Kill(ctx, sig); err != nil && !errdefs.IsNotFound(err) {
|
||||
return errors.Wrapf(err, "failed to stop container %q", id)
|
||||
}
|
||||
@@ -146,10 +146,10 @@ func (c *criService) stopContainer(ctx context.Context, container containerstore
|
||||
return ctx.Err()
|
||||
}
|
||||
// sigTermCtx was exceeded. Send SIGKILL
|
||||
logrus.Debugf("Stop container %q with signal %v timed out", id, sig)
|
||||
log.G(ctx).Debugf("Stop container %q with signal %v timed out", id, sig)
|
||||
}
|
||||
|
||||
logrus.Infof("Kill container %q", id)
|
||||
log.G(ctx).Infof("Kill container %q", id)
|
||||
if err = task.Kill(ctx, syscall.SIGKILL); err != nil && !errdefs.IsNotFound(err) {
|
||||
return errors.Wrapf(err, "failed to kill container %q", id)
|
||||
}
|
||||
|
||||
10
vendor/github.com/containerd/cri/pkg/server/container_update_resources.go
generated
vendored
10
vendor/github.com/containerd/cri/pkg/server/container_update_resources.go
generated
vendored
@@ -22,10 +22,10 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/typeurl"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
@@ -70,7 +70,7 @@ func (c *criService) updateContainerResources(ctx context.Context,
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get container spec")
|
||||
}
|
||||
newSpec, err := updateOCILinuxResource(oldSpec, resources)
|
||||
newSpec, err := updateOCILinuxResource(ctx, oldSpec, resources)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update resource in spec")
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (c *criService) updateContainerResources(ctx context.Context,
|
||||
defer deferCancel()
|
||||
// Reset spec on error.
|
||||
if err := updateContainerSpec(deferCtx, cntr.Container, oldSpec); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to update spec %+v for container %q", oldSpec, id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to update spec %+v for container %q", oldSpec, id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -130,7 +130,7 @@ func updateContainerSpec(ctx context.Context, cntr containerd.Container, spec *r
|
||||
}
|
||||
|
||||
// updateOCILinuxResource updates container resource limit.
|
||||
func updateOCILinuxResource(spec *runtimespec.Spec, new *runtime.LinuxContainerResources) (*runtimespec.Spec, error) {
|
||||
func updateOCILinuxResource(ctx context.Context, spec *runtimespec.Spec, new *runtime.LinuxContainerResources) (*runtimespec.Spec, error) {
|
||||
// Copy to make sure old spec is not changed.
|
||||
var cloned runtimespec.Spec
|
||||
if err := util.DeepCopy(&cloned, spec); err != nil {
|
||||
@@ -139,7 +139,7 @@ func updateOCILinuxResource(spec *runtimespec.Spec, new *runtime.LinuxContainerR
|
||||
if cloned.Linux == nil {
|
||||
cloned.Linux = &runtimespec.Linux{}
|
||||
}
|
||||
if err := opts.WithResources(new)(nil, nil, nil, &cloned); err != nil {
|
||||
if err := opts.WithResources(new)(ctx, nil, nil, &cloned); err != nil {
|
||||
return nil, errors.Wrap(err, "unable to set linux container resources")
|
||||
}
|
||||
return &cloned, nil
|
||||
|
||||
10
vendor/github.com/containerd/cri/pkg/server/helpers.go
generated
vendored
10
vendor/github.com/containerd/cri/pkg/server/helpers.go
generated
vendored
@@ -142,12 +142,12 @@ func makeContainerName(c *runtime.ContainerMetadata, s *runtime.PodSandboxMetada
|
||||
}
|
||||
|
||||
// getCgroupsPath generates container cgroups path.
|
||||
func getCgroupsPath(cgroupsParent, id string, systemdCgroup bool) string {
|
||||
if systemdCgroup {
|
||||
// Convert a.slice/b.slice/c.slice to c.slice.
|
||||
p := path.Base(cgroupsParent)
|
||||
func getCgroupsPath(cgroupsParent, id string) string {
|
||||
base := path.Base(cgroupsParent)
|
||||
if strings.HasSuffix(base, ".slice") {
|
||||
// For a.slice/b.slice/c.slice, base is c.slice.
|
||||
// runc systemd cgroup path format is "slice:prefix:name".
|
||||
return strings.Join([]string{p, "cri-containerd", id}, ":")
|
||||
return strings.Join([]string{base, "cri-containerd", id}, ":")
|
||||
}
|
||||
return filepath.Join(cgroupsParent, id)
|
||||
}
|
||||
|
||||
222
vendor/github.com/containerd/cri/pkg/server/image_pull.go
generated
vendored
222
vendor/github.com/containerd/cri/pkg/server/image_pull.go
generated
vendored
@@ -30,16 +30,15 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
containerdimages "github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/reference"
|
||||
"github.com/containerd/containerd/remotes"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/remotes/docker"
|
||||
"github.com/containerd/cri/pkg/config"
|
||||
distribution "github.com/docker/distribution/reference"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
criconfig "github.com/containerd/cri/pkg/config"
|
||||
)
|
||||
|
||||
// For image management:
|
||||
@@ -92,16 +91,21 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
||||
}
|
||||
ref := namedRef.String()
|
||||
if ref != imageRef {
|
||||
logrus.Debugf("PullImage using normalized image ref: %q", ref)
|
||||
log.G(ctx).Debugf("PullImage using normalized image ref: %q", ref)
|
||||
}
|
||||
resolver, desc, err := c.getResolver(ctx, ref, c.credentials(r.GetAuth()))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to resolve image %q", ref)
|
||||
}
|
||||
// We have to check schema1 here, because after `Pull`, schema1
|
||||
// image has already been converted.
|
||||
isSchema1 := desc.MediaType == containerdimages.MediaTypeDockerSchema1Manifest
|
||||
|
||||
var (
|
||||
resolver = docker.NewResolver(docker.ResolverOptions{
|
||||
Hosts: c.registryHosts(r.GetAuth()),
|
||||
})
|
||||
isSchema1 bool
|
||||
imageHandler containerdimages.HandlerFunc = func(_ context.Context,
|
||||
desc imagespec.Descriptor) ([]imagespec.Descriptor, error) {
|
||||
if desc.MediaType == containerdimages.MediaTypeDockerSchema1Manifest {
|
||||
isSchema1 = true
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
)
|
||||
image, err := c.client.Pull(ctx, ref,
|
||||
containerd.WithSchema1Conversion,
|
||||
containerd.WithResolver(resolver),
|
||||
@@ -109,6 +113,7 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
||||
containerd.WithPullUnpack,
|
||||
containerd.WithPullLabel(imageLabelKey, imageLabelValue),
|
||||
containerd.WithMaxConcurrentDownloads(c.config.MaxConcurrentDownloads),
|
||||
containerd.WithImageHandler(imageHandler),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to pull and unpack image %q", ref)
|
||||
@@ -136,7 +141,7 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("Pulled image %q with image id %q, repo tag %q, repo digest %q", imageRef, imageID,
|
||||
log.G(ctx).Debugf("Pulled image %q with image id %q, repo tag %q, repo digest %q", imageRef, imageID,
|
||||
repoTag, repoDigest)
|
||||
// NOTE(random-liu): the actual state in containerd is the source of truth, even we maintain
|
||||
// in-memory image store, it's only for in-memory indexing. The image could be removed
|
||||
@@ -147,10 +152,20 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
||||
}
|
||||
|
||||
// ParseAuth parses AuthConfig and returns username and password/secret required by containerd.
|
||||
func ParseAuth(auth *runtime.AuthConfig) (string, string, error) {
|
||||
func ParseAuth(auth *runtime.AuthConfig, host string) (string, string, error) {
|
||||
if auth == nil {
|
||||
return "", "", nil
|
||||
}
|
||||
if auth.ServerAddress != "" {
|
||||
// Do not return the auth info when server address doesn't match.
|
||||
u, err := url.Parse(auth.ServerAddress)
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "parse server address")
|
||||
}
|
||||
if host != u.Host {
|
||||
return "", "", nil
|
||||
}
|
||||
}
|
||||
if auth.Username != "" {
|
||||
return auth.Username, auth.Password, nil
|
||||
}
|
||||
@@ -234,31 +249,23 @@ func (c *criService) updateImage(ctx context.Context, r string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// credentials returns a credential function for docker resolver to use.
|
||||
func (c *criService) credentials(auth *runtime.AuthConfig) func(string) (string, string, error) {
|
||||
return func(host string) (string, string, error) {
|
||||
if auth == nil {
|
||||
// Get default auth from config.
|
||||
for h, ac := range c.config.Registry.Auths {
|
||||
u, err := url.Parse(h)
|
||||
if err != nil {
|
||||
return "", "", errors.Wrapf(err, "parse auth host %q", h)
|
||||
}
|
||||
if u.Host == host {
|
||||
auth = toRuntimeAuthConfig(ac)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return ParseAuth(auth)
|
||||
}
|
||||
}
|
||||
|
||||
// getTLSConfig returns a TLSConfig configured with a CA/Cert/Key specified by registryTLSConfig
|
||||
func (c *criService) getTLSConfig(registryTLSConfig config.TLSConfig) (*tls.Config, error) {
|
||||
cert, err := tls.LoadX509KeyPair(registryTLSConfig.CertFile, registryTLSConfig.KeyFile)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to load cert file")
|
||||
func (c *criService) getTLSConfig(registryTLSConfig criconfig.TLSConfig) (*tls.Config, error) {
|
||||
var (
|
||||
cert tls.Certificate
|
||||
err error
|
||||
)
|
||||
if registryTLSConfig.CertFile != "" && registryTLSConfig.KeyFile != "" {
|
||||
cert, err = tls.LoadX509KeyPair(registryTLSConfig.CertFile, registryTLSConfig.KeyFile)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to load cert file")
|
||||
}
|
||||
}
|
||||
if registryTLSConfig.CertFile != "" && registryTLSConfig.KeyFile == "" {
|
||||
return nil, errors.Errorf("cert file %q was specified, but no corresponding key file was specified", registryTLSConfig.CertFile)
|
||||
}
|
||||
if registryTLSConfig.CertFile == "" && registryTLSConfig.KeyFile != "" {
|
||||
return nil, errors.Errorf("key file %q was specified, but no corresponding cert file was specified", registryTLSConfig.KeyFile)
|
||||
}
|
||||
|
||||
caCertPool, err := x509.SystemCertPool()
|
||||
@@ -272,75 +279,98 @@ func (c *criService) getTLSConfig(registryTLSConfig config.TLSConfig) (*tls.Conf
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
|
||||
tlsConfig := &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
RootCAs: caCertPool,
|
||||
RootCAs: caCertPool,
|
||||
}
|
||||
if len(cert.Certificate) != 0 {
|
||||
tlsConfig.Certificates = []tls.Certificate{cert}
|
||||
}
|
||||
tlsConfig.BuildNameToCertificate()
|
||||
return tlsConfig, nil
|
||||
}
|
||||
|
||||
// getResolver tries registry mirrors and the default registry, and returns the resolver and descriptor
|
||||
// from the first working registry.
|
||||
func (c *criService) getResolver(ctx context.Context, ref string, cred func(string) (string, string, error)) (remotes.Resolver, imagespec.Descriptor, error) {
|
||||
refspec, err := reference.Parse(ref)
|
||||
if err != nil {
|
||||
return nil, imagespec.Descriptor{}, errors.Wrap(err, "parse image reference")
|
||||
// registryHosts is the registry hosts to be used by the resolver.
|
||||
func (c *criService) registryHosts(auth *runtime.AuthConfig) docker.RegistryHosts {
|
||||
return func(host string) ([]docker.RegistryHost, error) {
|
||||
var registries []docker.RegistryHost
|
||||
|
||||
endpoints, err := c.registryEndpoints(host)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get registry endpoints")
|
||||
}
|
||||
for _, e := range endpoints {
|
||||
u, err := url.Parse(e)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "parse registry endpoint %q from mirrors", e)
|
||||
}
|
||||
|
||||
var (
|
||||
transport = newTransport()
|
||||
client = &http.Client{Transport: transport}
|
||||
config = c.config.Registry.Configs[u.Host]
|
||||
)
|
||||
|
||||
if u.Scheme != "https" && config.TLS != nil {
|
||||
return nil, errors.Errorf("tls provided for http endpoint %q", e)
|
||||
}
|
||||
|
||||
if config.TLS != nil {
|
||||
transport.TLSClientConfig, err = c.getTLSConfig(*config.TLS)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "get TLSConfig for registry %q", e)
|
||||
}
|
||||
}
|
||||
|
||||
if auth == nil && config.Auth != nil {
|
||||
auth = toRuntimeAuthConfig(*config.Auth)
|
||||
}
|
||||
|
||||
if u.Path == "" {
|
||||
u.Path = "/v2"
|
||||
}
|
||||
|
||||
registries = append(registries, docker.RegistryHost{
|
||||
Client: client,
|
||||
Authorizer: docker.NewDockerAuthorizer(
|
||||
docker.WithAuthClient(client),
|
||||
docker.WithAuthCreds(func(host string) (string, string, error) {
|
||||
return ParseAuth(auth, host)
|
||||
})),
|
||||
Host: u.Host,
|
||||
Scheme: u.Scheme,
|
||||
Path: u.Path,
|
||||
Capabilities: docker.HostCapabilityResolve | docker.HostCapabilityPull,
|
||||
})
|
||||
}
|
||||
return registries, nil
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
transport = newTransport()
|
||||
httpClient = &http.Client{Transport: transport}
|
||||
)
|
||||
|
||||
// Try mirrors in order first, and then try default host name.
|
||||
for _, e := range c.config.Registry.Mirrors[refspec.Hostname()].Endpoints {
|
||||
// registryEndpoints returns endpoints for a given host.
|
||||
// It adds default registry endpoint if it does not exist in the passed-in endpoint list.
|
||||
// It also supports wildcard host matching with `*`.
|
||||
func (c *criService) registryEndpoints(host string) ([]string, error) {
|
||||
var endpoints []string
|
||||
_, ok := c.config.Registry.Mirrors[host]
|
||||
if ok {
|
||||
endpoints = c.config.Registry.Mirrors[host].Endpoints
|
||||
} else {
|
||||
endpoints = c.config.Registry.Mirrors["*"].Endpoints
|
||||
}
|
||||
defaultHost, err := docker.DefaultHost(host)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get default host")
|
||||
}
|
||||
for _, e := range endpoints {
|
||||
u, err := url.Parse(e)
|
||||
if err != nil {
|
||||
return nil, imagespec.Descriptor{}, errors.Wrapf(err, "parse registry endpoint %q", e)
|
||||
return nil, errors.Wrap(err, "parse endpoint url")
|
||||
}
|
||||
|
||||
if registryTLSConfig, ok := c.config.Registry.TLSConfigs[u.Host]; ok {
|
||||
transport.TLSClientConfig, err = c.getTLSConfig(registryTLSConfig)
|
||||
if err != nil {
|
||||
return nil, imagespec.Descriptor{}, errors.Wrapf(err, "get TLSConfig for registry %q", refspec.Hostname())
|
||||
}
|
||||
}
|
||||
|
||||
resolver := docker.NewResolver(docker.ResolverOptions{
|
||||
Authorizer: docker.NewAuthorizer(httpClient, cred),
|
||||
Client: httpClient,
|
||||
Host: func(string) (string, error) { return u.Host, nil },
|
||||
// By default use "https".
|
||||
PlainHTTP: u.Scheme == "http",
|
||||
})
|
||||
_, desc, err := resolver.Resolve(ctx, ref)
|
||||
if err == nil {
|
||||
return resolver, desc, nil
|
||||
}
|
||||
logrus.WithError(err).Debugf("Tried registry mirror %q but failed", e)
|
||||
// Continue to try next endpoint
|
||||
}
|
||||
|
||||
hostname, err := docker.DefaultHost(refspec.Hostname())
|
||||
if err != nil {
|
||||
return nil, imagespec.Descriptor{}, errors.Wrapf(err, "get host for refspec %q", refspec.Hostname())
|
||||
}
|
||||
if registryTLSConfig, ok := c.config.Registry.TLSConfigs[hostname]; ok {
|
||||
transport.TLSClientConfig, err = c.getTLSConfig(registryTLSConfig)
|
||||
if err != nil {
|
||||
return nil, imagespec.Descriptor{}, errors.Wrapf(err, "get TLSConfig for registry %q", refspec.Hostname())
|
||||
if u.Host == host {
|
||||
// Do not add default if the endpoint already exists.
|
||||
return endpoints, nil
|
||||
}
|
||||
}
|
||||
|
||||
resolver := docker.NewResolver(docker.ResolverOptions{
|
||||
Credentials: cred,
|
||||
Client: httpClient,
|
||||
})
|
||||
_, desc, err := resolver.Resolve(ctx, ref)
|
||||
if err != nil {
|
||||
return nil, imagespec.Descriptor{}, errors.Wrap(err, "no available registry endpoint")
|
||||
}
|
||||
return resolver, desc, nil
|
||||
return append(endpoints, "https://"+defaultHost), nil
|
||||
}
|
||||
|
||||
// newTransport returns a new HTTP transport used to pull image.
|
||||
|
||||
6
vendor/github.com/containerd/cri/pkg/server/image_status.go
generated
vendored
6
vendor/github.com/containerd/cri/pkg/server/image_status.go
generated
vendored
@@ -19,14 +19,14 @@ package server
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/containerd/cri/pkg/store"
|
||||
imagestore "github.com/containerd/cri/pkg/store/image"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// ImageStatus returns the status of the image, returns nil if the image isn't present.
|
||||
@@ -97,7 +97,7 @@ func (c *criService) toCRIImageInfo(ctx context.Context, image *imagestore.Image
|
||||
if err == nil {
|
||||
info["info"] = string(m)
|
||||
} else {
|
||||
logrus.WithError(err).Errorf("failed to marshal info %v", imi)
|
||||
log.G(ctx).WithError(err).Errorf("failed to marshal info %v", imi)
|
||||
info["info"] = err.Error()
|
||||
}
|
||||
|
||||
|
||||
169
vendor/github.com/containerd/cri/pkg/server/instrumented_service.go
generated
vendored
169
vendor/github.com/containerd/cri/pkg/server/instrumented_service.go
generated
vendored
@@ -19,13 +19,12 @@ package server
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
ctrdutil "github.com/containerd/cri/pkg/containerd/util"
|
||||
"github.com/containerd/cri/pkg/log"
|
||||
)
|
||||
|
||||
// instrumentedService wraps service with containerd namespace and logs.
|
||||
@@ -52,12 +51,12 @@ func (in *instrumentedService) RunPodSandbox(ctx context.Context, r *runtime.Run
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("RunPodsandbox for %+v", r.GetConfig().GetMetadata())
|
||||
log.G(ctx).Infof("RunPodsandbox for %+v", r.GetConfig().GetMetadata())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("RunPodSandbox for %+v failed, error", r.GetConfig().GetMetadata())
|
||||
log.G(ctx).WithError(err).Errorf("RunPodSandbox for %+v failed, error", r.GetConfig().GetMetadata())
|
||||
} else {
|
||||
logrus.Infof("RunPodSandbox for %+v returns sandbox id %q", r.GetConfig().GetMetadata(), res.GetPodSandboxId())
|
||||
log.G(ctx).Infof("RunPodSandbox for %+v returns sandbox id %q", r.GetConfig().GetMetadata(), res.GetPodSandboxId())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.RunPodSandbox(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -68,12 +67,12 @@ func (in *instrumentedService) ListPodSandbox(ctx context.Context, r *runtime.Li
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("ListPodSandbox with filter %+v", r.GetFilter())
|
||||
log.G(ctx).Tracef("ListPodSandbox with filter %+v", r.GetFilter())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("ListPodSandbox failed")
|
||||
log.G(ctx).WithError(err).Error("ListPodSandbox failed")
|
||||
} else {
|
||||
log.Tracef("ListPodSandbox returns pod sandboxes %+v", res.GetItems())
|
||||
log.G(ctx).Tracef("ListPodSandbox returns pod sandboxes %+v", res.GetItems())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.ListPodSandbox(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -84,12 +83,12 @@ func (in *instrumentedService) PodSandboxStatus(ctx context.Context, r *runtime.
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("PodSandboxStatus for %q", r.GetPodSandboxId())
|
||||
log.G(ctx).Tracef("PodSandboxStatus for %q", r.GetPodSandboxId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("PodSandboxStatus for %q failed", r.GetPodSandboxId())
|
||||
log.G(ctx).WithError(err).Errorf("PodSandboxStatus for %q failed", r.GetPodSandboxId())
|
||||
} else {
|
||||
log.Tracef("PodSandboxStatus for %q returns status %+v", r.GetPodSandboxId(), res.GetStatus())
|
||||
log.G(ctx).Tracef("PodSandboxStatus for %q returns status %+v", r.GetPodSandboxId(), res.GetStatus())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.PodSandboxStatus(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -100,12 +99,12 @@ func (in *instrumentedService) StopPodSandbox(ctx context.Context, r *runtime.St
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("StopPodSandbox for %q", r.GetPodSandboxId())
|
||||
log.G(ctx).Infof("StopPodSandbox for %q", r.GetPodSandboxId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("StopPodSandbox for %q failed", r.GetPodSandboxId())
|
||||
log.G(ctx).WithError(err).Errorf("StopPodSandbox for %q failed", r.GetPodSandboxId())
|
||||
} else {
|
||||
logrus.Infof("StopPodSandbox for %q returns successfully", r.GetPodSandboxId())
|
||||
log.G(ctx).Infof("StopPodSandbox for %q returns successfully", r.GetPodSandboxId())
|
||||
}
|
||||
}()
|
||||
res, err := in.c.StopPodSandbox(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -116,12 +115,12 @@ func (in *instrumentedService) RemovePodSandbox(ctx context.Context, r *runtime.
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("RemovePodSandbox for %q", r.GetPodSandboxId())
|
||||
log.G(ctx).Infof("RemovePodSandbox for %q", r.GetPodSandboxId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("RemovePodSandbox for %q failed", r.GetPodSandboxId())
|
||||
log.G(ctx).WithError(err).Errorf("RemovePodSandbox for %q failed", r.GetPodSandboxId())
|
||||
} else {
|
||||
logrus.Infof("RemovePodSandbox %q returns successfully", r.GetPodSandboxId())
|
||||
log.G(ctx).Infof("RemovePodSandbox %q returns successfully", r.GetPodSandboxId())
|
||||
}
|
||||
}()
|
||||
res, err := in.c.RemovePodSandbox(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -132,12 +131,12 @@ func (in *instrumentedService) PortForward(ctx context.Context, r *runtime.PortF
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("Portforward for %q port %v", r.GetPodSandboxId(), r.GetPort())
|
||||
log.G(ctx).Infof("Portforward for %q port %v", r.GetPodSandboxId(), r.GetPort())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Portforward for %q failed", r.GetPodSandboxId())
|
||||
log.G(ctx).WithError(err).Errorf("Portforward for %q failed", r.GetPodSandboxId())
|
||||
} else {
|
||||
logrus.Infof("Portforward for %q returns URL %q", r.GetPodSandboxId(), res.GetUrl())
|
||||
log.G(ctx).Infof("Portforward for %q returns URL %q", r.GetPodSandboxId(), res.GetUrl())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.PortForward(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -148,14 +147,14 @@ func (in *instrumentedService) CreateContainer(ctx context.Context, r *runtime.C
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("CreateContainer within sandbox %q for container %+v",
|
||||
log.G(ctx).Infof("CreateContainer within sandbox %q for container %+v",
|
||||
r.GetPodSandboxId(), r.GetConfig().GetMetadata())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("CreateContainer within sandbox %q for %+v failed",
|
||||
log.G(ctx).WithError(err).Errorf("CreateContainer within sandbox %q for %+v failed",
|
||||
r.GetPodSandboxId(), r.GetConfig().GetMetadata())
|
||||
} else {
|
||||
logrus.Infof("CreateContainer within sandbox %q for %+v returns container id %q",
|
||||
log.G(ctx).Infof("CreateContainer within sandbox %q for %+v returns container id %q",
|
||||
r.GetPodSandboxId(), r.GetConfig().GetMetadata(), res.GetContainerId())
|
||||
}
|
||||
}()
|
||||
@@ -167,12 +166,12 @@ func (in *instrumentedService) StartContainer(ctx context.Context, r *runtime.St
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("StartContainer for %q", r.GetContainerId())
|
||||
log.G(ctx).Infof("StartContainer for %q", r.GetContainerId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("StartContainer for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("StartContainer for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("StartContainer for %q returns successfully", r.GetContainerId())
|
||||
log.G(ctx).Infof("StartContainer for %q returns successfully", r.GetContainerId())
|
||||
}
|
||||
}()
|
||||
res, err := in.c.StartContainer(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -183,12 +182,12 @@ func (in *instrumentedService) ListContainers(ctx context.Context, r *runtime.Li
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("ListContainers with filter %+v", r.GetFilter())
|
||||
log.G(ctx).Tracef("ListContainers with filter %+v", r.GetFilter())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ListContainers with filter %+v failed", r.GetFilter())
|
||||
log.G(ctx).WithError(err).Errorf("ListContainers with filter %+v failed", r.GetFilter())
|
||||
} else {
|
||||
log.Tracef("ListContainers with filter %+v returns containers %+v",
|
||||
log.G(ctx).Tracef("ListContainers with filter %+v returns containers %+v",
|
||||
r.GetFilter(), res.GetContainers())
|
||||
}
|
||||
}()
|
||||
@@ -200,12 +199,12 @@ func (in *instrumentedService) ContainerStatus(ctx context.Context, r *runtime.C
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("ContainerStatus for %q", r.GetContainerId())
|
||||
log.G(ctx).Tracef("ContainerStatus for %q", r.GetContainerId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ContainerStatus for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("ContainerStatus for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
log.Tracef("ContainerStatus for %q returns status %+v", r.GetContainerId(), res.GetStatus())
|
||||
log.G(ctx).Tracef("ContainerStatus for %q returns status %+v", r.GetContainerId(), res.GetStatus())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.ContainerStatus(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -216,12 +215,12 @@ func (in *instrumentedService) StopContainer(ctx context.Context, r *runtime.Sto
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("StopContainer for %q with timeout %d (s)", r.GetContainerId(), r.GetTimeout())
|
||||
log.G(ctx).Infof("StopContainer for %q with timeout %d (s)", r.GetContainerId(), r.GetTimeout())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("StopContainer for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("StopContainer for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("StopContainer for %q returns successfully", r.GetContainerId())
|
||||
log.G(ctx).Infof("StopContainer for %q returns successfully", r.GetContainerId())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.StopContainer(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -232,12 +231,12 @@ func (in *instrumentedService) RemoveContainer(ctx context.Context, r *runtime.R
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("RemoveContainer for %q", r.GetContainerId())
|
||||
log.G(ctx).Infof("RemoveContainer for %q", r.GetContainerId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("RemoveContainer for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("RemoveContainer for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("RemoveContainer for %q returns successfully", r.GetContainerId())
|
||||
log.G(ctx).Infof("RemoveContainer for %q returns successfully", r.GetContainerId())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.RemoveContainer(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -248,13 +247,13 @@ func (in *instrumentedService) ExecSync(ctx context.Context, r *runtime.ExecSync
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("ExecSync for %q with command %+v and timeout %d (s)", r.GetContainerId(), r.GetCmd(), r.GetTimeout())
|
||||
log.G(ctx).Infof("ExecSync for %q with command %+v and timeout %d (s)", r.GetContainerId(), r.GetCmd(), r.GetTimeout())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ExecSync for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("ExecSync for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("ExecSync for %q returns with exit code %d", r.GetContainerId(), res.GetExitCode())
|
||||
logrus.Debugf("ExecSync for %q outputs - stdout: %q, stderr: %q", r.GetContainerId(),
|
||||
log.G(ctx).Infof("ExecSync for %q returns with exit code %d", r.GetContainerId(), res.GetExitCode())
|
||||
log.G(ctx).Debugf("ExecSync for %q outputs - stdout: %q, stderr: %q", r.GetContainerId(),
|
||||
res.GetStdout(), res.GetStderr())
|
||||
}
|
||||
}()
|
||||
@@ -266,13 +265,13 @@ func (in *instrumentedService) Exec(ctx context.Context, r *runtime.ExecRequest)
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("Exec for %q with command %+v, tty %v and stdin %v",
|
||||
log.G(ctx).Infof("Exec for %q with command %+v, tty %v and stdin %v",
|
||||
r.GetContainerId(), r.GetCmd(), r.GetTty(), r.GetStdin())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Exec for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("Exec for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("Exec for %q returns URL %q", r.GetContainerId(), res.GetUrl())
|
||||
log.G(ctx).Infof("Exec for %q returns URL %q", r.GetContainerId(), res.GetUrl())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.Exec(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -283,12 +282,12 @@ func (in *instrumentedService) Attach(ctx context.Context, r *runtime.AttachRequ
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("Attach for %q with tty %v and stdin %v", r.GetContainerId(), r.GetTty(), r.GetStdin())
|
||||
log.G(ctx).Infof("Attach for %q with tty %v and stdin %v", r.GetContainerId(), r.GetTty(), r.GetStdin())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Attach for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("Attach for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("Attach for %q returns URL %q", r.GetContainerId(), res.Url)
|
||||
log.G(ctx).Infof("Attach for %q returns URL %q", r.GetContainerId(), res.Url)
|
||||
}
|
||||
}()
|
||||
res, err = in.c.Attach(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -299,12 +298,12 @@ func (in *instrumentedService) UpdateContainerResources(ctx context.Context, r *
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("UpdateContainerResources for %q with %+v", r.GetContainerId(), r.GetLinux())
|
||||
log.G(ctx).Infof("UpdateContainerResources for %q with %+v", r.GetContainerId(), r.GetLinux())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("UpdateContainerResources for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("UpdateContainerResources for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Infof("UpdateContainerResources for %q returns successfully", r.GetContainerId())
|
||||
log.G(ctx).Infof("UpdateContainerResources for %q returns successfully", r.GetContainerId())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.UpdateContainerResources(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -315,12 +314,12 @@ func (in *instrumentedService) PullImage(ctx context.Context, r *runtime.PullIma
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("PullImage %q", r.GetImage().GetImage())
|
||||
log.G(ctx).Infof("PullImage %q", r.GetImage().GetImage())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("PullImage %q failed", r.GetImage().GetImage())
|
||||
log.G(ctx).WithError(err).Errorf("PullImage %q failed", r.GetImage().GetImage())
|
||||
} else {
|
||||
logrus.Infof("PullImage %q returns image reference %q",
|
||||
log.G(ctx).Infof("PullImage %q returns image reference %q",
|
||||
r.GetImage().GetImage(), res.GetImageRef())
|
||||
}
|
||||
}()
|
||||
@@ -332,12 +331,12 @@ func (in *instrumentedService) ListImages(ctx context.Context, r *runtime.ListIm
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("ListImages with filter %+v", r.GetFilter())
|
||||
log.G(ctx).Tracef("ListImages with filter %+v", r.GetFilter())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ListImages with filter %+v failed", r.GetFilter())
|
||||
log.G(ctx).WithError(err).Errorf("ListImages with filter %+v failed", r.GetFilter())
|
||||
} else {
|
||||
log.Tracef("ListImages with filter %+v returns image list %+v",
|
||||
log.G(ctx).Tracef("ListImages with filter %+v returns image list %+v",
|
||||
r.GetFilter(), res.GetImages())
|
||||
}
|
||||
}()
|
||||
@@ -349,12 +348,12 @@ func (in *instrumentedService) ImageStatus(ctx context.Context, r *runtime.Image
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("ImageStatus for %q", r.GetImage().GetImage())
|
||||
log.G(ctx).Tracef("ImageStatus for %q", r.GetImage().GetImage())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ImageStatus for %q failed", r.GetImage().GetImage())
|
||||
log.G(ctx).WithError(err).Errorf("ImageStatus for %q failed", r.GetImage().GetImage())
|
||||
} else {
|
||||
log.Tracef("ImageStatus for %q returns image status %+v",
|
||||
log.G(ctx).Tracef("ImageStatus for %q returns image status %+v",
|
||||
r.GetImage().GetImage(), res.GetImage())
|
||||
}
|
||||
}()
|
||||
@@ -366,12 +365,12 @@ func (in *instrumentedService) RemoveImage(ctx context.Context, r *runtime.Remov
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Infof("RemoveImage %q", r.GetImage().GetImage())
|
||||
log.G(ctx).Infof("RemoveImage %q", r.GetImage().GetImage())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("RemoveImage %q failed", r.GetImage().GetImage())
|
||||
log.G(ctx).WithError(err).Errorf("RemoveImage %q failed", r.GetImage().GetImage())
|
||||
} else {
|
||||
logrus.Infof("RemoveImage %q returns successfully", r.GetImage().GetImage())
|
||||
log.G(ctx).Infof("RemoveImage %q returns successfully", r.GetImage().GetImage())
|
||||
}
|
||||
}()
|
||||
res, err := in.c.RemoveImage(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -382,12 +381,12 @@ func (in *instrumentedService) ImageFsInfo(ctx context.Context, r *runtime.Image
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Debugf("ImageFsInfo")
|
||||
log.G(ctx).Debugf("ImageFsInfo")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("ImageFsInfo failed")
|
||||
log.G(ctx).WithError(err).Error("ImageFsInfo failed")
|
||||
} else {
|
||||
logrus.Debugf("ImageFsInfo returns filesystem info %+v", res.ImageFilesystems)
|
||||
log.G(ctx).Debugf("ImageFsInfo returns filesystem info %+v", res.ImageFilesystems)
|
||||
}
|
||||
}()
|
||||
res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -398,12 +397,12 @@ func (in *instrumentedService) ContainerStats(ctx context.Context, r *runtime.Co
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Debugf("ContainerStats for %q", r.GetContainerId())
|
||||
log.G(ctx).Debugf("ContainerStats for %q", r.GetContainerId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ContainerStats for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("ContainerStats for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Debugf("ContainerStats for %q returns stats %+v", r.GetContainerId(), res.GetStats())
|
||||
log.G(ctx).Debugf("ContainerStats for %q returns stats %+v", r.GetContainerId(), res.GetStats())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -414,12 +413,12 @@ func (in *instrumentedService) ListContainerStats(ctx context.Context, r *runtim
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("ListContainerStats with filter %+v", r.GetFilter())
|
||||
log.G(ctx).Tracef("ListContainerStats with filter %+v", r.GetFilter())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("ListContainerStats failed")
|
||||
log.G(ctx).WithError(err).Error("ListContainerStats failed")
|
||||
} else {
|
||||
log.Tracef("ListContainerStats returns stats %+v", res.GetStats())
|
||||
log.G(ctx).Tracef("ListContainerStats returns stats %+v", res.GetStats())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.ListContainerStats(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -430,12 +429,12 @@ func (in *instrumentedService) Status(ctx context.Context, r *runtime.StatusRequ
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("Status")
|
||||
log.G(ctx).Tracef("Status")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Status failed")
|
||||
log.G(ctx).WithError(err).Error("Status failed")
|
||||
} else {
|
||||
log.Tracef("Status returns status %+v", res.GetStatus())
|
||||
log.G(ctx).Tracef("Status returns status %+v", res.GetStatus())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.Status(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -446,12 +445,12 @@ func (in *instrumentedService) Version(ctx context.Context, r *runtime.VersionRe
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Tracef("Version with client side version %q", r.GetVersion())
|
||||
log.G(ctx).Tracef("Version with client side version %q", r.GetVersion())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Version failed")
|
||||
log.G(ctx).WithError(err).Error("Version failed")
|
||||
} else {
|
||||
log.Tracef("Version returns %+v", res)
|
||||
log.G(ctx).Tracef("Version returns %+v", res)
|
||||
}
|
||||
}()
|
||||
res, err = in.c.Version(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -462,12 +461,12 @@ func (in *instrumentedService) UpdateRuntimeConfig(ctx context.Context, r *runti
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Debugf("UpdateRuntimeConfig with config %+v", r.GetRuntimeConfig())
|
||||
log.G(ctx).Debugf("UpdateRuntimeConfig with config %+v", r.GetRuntimeConfig())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("UpdateRuntimeConfig failed")
|
||||
log.G(ctx).WithError(err).Error("UpdateRuntimeConfig failed")
|
||||
} else {
|
||||
logrus.Debug("UpdateRuntimeConfig returns returns successfully")
|
||||
log.G(ctx).Debug("UpdateRuntimeConfig returns returns successfully")
|
||||
}
|
||||
}()
|
||||
res, err = in.c.UpdateRuntimeConfig(ctrdutil.WithNamespace(ctx), r)
|
||||
@@ -478,12 +477,12 @@ func (in *instrumentedService) ReopenContainerLog(ctx context.Context, r *runtim
|
||||
if err := in.checkInitialized(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Debugf("ReopenContainerLog for %q", r.GetContainerId())
|
||||
log.G(ctx).Debugf("ReopenContainerLog for %q", r.GetContainerId())
|
||||
defer func() {
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("ReopenContainerLog for %q failed", r.GetContainerId())
|
||||
log.G(ctx).WithError(err).Errorf("ReopenContainerLog for %q failed", r.GetContainerId())
|
||||
} else {
|
||||
logrus.Debugf("ReopenContainerLog for %q returns successfully", r.GetContainerId())
|
||||
log.G(ctx).Debugf("ReopenContainerLog for %q returns successfully", r.GetContainerId())
|
||||
}
|
||||
}()
|
||||
res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), r)
|
||||
|
||||
38
vendor/github.com/containerd/cri/pkg/server/restart.go
generated
vendored
38
vendor/github.com/containerd/cri/pkg/server/restart.go
generated
vendored
@@ -26,11 +26,11 @@ import (
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
containerdimages "github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
@@ -60,10 +60,10 @@ func (c *criService) recover(ctx context.Context) error {
|
||||
for _, sandbox := range sandboxes {
|
||||
sb, err := c.loadSandbox(ctx, sandbox)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to load sandbox %q", sandbox.ID())
|
||||
log.G(ctx).WithError(err).Errorf("Failed to load sandbox %q", sandbox.ID())
|
||||
continue
|
||||
}
|
||||
logrus.Debugf("Loaded sandbox %+v", sb)
|
||||
log.G(ctx).Debugf("Loaded sandbox %+v", sb)
|
||||
if err := c.sandboxStore.Add(sb); err != nil {
|
||||
return errors.Wrapf(err, "failed to add sandbox %q to store", sandbox.ID())
|
||||
}
|
||||
@@ -80,10 +80,10 @@ func (c *criService) recover(ctx context.Context) error {
|
||||
for _, container := range containers {
|
||||
cntr, err := c.loadContainer(ctx, container)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to load container %q", container.ID())
|
||||
log.G(ctx).WithError(err).Errorf("Failed to load container %q", container.ID())
|
||||
continue
|
||||
}
|
||||
logrus.Debugf("Loaded container %+v", cntr)
|
||||
log.G(ctx).Debugf("Loaded container %+v", cntr)
|
||||
if err := c.containerStore.Add(cntr); err != nil {
|
||||
return errors.Wrapf(err, "failed to add container %q to store", container.ID())
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func (c *criService) recover(ctx context.Context) error {
|
||||
errMsg: "failed to cleanup orphaned volatile container directories",
|
||||
},
|
||||
} {
|
||||
if err := cleanupOrphanedIDDirs(cleanup.cntrs, cleanup.base); err != nil {
|
||||
if err := cleanupOrphanedIDDirs(ctx, cleanup.cntrs, cleanup.base); err != nil {
|
||||
return errors.Wrap(err, cleanup.errMsg)
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ func (c *criService) loadContainer(ctx context.Context, cntr containerd.Containe
|
||||
// Load status from checkpoint.
|
||||
status, err := containerstore.LoadStatus(containerDir, id)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warnf("Failed to load container status for %q", id)
|
||||
log.G(ctx).WithError(err).Warnf("Failed to load container status for %q", id)
|
||||
status = unknownContainerStatus()
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ func (c *criService) loadContainer(ctx context.Context, cntr containerd.Containe
|
||||
return nil
|
||||
}()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to load container status for %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to load container status for %q", id)
|
||||
status = unknownContainerStatus()
|
||||
}
|
||||
opts := []containerstore.Opts{
|
||||
@@ -400,7 +400,7 @@ func (c *criService) loadSandbox(ctx context.Context, cntr containerd.Container)
|
||||
return status, nil
|
||||
}()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to load sandbox status for %q", cntr.ID())
|
||||
log.G(ctx).WithError(err).Errorf("Failed to load sandbox status for %q", cntr.ID())
|
||||
}
|
||||
|
||||
sandbox = sandboxstore.NewSandbox(*meta, s)
|
||||
@@ -425,32 +425,32 @@ func (c *criService) loadImages(ctx context.Context, cImages []containerd.Image)
|
||||
for _, i := range cImages {
|
||||
ok, _, _, _, err := containerdimages.Check(ctx, i.ContentStore(), i.Target(), platforms.Default())
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to check image content readiness for %q", i.Name())
|
||||
log.G(ctx).WithError(err).Errorf("Failed to check image content readiness for %q", i.Name())
|
||||
continue
|
||||
}
|
||||
if !ok {
|
||||
logrus.Warnf("The image content readiness for %q is not ok", i.Name())
|
||||
log.G(ctx).Warnf("The image content readiness for %q is not ok", i.Name())
|
||||
continue
|
||||
}
|
||||
// Checking existence of top-level snapshot for each image being recovered.
|
||||
unpacked, err := i.IsUnpacked(ctx, snapshotter)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warnf("Failed to check whether image is unpacked for image %s", i.Name())
|
||||
log.G(ctx).WithError(err).Warnf("Failed to check whether image is unpacked for image %s", i.Name())
|
||||
continue
|
||||
}
|
||||
if !unpacked {
|
||||
logrus.Warnf("The image %s is not unpacked.", i.Name())
|
||||
log.G(ctx).Warnf("The image %s is not unpacked.", i.Name())
|
||||
// TODO(random-liu): Consider whether we should try unpack here.
|
||||
}
|
||||
if err := c.updateImage(ctx, i.Name()); err != nil {
|
||||
logrus.WithError(err).Warnf("Failed to update reference for image %q", i.Name())
|
||||
log.G(ctx).WithError(err).Warnf("Failed to update reference for image %q", i.Name())
|
||||
continue
|
||||
}
|
||||
logrus.Debugf("Loaded image %q", i.Name())
|
||||
log.G(ctx).Debugf("Loaded image %q", i.Name())
|
||||
}
|
||||
}
|
||||
|
||||
func cleanupOrphanedIDDirs(cntrs []containerd.Container, base string) error {
|
||||
func cleanupOrphanedIDDirs(ctx context.Context, cntrs []containerd.Container, base string) error {
|
||||
// Cleanup orphaned id directories.
|
||||
dirs, err := ioutil.ReadDir(base)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
@@ -462,7 +462,7 @@ func cleanupOrphanedIDDirs(cntrs []containerd.Container, base string) error {
|
||||
}
|
||||
for _, d := range dirs {
|
||||
if !d.IsDir() {
|
||||
logrus.Warnf("Invalid file %q found in base directory %q", d.Name(), base)
|
||||
log.G(ctx).Warnf("Invalid file %q found in base directory %q", d.Name(), base)
|
||||
continue
|
||||
}
|
||||
if _, ok := idsMap[d.Name()]; ok {
|
||||
@@ -471,9 +471,9 @@ func cleanupOrphanedIDDirs(cntrs []containerd.Container, base string) error {
|
||||
}
|
||||
dir := filepath.Join(base, d.Name())
|
||||
if err := system.EnsureRemoveAll(dir); err != nil {
|
||||
logrus.WithError(err).Warnf("Failed to remove id directory %q", dir)
|
||||
log.G(ctx).WithError(err).Warnf("Failed to remove id directory %q", dir)
|
||||
} else {
|
||||
logrus.Debugf("Cleanup orphaned id directory %q", dir)
|
||||
log.G(ctx).Debugf("Cleanup orphaned id directory %q", dir)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
7
vendor/github.com/containerd/cri/pkg/server/sandbox_portforward.go
generated
vendored
7
vendor/github.com/containerd/cri/pkg/server/sandbox_portforward.go
generated
vendored
@@ -23,6 +23,7 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containernetworking/plugins/pkg/ns"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -48,7 +49,7 @@ func (c *criService) PortForward(ctx context.Context, r *runtime.PortForwardRequ
|
||||
// portForward requires `socat` on the node. It uses netns to enter the sandbox namespace,
|
||||
// and run `socat` insidethe namespace to forward stream for a specific port. The `socat`
|
||||
// command keeps running until it exits or client disconnect.
|
||||
func (c *criService) portForward(id string, port int32, stream io.ReadWriteCloser) error {
|
||||
func (c *criService) portForward(ctx context.Context, id string, port int32, stream io.ReadWriter) error {
|
||||
s, err := c.sandboxStore.Get(id)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to find sandbox %q in store", id)
|
||||
@@ -82,7 +83,7 @@ func (c *criService) portForward(id string, port int32, stream io.ReadWriteClose
|
||||
// Check https://linux.die.net/man/1/socat for meaning of the options.
|
||||
args := []string{socat, "-", fmt.Sprintf("TCP4:localhost:%d", port)}
|
||||
|
||||
logrus.Infof("Executing port forwarding command %q in network namespace %q", strings.Join(args, " "), netNSPath)
|
||||
log.G(ctx).Infof("Executing port forwarding command %q in network namespace %q", strings.Join(args, " "), netNSPath)
|
||||
err = netNSDo(func(_ ns.NetNS) error {
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
cmd.Stdout = stream
|
||||
@@ -119,7 +120,7 @@ func (c *criService) portForward(id string, port int32, stream io.ReadWriteClose
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to execute portforward in network namespace %q", netNSPath)
|
||||
}
|
||||
logrus.Infof("Finish port forwarding for %q port %d", id, port)
|
||||
log.G(ctx).Infof("Finish port forwarding for %q port %d", id, port)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
6
vendor/github.com/containerd/cri/pkg/server/sandbox_remove.go
generated
vendored
6
vendor/github.com/containerd/cri/pkg/server/sandbox_remove.go
generated
vendored
@@ -19,12 +19,12 @@ package server
|
||||
import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/containerd/cri/pkg/log"
|
||||
"github.com/containerd/cri/pkg/store"
|
||||
sandboxstore "github.com/containerd/cri/pkg/store/sandbox"
|
||||
)
|
||||
@@ -39,7 +39,7 @@ func (c *criService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
|
||||
r.GetPodSandboxId())
|
||||
}
|
||||
// Do not return error if the id doesn't exist.
|
||||
log.Tracef("RemovePodSandbox called for sandbox %q that does not exist",
|
||||
log.G(ctx).Tracef("RemovePodSandbox called for sandbox %q that does not exist",
|
||||
r.GetPodSandboxId())
|
||||
return &runtime.RemovePodSandboxResponse{}, nil
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func (c *criService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
|
||||
if !errdefs.IsNotFound(err) {
|
||||
return nil, errors.Wrapf(err, "failed to delete sandbox container %q", id)
|
||||
}
|
||||
log.Tracef("Remove called for sandbox container %q that does not exist", id)
|
||||
log.G(ctx).Tracef("Remove called for sandbox container %q that does not exist", id)
|
||||
}
|
||||
|
||||
// Remove sandbox from sandbox store. Note that once the sandbox is successfully
|
||||
|
||||
54
vendor/github.com/containerd/cri/pkg/server/sandbox_run.go
generated
vendored
54
vendor/github.com/containerd/cri/pkg/server/sandbox_run.go
generated
vendored
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
cni "github.com/containerd/go-cni"
|
||||
@@ -44,7 +45,6 @@ import (
|
||||
criconfig "github.com/containerd/cri/pkg/config"
|
||||
customopts "github.com/containerd/cri/pkg/containerd/opts"
|
||||
ctrdutil "github.com/containerd/cri/pkg/containerd/util"
|
||||
"github.com/containerd/cri/pkg/log"
|
||||
"github.com/containerd/cri/pkg/netns"
|
||||
sandboxstore "github.com/containerd/cri/pkg/store/sandbox"
|
||||
"github.com/containerd/cri/pkg/util"
|
||||
@@ -59,7 +59,7 @@ func init() {
|
||||
// the sandbox is in ready state.
|
||||
func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandboxRequest) (_ *runtime.RunPodSandboxResponse, retErr error) {
|
||||
config := r.GetConfig()
|
||||
logrus.Debugf("Sandbox config %+v", config)
|
||||
log.G(ctx).Debugf("Sandbox config %+v", config)
|
||||
|
||||
// Generate unique id and name for the sandbox and reserve the name.
|
||||
id := util.GenerateID()
|
||||
@@ -68,7 +68,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
return nil, errors.New("sandbox config must include metadata")
|
||||
}
|
||||
name := makeSandboxName(metadata)
|
||||
logrus.Debugf("Generated id %q for sandbox %q", id, name)
|
||||
log.G(ctx).Debugf("Generated id %q for sandbox %q", id, name)
|
||||
// Reserve the sandbox name to avoid concurrent `RunPodSandbox` request starting the
|
||||
// same sandbox.
|
||||
if err := c.sandboxNameIndex.Reserve(name, id); err != nil {
|
||||
@@ -108,7 +108,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get sandbox runtime")
|
||||
}
|
||||
logrus.Debugf("Use OCI %+v for sandbox %q", ociRuntime, id)
|
||||
log.G(ctx).Debugf("Use OCI %+v for sandbox %q", ociRuntime, id)
|
||||
|
||||
securityContext := config.GetLinux().GetSecurityContext()
|
||||
//Create Network Namespace if it is not in host network
|
||||
@@ -126,7 +126,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
if err := sandbox.NetNS.Remove(); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to remove network namespace %s for sandbox %q", sandbox.NetNSPath, id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to remove network namespace %s for sandbox %q", sandbox.NetNSPath, id)
|
||||
}
|
||||
sandbox.NetNSPath = ""
|
||||
}
|
||||
@@ -139,15 +139,15 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
// In this case however caching the IP will add a subtle performance enhancement by avoiding
|
||||
// calls to network namespace of the pod to query the IP of the veth interface on every
|
||||
// SandboxStatus request.
|
||||
sandbox.IP, sandbox.CNIResult, err = c.setupPod(id, sandbox.NetNSPath, config)
|
||||
sandbox.IP, sandbox.CNIResult, err = c.setupPod(ctx, id, sandbox.NetNSPath, config)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to setup network for sandbox %q", id)
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
// Teardown network if an error is returned.
|
||||
if err := c.teardownPod(id, sandbox.NetNSPath, config); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to destroy network for sandbox %q", id)
|
||||
if err := c.teardownPod(ctx, id, sandbox.NetNSPath, config); err != nil {
|
||||
log.G(ctx).WithError(err).Errorf("Failed to destroy network for sandbox %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -158,7 +158,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to generate sandbox container spec")
|
||||
}
|
||||
logrus.Debugf("Sandbox container %q spec: %#+v", id, spew.NewFormatter(spec))
|
||||
log.G(ctx).Debugf("Sandbox container %q spec: %#+v", id, spew.NewFormatter(spec))
|
||||
|
||||
var specOpts []oci.SpecOpts
|
||||
userstr, err := generateUserString(
|
||||
@@ -169,6 +169,11 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to generate user string")
|
||||
}
|
||||
if userstr == "" {
|
||||
// Lastly, since no user override was passed via CRI try to set via OCI
|
||||
// Image
|
||||
userstr = image.ImageSpec.Config.User
|
||||
}
|
||||
if userstr != "" {
|
||||
specOpts = append(specOpts, oci.WithUser(userstr))
|
||||
}
|
||||
@@ -207,7 +212,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
deferCtx, deferCancel := ctrdutil.DeferContext()
|
||||
defer deferCancel()
|
||||
if err := container.Delete(deferCtx, containerd.WithSnapshotCleanup); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to delete containerd container %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to delete containerd container %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -222,7 +227,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
if retErr != nil {
|
||||
// Cleanup the sandbox root directory.
|
||||
if err := c.os.RemoveAll(sandboxRootDir); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to remove sandbox root directory %q",
|
||||
log.G(ctx).WithError(err).Errorf("Failed to remove sandbox root directory %q",
|
||||
sandboxRootDir)
|
||||
}
|
||||
}
|
||||
@@ -236,7 +241,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
if retErr != nil {
|
||||
// Cleanup the volatile sandbox root directory.
|
||||
if err := c.os.RemoveAll(volatileSandboxRootDir); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to remove volatile sandbox root directory %q",
|
||||
log.G(ctx).WithError(err).Errorf("Failed to remove volatile sandbox root directory %q",
|
||||
volatileSandboxRootDir)
|
||||
}
|
||||
}
|
||||
@@ -249,7 +254,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
if err = c.unmountSandboxFiles(id, config); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to unmount sandbox files in %q",
|
||||
log.G(ctx).WithError(err).Errorf("Failed to unmount sandbox files in %q",
|
||||
sandboxRootDir)
|
||||
}
|
||||
}
|
||||
@@ -262,7 +267,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
}
|
||||
|
||||
// Create sandbox task in containerd.
|
||||
log.Tracef("Create sandbox container (id=%q, name=%q).",
|
||||
log.G(ctx).Tracef("Create sandbox container (id=%q, name=%q).",
|
||||
id, name)
|
||||
|
||||
var taskOpts []containerd.NewTaskOpts
|
||||
@@ -281,7 +286,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
defer deferCancel()
|
||||
// Cleanup the sandbox container if an error is returned.
|
||||
if _, err := task.Delete(deferCtx, containerd.WithProcessKill); err != nil && !errdefs.IsNotFound(err) {
|
||||
logrus.WithError(err).Errorf("Failed to delete sandbox container %q", id)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to delete sandbox container %q", id)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -352,8 +357,7 @@ func (c *criService) generateSandboxContainerSpec(id string, config *runtime.Pod
|
||||
specOpts = append(specOpts, customopts.WithDisabledCgroups)
|
||||
} else {
|
||||
if config.GetLinux().GetCgroupParent() != "" {
|
||||
cgroupsPath := getCgroupsPath(config.GetLinux().GetCgroupParent(), id,
|
||||
c.config.SystemdCgroup)
|
||||
cgroupsPath := getCgroupsPath(config.GetLinux().GetCgroupParent(), id)
|
||||
specOpts = append(specOpts, oci.WithCgroup(cgroupsPath))
|
||||
}
|
||||
}
|
||||
@@ -541,7 +545,7 @@ func (c *criService) unmountSandboxFiles(id string, config *runtime.PodSandboxCo
|
||||
}
|
||||
|
||||
// setupPod setups up the network for a pod
|
||||
func (c *criService) setupPod(id string, path string, config *runtime.PodSandboxConfig) (string, *cni.CNIResult, error) {
|
||||
func (c *criService) setupPod(ctx context.Context, id string, path string, config *runtime.PodSandboxConfig) (string, *cni.CNIResult, error) {
|
||||
if c.netPlugin == nil {
|
||||
return "", nil, errors.New("cni config not initialized")
|
||||
}
|
||||
@@ -555,7 +559,7 @@ func (c *criService) setupPod(id string, path string, config *runtime.PodSandbox
|
||||
return "", nil, errors.Wrap(err, "failed to get bandwidth info from annotations")
|
||||
}
|
||||
|
||||
result, err := c.netPlugin.Setup(id,
|
||||
result, err := c.netPlugin.Setup(ctx, id,
|
||||
path,
|
||||
cni.WithLabels(labels),
|
||||
cni.WithCapabilityPortMap(toCNIPortMappings(config.GetPortMappings())),
|
||||
@@ -565,14 +569,14 @@ func (c *criService) setupPod(id string, path string, config *runtime.PodSandbox
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
logDebugCNIResult(id, result)
|
||||
logDebugCNIResult(ctx, id, result)
|
||||
// Check if the default interface has IP config
|
||||
if configs, ok := result.Interfaces[defaultIfName]; ok && len(configs.IPConfigs) > 0 {
|
||||
return selectPodIP(configs.IPConfigs), result, nil
|
||||
}
|
||||
// If it comes here then the result was invalid so destroy the pod network and return error
|
||||
if err := c.teardownPod(id, path, config); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to destroy network for sandbox %q", id)
|
||||
if err := c.teardownPod(ctx, id, path, config); err != nil {
|
||||
log.G(ctx).WithError(err).Errorf("Failed to destroy network for sandbox %q", id)
|
||||
}
|
||||
return "", result, errors.Errorf("failed to find network info for sandbox %q", id)
|
||||
}
|
||||
@@ -682,14 +686,14 @@ func (c *criService) getSandboxRuntime(config *runtime.PodSandboxConfig, runtime
|
||||
return handler, nil
|
||||
}
|
||||
|
||||
func logDebugCNIResult(sandboxID string, result *cni.CNIResult) {
|
||||
func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.CNIResult) {
|
||||
if logrus.GetLevel() < logrus.DebugLevel {
|
||||
return
|
||||
}
|
||||
cniResult, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to marshal CNI result for sandbox %q: %v", sandboxID, err)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to marshal CNI result for sandbox %q: %v", sandboxID, err)
|
||||
return
|
||||
}
|
||||
logrus.Debugf("cni result for sandbox %q: %s", sandboxID, string(cniResult))
|
||||
log.G(ctx).Debugf("cni result for sandbox %q: %s", sandboxID, string(cniResult))
|
||||
}
|
||||
|
||||
10
vendor/github.com/containerd/cri/pkg/server/sandbox_stop.go
generated
vendored
10
vendor/github.com/containerd/cri/pkg/server/sandbox_stop.go
generated
vendored
@@ -22,9 +22,9 @@ import (
|
||||
|
||||
eventtypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
cni "github.com/containerd/go-cni"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
@@ -80,7 +80,7 @@ func (c *criService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandb
|
||||
} else if closed {
|
||||
netNSPath = ""
|
||||
}
|
||||
if err := c.teardownPod(id, netNSPath, sandbox.Config); err != nil {
|
||||
if err := c.teardownPod(ctx, id, netNSPath, sandbox.Config); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to destroy network for sandbox %q", id)
|
||||
}
|
||||
if err = sandbox.NetNS.Remove(); err != nil {
|
||||
@@ -88,7 +88,7 @@ func (c *criService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandb
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Infof("TearDown network for sandbox %q successfully", id)
|
||||
log.G(ctx).Infof("TearDown network for sandbox %q successfully", id)
|
||||
|
||||
return &runtime.StopPodSandboxResponse{}, nil
|
||||
}
|
||||
@@ -157,13 +157,13 @@ func (c *criService) waitSandboxStop(ctx context.Context, sandbox sandboxstore.S
|
||||
}
|
||||
|
||||
// teardownPod removes the network from the pod
|
||||
func (c *criService) teardownPod(id string, path string, config *runtime.PodSandboxConfig) error {
|
||||
func (c *criService) teardownPod(ctx context.Context, id string, path string, config *runtime.PodSandboxConfig) error {
|
||||
if c.netPlugin == nil {
|
||||
return errors.New("cni config not initialized")
|
||||
}
|
||||
|
||||
labels := getPodCNILabels(id, config)
|
||||
return c.netPlugin.Remove(id,
|
||||
return c.netPlugin.Remove(ctx, id,
|
||||
path,
|
||||
cni.WithLabels(labels),
|
||||
cni.WithCapabilityPortMap(toCNIPortMappings(config.GetPortMappings())))
|
||||
|
||||
6
vendor/github.com/containerd/cri/pkg/server/status.go
generated
vendored
6
vendor/github.com/containerd/cri/pkg/server/status.go
generated
vendored
@@ -21,8 +21,8 @@ import (
|
||||
"fmt"
|
||||
goruntime "runtime"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
cni "github.com/containerd/go-cni"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
)
|
||||
@@ -45,7 +45,7 @@ func (c *criService) Status(ctx context.Context, r *runtime.StatusRequest) (*run
|
||||
|
||||
// Load the latest cni configuration to be in sync with the latest network configuration
|
||||
if err := c.netPlugin.Load(cni.WithLoNetwork, cni.WithDefaultConf); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to load cni configuration")
|
||||
log.G(ctx).WithError(err).Errorf("Failed to load cni configuration")
|
||||
}
|
||||
// Check the status of the cni initialization
|
||||
if err := c.netPlugin.Status(); err != nil {
|
||||
@@ -75,7 +75,7 @@ func (c *criService) Status(ctx context.Context, r *runtime.StatusRequest) (*run
|
||||
|
||||
cniConfig, err := json.Marshal(c.netPlugin.GetConfig())
|
||||
if err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to marshal CNI config %v", err)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to marshal CNI config %v", err)
|
||||
}
|
||||
resp.Info["cniconfig"] = string(cniConfig)
|
||||
}
|
||||
|
||||
3
vendor/github.com/containerd/cri/pkg/server/streaming.go
generated
vendored
3
vendor/github.com/containerd/cri/pkg/server/streaming.go
generated
vendored
@@ -25,6 +25,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
k8snet "k8s.io/apimachinery/pkg/util/net"
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
@@ -155,7 +156,7 @@ func (s *streamRuntime) PortForward(podSandboxID string, port int32, stream io.R
|
||||
if port <= 0 || port > math.MaxUint16 {
|
||||
return errors.Errorf("invalid port %d", port)
|
||||
}
|
||||
return s.c.portForward(podSandboxID, port, stream)
|
||||
return s.c.portForward(context.Background(), podSandboxID, port, stream)
|
||||
}
|
||||
|
||||
// handleResizing spawns a goroutine that processes the resize channel, calling resizeFunc for each
|
||||
|
||||
10
vendor/github.com/containerd/cri/pkg/server/update_runtime_config.go
generated
vendored
10
vendor/github.com/containerd/cri/pkg/server/update_runtime_config.go
generated
vendored
@@ -21,9 +21,9 @@ import (
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
cni "github.com/containerd/go-cni"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
)
|
||||
@@ -46,17 +46,17 @@ func (c *criService) UpdateRuntimeConfig(ctx context.Context, r *runtime.UpdateR
|
||||
}
|
||||
confTemplate := c.config.NetworkPluginConfTemplate
|
||||
if confTemplate == "" {
|
||||
logrus.Info("No cni config template is specified, wait for other system components to drop the config.")
|
||||
log.G(ctx).Info("No cni config template is specified, wait for other system components to drop the config.")
|
||||
return &runtime.UpdateRuntimeConfigResponse{}, nil
|
||||
}
|
||||
if err := c.netPlugin.Status(); err == nil {
|
||||
logrus.Infof("Network plugin is ready, skip generating cni config from template %q", confTemplate)
|
||||
log.G(ctx).Infof("Network plugin is ready, skip generating cni config from template %q", confTemplate)
|
||||
return &runtime.UpdateRuntimeConfigResponse{}, nil
|
||||
} else if err := c.netPlugin.Load(cni.WithLoNetwork, cni.WithDefaultConf); err == nil {
|
||||
logrus.Infof("CNI config is successfully loaded, skip generating cni config from template %q", confTemplate)
|
||||
log.G(ctx).Infof("CNI config is successfully loaded, skip generating cni config from template %q", confTemplate)
|
||||
return &runtime.UpdateRuntimeConfigResponse{}, nil
|
||||
}
|
||||
logrus.Infof("Generating cni config from template %q", confTemplate)
|
||||
log.G(ctx).Infof("Generating cni config from template %q", confTemplate)
|
||||
// generate cni config file from the template with updated pod cidr.
|
||||
t, err := template.ParseFiles(confTemplate)
|
||||
if err != nil {
|
||||
|
||||
142
vendor/github.com/containerd/cri/vendor.conf
generated
vendored
142
vendor/github.com/containerd/cri/vendor.conf
generated
vendored
@@ -1,72 +1,80 @@
|
||||
github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/containerd/cgroups db272301ab8449d05f062e6db6f13d8a6aaff466
|
||||
github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f
|
||||
github.com/containerd/containerd 31afff294400b5a69bdb3ec387ecdf5bad57a038
|
||||
github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4
|
||||
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
|
||||
github.com/containerd/go-cni 22460c018b64cf8bf4151b3ff9c4d077e6a88cbf
|
||||
github.com/containerd/go-runc 5a6d9f37cfa36b15efba46dc7ea349fa9b7143c3
|
||||
github.com/containerd/ttrpc a5bd8ce9e40bc7c065a11c6936f4d032ce6bfa2b
|
||||
github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40
|
||||
github.com/containernetworking/cni v0.6.0
|
||||
github.com/containernetworking/plugins v0.7.5
|
||||
github.com/coreos/go-systemd v14
|
||||
github.com/davecgh/go-spew v1.1.0
|
||||
github.com/docker/distribution 0d3efadf0154c2b8a4e7b6621fff9809655cc580
|
||||
github.com/docker/docker 86f080cff0914e9694068ed78d503701667c4c00
|
||||
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
|
||||
github.com/docker/go-metrics 4ea375f7759c82740c893fc030bc37088d2ec098
|
||||
github.com/docker/go-units v0.4.0
|
||||
github.com/docker/spdystream 449fdfce4d962303d702fec724ef0ad181c92528
|
||||
github.com/emicklei/go-restful v2.2.1
|
||||
github.com/godbus/dbus v3
|
||||
github.com/gogo/googleapis v1.2.0
|
||||
github.com/gogo/protobuf v1.2.1
|
||||
github.com/golang/protobuf v1.2.0
|
||||
github.com/google/gofuzz 44d81051d367757e1c7c6a5a86423ece9afcf63c
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.1
|
||||
github.com/json-iterator/go 1.1.5
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1
|
||||
github.com/Microsoft/go-winio 84b4ab48a50763fe7b3abcef38e5205c12027fac
|
||||
github.com/Microsoft/hcsshim 8abdbb8205e4192c68b5f84c31197156f31be517
|
||||
github.com/modern-go/concurrent 1.0.3
|
||||
github.com/modern-go/reflect2 1.0.1
|
||||
github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7
|
||||
github.com/opencontainers/image-spec v1.0.1
|
||||
github.com/opencontainers/runc v1.0.0-rc8
|
||||
github.com/opencontainers/runtime-spec 29686dbc5559d93fb1ef402eeda3e35c38d75af4
|
||||
github.com/opencontainers/selinux v1.2.2
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/pmezard/go-difflib v1.0.0
|
||||
github.com/prometheus/client_golang f4fb1b73fb099f396a7f0036bf86aa8def4ed823
|
||||
github.com/prometheus/client_model 99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c
|
||||
github.com/prometheus/common 89604d197083d4781071d3c65855d24ecfb0a563
|
||||
github.com/prometheus/procfs cb4147076ac75738c9a7d279075a253c0cc5acbd
|
||||
github.com/seccomp/libseccomp-golang v0.9.1
|
||||
github.com/sirupsen/logrus v1.4.1
|
||||
github.com/stretchr/testify v1.1.4
|
||||
github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2
|
||||
# cri dependencies
|
||||
github.com/tchap/go-patricia v2.2.6
|
||||
github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
|
||||
github.com/opencontainers/selinux v1.2.2
|
||||
github.com/docker/docker 86f080cff0914e9694068ed78d503701667c4c00
|
||||
github.com/docker/distribution 0d3efadf0154c2b8a4e7b6621fff9809655cc580
|
||||
|
||||
# containerd dependencies
|
||||
go.etcd.io/bbolt 2eb7227adea1d5cf85f0bc2a82b7059b13c2fa68
|
||||
golang.org/x/crypto 88737f569e3a9c7ab309cdc09a07fe7fc87233c3
|
||||
golang.org/x/net f3200d17e092c607f615320ecaad13d87ad9a2b3
|
||||
golang.org/x/oauth2 a6bd8cefa1811bd24b86f8902872e4e8225f74c4
|
||||
golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e
|
||||
golang.org/x/sys 4c4f7f33c9ed00de01c4c741d2177abfcfe19307 https://github.com/golang/sys
|
||||
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
|
||||
golang.org/x/time f51c12702a4d776e4c1fa9b0fabab841babae631
|
||||
google.golang.org/grpc 25c4f928eaa6d96443009bd842389fb4fa48664e # v1.20.1
|
||||
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
|
||||
google.golang.org/grpc 25c4f928eaa6d96443009bd842389fb4fa48664e
|
||||
gopkg.in/inf.v0 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4
|
||||
gopkg.in/yaml.v2 v2.2.1
|
||||
k8s.io/api kubernetes-1.15.0
|
||||
k8s.io/apimachinery kubernetes-1.15.0
|
||||
k8s.io/apiserver kubernetes-1.15.0
|
||||
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
|
||||
golang.org/x/sys 4c4f7f33c9ed00de01c4c741d2177abfcfe19307 https://github.com/golang/sys
|
||||
golang.org/x/sync 42b317875d0fa942474b76e1b46a6060d720ae6e
|
||||
golang.org/x/net f3200d17e092c607f615320ecaad13d87ad9a2b3
|
||||
github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
|
||||
github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2
|
||||
github.com/sirupsen/logrus v1.4.1
|
||||
github.com/prometheus/procfs cb4147076ac75738c9a7d279075a253c0cc5acbd
|
||||
github.com/prometheus/common 89604d197083d4781071d3c65855d24ecfb0a563
|
||||
github.com/prometheus/client_model 99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c
|
||||
github.com/prometheus/client_golang f4fb1b73fb099f396a7f0036bf86aa8def4ed823
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/opencontainers/runtime-spec 29686dbc5559d93fb1ef402eeda3e35c38d75af4 # v1.0.1-59-g29686db
|
||||
github.com/opencontainers/runc f4982d86f7fde0b6f953cc62ccc4022c519a10a9 # v1.0.0-rc8-32-gf4982d86
|
||||
github.com/opencontainers/image-spec v1.0.1
|
||||
github.com/opencontainers/go-digest c9281466c8b2f606084ac71339773efd177436e7
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.1
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/golang/protobuf v1.2.0
|
||||
github.com/gogo/protobuf v1.2.1
|
||||
github.com/gogo/googleapis v1.2.0
|
||||
github.com/godbus/dbus v3
|
||||
github.com/docker/go-units v0.4.0
|
||||
github.com/docker/go-metrics 4ea375f7759c82740c893fc030bc37088d2ec098
|
||||
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
|
||||
github.com/coreos/go-systemd v14
|
||||
github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40
|
||||
github.com/containerd/ttrpc 1fb3814edf44a76e0ccf503decf726d994919a9a
|
||||
github.com/containerd/go-runc 9007c2405372fe28918845901a3276c0915689a1
|
||||
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
|
||||
github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4
|
||||
github.com/containerd/containerd a3a30635ef713b544ea7feff0d12a768fd1ed636
|
||||
github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f
|
||||
github.com/containerd/cgroups c4b9ac5c7601384c965b9646fc515884e091ebb9
|
||||
github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
|
||||
github.com/Microsoft/hcsshim 8abdbb8205e4192c68b5f84c31197156f31be517
|
||||
github.com/Microsoft/go-winio v0.4.14
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
|
||||
# kubernetes dependencies
|
||||
sigs.k8s.io/yaml v1.1.0
|
||||
k8s.io/utils c2654d5206da6b7b6ace12841e8f359bb89b443c
|
||||
k8s.io/kubernetes v1.15.0
|
||||
k8s.io/klog v0.3.1
|
||||
k8s.io/cri-api kubernetes-1.15.0
|
||||
k8s.io/client-go kubernetes-1.15.0
|
||||
k8s.io/klog v0.3.1
|
||||
k8s.io/kubernetes v1.15.0
|
||||
k8s.io/utils c2654d5206da6b7b6ace12841e8f359bb89b443c
|
||||
sigs.k8s.io/yaml v1.1.0
|
||||
k8s.io/api kubernetes-1.15.0
|
||||
k8s.io/apiserver kubernetes-1.15.0
|
||||
k8s.io/apimachinery kubernetes-1.15.0
|
||||
gopkg.in/yaml.v2 v2.2.1
|
||||
gopkg.in/inf.v0 v0.9.0
|
||||
golang.org/x/time f51c12702a4d776e4c1fa9b0fabab841babae631
|
||||
golang.org/x/oauth2 9f3314589c9a9136388751d9adae6b0ed400978a
|
||||
golang.org/x/crypto 88737f569e3a9c7ab309cdc09a07fe7fc87233c3
|
||||
github.com/stretchr/testify v1.2.2
|
||||
github.com/seccomp/libseccomp-golang v0.9.1
|
||||
github.com/pmezard/go-difflib v1.0.0
|
||||
github.com/modern-go/reflect2 1.0.1
|
||||
github.com/modern-go/concurrent 1.0.3
|
||||
github.com/json-iterator/go 1.1.5
|
||||
github.com/google/gofuzz 24818f796faf91cd76ec7bddd72458fbced7a6c1
|
||||
github.com/emicklei/go-restful v2.2.1
|
||||
github.com/docker/spdystream 449fdfce4d962303d702fec724ef0ad181c92528
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
|
||||
# cni dependencies
|
||||
github.com/containernetworking/plugins v0.7.6
|
||||
github.com/containernetworking/cni v0.7.1
|
||||
github.com/containerd/go-cni 49fbd9b210f3c8ee3b7fd3cd797aabaf364627c1
|
||||
|
||||
4
vendor/github.com/containerd/go-cni/README.md
generated
vendored
4
vendor/github.com/containerd/go-cni/README.md
generated
vendored
@@ -12,7 +12,7 @@ A generic CNI library to provide APIs for CNI plugin interactions. The library p
|
||||
go-cni aims to support plugins that implement [Container Network Interface](https://github.com/containernetworking/cni)
|
||||
|
||||
## Usage
|
||||
```
|
||||
```go
|
||||
func main() {
|
||||
id := "123456"
|
||||
netns := "/proc/9999/ns/net"
|
||||
@@ -24,7 +24,7 @@ func main() {
|
||||
gocni.WithDefaultIfName(defaultIfName))
|
||||
|
||||
// Load the cni configuration
|
||||
err:= l.Load(gocni.WithLoNetwork,gocni.WithDefaultConf)
|
||||
err:= l.Load(gocni.WithLoNetwork, gocni.WithDefaultConf)
|
||||
if err != nil{
|
||||
log.Errorf("failed to load cni configuration: %v", err)
|
||||
return
|
||||
|
||||
13
vendor/github.com/containerd/go-cni/cni.go
generated
vendored
13
vendor/github.com/containerd/go-cni/cni.go
generated
vendored
@@ -17,6 +17,7 @@
|
||||
package cni
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -29,9 +30,9 @@ import (
|
||||
|
||||
type CNI interface {
|
||||
// Setup setup the network for the namespace
|
||||
Setup(id string, path string, opts ...NamespaceOpts) (*CNIResult, error)
|
||||
Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*CNIResult, error)
|
||||
// Remove tears down the network of the namespace.
|
||||
Remove(id string, path string, opts ...NamespaceOpts) error
|
||||
Remove(ctx context.Context, id string, path string, opts ...NamespaceOpts) error
|
||||
// Load loads the cni network config
|
||||
Load(opts ...CNIOpt) error
|
||||
// Status checks the status of the cni initialization
|
||||
@@ -139,7 +140,7 @@ func (c *libcni) Networks() []*Network {
|
||||
}
|
||||
|
||||
// Setup setups the network in the namespace
|
||||
func (c *libcni) Setup(id string, path string, opts ...NamespaceOpts) (*CNIResult, error) {
|
||||
func (c *libcni) Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*CNIResult, error) {
|
||||
if err := c.Status(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -149,7 +150,7 @@ func (c *libcni) Setup(id string, path string, opts ...NamespaceOpts) (*CNIResul
|
||||
}
|
||||
var results []*current.Result
|
||||
for _, network := range c.Networks() {
|
||||
r, err := network.Attach(ns)
|
||||
r, err := network.Attach(ctx, ns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -159,7 +160,7 @@ func (c *libcni) Setup(id string, path string, opts ...NamespaceOpts) (*CNIResul
|
||||
}
|
||||
|
||||
// Remove removes the network config from the namespace
|
||||
func (c *libcni) Remove(id string, path string, opts ...NamespaceOpts) error {
|
||||
func (c *libcni) Remove(ctx context.Context, id string, path string, opts ...NamespaceOpts) error {
|
||||
if err := c.Status(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -168,7 +169,7 @@ func (c *libcni) Remove(id string, path string, opts ...NamespaceOpts) error {
|
||||
return err
|
||||
}
|
||||
for _, network := range c.Networks() {
|
||||
if err := network.Remove(ns); err != nil {
|
||||
if err := network.Remove(ctx, ns); err != nil {
|
||||
// Based on CNI spec v0.7.0, empty network namespace is allowed to
|
||||
// do best effort cleanup. However, it is not handled consistently
|
||||
// right now:
|
||||
|
||||
4
vendor/github.com/containerd/go-cni/helper.go
generated
vendored
4
vendor/github.com/containerd/go-cni/helper.go
generated
vendored
@@ -24,10 +24,10 @@ import (
|
||||
|
||||
func validateInterfaceConfig(ipConf *current.IPConfig, ifs int) error {
|
||||
if ipConf == nil {
|
||||
return fmt.Errorf("invalid IP configuration")
|
||||
return fmt.Errorf("invalid IP configuration (nil)")
|
||||
}
|
||||
if ipConf.Interface != nil && *ipConf.Interface > ifs {
|
||||
return fmt.Errorf("invalid IP configuration with invalid interface %d", *ipConf.Interface)
|
||||
return fmt.Errorf("invalid IP configuration (interface number %d is > number of interfaces %d)", *ipConf.Interface, ifs)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
10
vendor/github.com/containerd/go-cni/namespace.go
generated
vendored
10
vendor/github.com/containerd/go-cni/namespace.go
generated
vendored
@@ -17,6 +17,8 @@
|
||||
package cni
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
cnilibrary "github.com/containernetworking/cni/libcni"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
)
|
||||
@@ -27,16 +29,16 @@ type Network struct {
|
||||
ifName string
|
||||
}
|
||||
|
||||
func (n *Network) Attach(ns *Namespace) (*current.Result, error) {
|
||||
r, err := n.cni.AddNetworkList(n.config, ns.config(n.ifName))
|
||||
func (n *Network) Attach(ctx context.Context, ns *Namespace) (*current.Result, error) {
|
||||
r, err := n.cni.AddNetworkList(ctx, n.config, ns.config(n.ifName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return current.NewResultFromResult(r)
|
||||
}
|
||||
|
||||
func (n *Network) Remove(ns *Namespace) error {
|
||||
return n.cni.DelNetworkList(n.config, ns.config(n.ifName))
|
||||
func (n *Network) Remove(ctx context.Context, ns *Namespace) error {
|
||||
return n.cni.DelNetworkList(ctx, n.config, ns.config(n.ifName))
|
||||
}
|
||||
|
||||
type Namespace struct {
|
||||
|
||||
4
vendor/github.com/containerd/go-cni/opts.go
generated
vendored
4
vendor/github.com/containerd/go-cni/opts.go
generated
vendored
@@ -220,11 +220,11 @@ func loadFromConfDir(c *libcni, max int) error {
|
||||
|
||||
confList, err = cnilibrary.ConfListFromConf(conf)
|
||||
if err != nil {
|
||||
return errors.Wrapf(ErrInvalidConfig, "failed to convert CNI config file %s to list: %v", confFile, err)
|
||||
return errors.Wrapf(ErrInvalidConfig, "failed to convert CNI config file %s to CNI config list: %v", confFile, err)
|
||||
}
|
||||
}
|
||||
if len(confList.Plugins) == 0 {
|
||||
return errors.Wrapf(ErrInvalidConfig, "CNI config list %s has no networks, skipping", confFile)
|
||||
return errors.Wrapf(ErrInvalidConfig, "CNI config list in config file %s has no networks, skipping", confFile)
|
||||
|
||||
}
|
||||
networks = append(networks, &Network{
|
||||
|
||||
4
vendor/github.com/containerd/go-cni/result.go
generated
vendored
4
vendor/github.com/containerd/go-cni/result.go
generated
vendored
@@ -79,7 +79,7 @@ func (c *libcni) GetCNIResultFromResults(results []*current.Result) (*CNIResult,
|
||||
// interfaces
|
||||
for _, ipConf := range result.IPs {
|
||||
if err := validateInterfaceConfig(ipConf, len(result.Interfaces)); err != nil {
|
||||
return nil, errors.Wrapf(ErrInvalidResult, "failed to valid interface config: %v", err)
|
||||
return nil, errors.Wrapf(ErrInvalidResult, "invalid interface config: %v", err)
|
||||
}
|
||||
name := c.getInterfaceName(result.Interfaces, ipConf)
|
||||
r.Interfaces[name].IPConfigs = append(r.Interfaces[name].IPConfigs,
|
||||
@@ -89,7 +89,7 @@ func (c *libcni) GetCNIResultFromResults(results []*current.Result) (*CNIResult,
|
||||
r.Routes = append(r.Routes, result.Routes...)
|
||||
}
|
||||
if _, ok := r.Interfaces[defaultInterface(c.prefix)]; !ok {
|
||||
return nil, errors.Wrapf(ErrNotFound, "default network not found")
|
||||
return nil, errors.Wrapf(ErrNotFound, "default network not found for: %s", defaultInterface(c.prefix))
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
2
vendor/github.com/containerd/go-cni/vendor.conf
generated
vendored
2
vendor/github.com/containerd/go-cni/vendor.conf
generated
vendored
@@ -2,5 +2,5 @@ github.com/stretchr/testify b89eecf5ca5db6d3ba60b237ffe3df7bafb7662f
|
||||
github.com/davecgh/go-spew 8991bc29aa16c548c550c7ff78260e27b9ab7c73
|
||||
github.com/pmezard/go-difflib 792786c7400a136282c1664665ae0a8db921c6c2
|
||||
github.com/stretchr/objx 8a3f7159479fbc75b30357fbc48f380b7320f08e
|
||||
github.com/containernetworking/cni 142cde0c766cd6055cc7fdfdcb44579c0c9c35bf
|
||||
github.com/containernetworking/cni v0.7.1
|
||||
github.com/pkg/errors v0.8.0
|
||||
|
||||
Reference in New Issue
Block a user