Update containerd to v1.6.9 (rhbz#2137464).

* Update 0002-Remove-windows... since it no longer applies
* Update 0001-Use-typeurl.Any.. since it no longer applies
* Use https://github.com/containerd/containerd/pull/6706 for
reference
This commit is contained in:
Dalton Hubble 2022-10-24 22:22:47 -07:00 committed by Maxwell G
parent 87f8204225
commit 8fa6e67b49
4 changed files with 255 additions and 97 deletions

View File

@ -1,56 +1,3 @@
From bdf3fc2b4bfea5ee3f91c5c2758c5154f95d27ad Mon Sep 17 00:00:00 2001
From: Kazuyoshi Kato <katokazu@amazon.com>
Date: Tue, 22 Mar 2022 00:40:39 +0000
Subject: [PATCH] Use typeurl.Any instead of github.com/gogo/protobuf/types.Any
This commit upgrades github.com/containerd/typeurl to use typeurl.Any.
The interface hides gogo/protobuf/types.Any from containerd's Go client.
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
---
cmd/containerd-shim/main_unix.go | 4 +-
cmd/ctr/commands/containers/containers.go | 2 +-
cmd/ctr/commands/tasks/kill.go | 29 ++++++
container.go | 10 +-
container_checkpoint_opts.go | 9 +-
container_opts.go | 10 +-
containers/containers.go | 8 +-
containerstore.go | 19 +++-
events.go | 5 +-
events/events.go | 3 +-
events/exchange/exchange.go | 8 +-
go.mod | 2 +-
go.sum | 3 +-
integration/client/container_test.go | 8 +-
integration/client/go.mod | 2 +-
integration/client/go.sum | 3 +-
metadata/boltutil/helpers.go | 20 ++--
metadata/containers.go | 3 +-
metadata/containers_test.go | 83 ++++++++++-------
pkg/cri/server/events.go | 3 +-
pkg/cri/server/helpers.go | 5 +-
pkg/cri/server/helpers_test.go | 13 +++
pkg/cri/server/restart.go | 4 +-
protobuf/any.go | 47 ++++++++++
protobuf/any_test.go | 26 ++++++
runtime/runtime.go | 8 +-
runtime/v1/linux/runtime.go | 9 +-
runtime/v1/linux/task.go | 4 +-
runtime/v1/shim/service.go | 3 +-
runtime/v2/manager.go | 7 +-
runtime/v2/runc/container.go | 6 +-
runtime/v2/runc/task/service.go | 5 +-
runtime/v2/runc/v1/service.go | 5 +-
runtime/v2/shim.go | 5 +-
runtime/v2/shim/publisher.go | 4 +-
services/containers/helpers.go | 20 +++-
services/events/service.go | 3 +-
services/tasks/local.go | 5 +-
task.go | 7 +-
42 files changed, 365 insertions(+), 150 deletions(-)
create mode 100644 protobuf/any.go
create mode 100644 protobuf/any_test.go
diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go
index 024611bf3..ef32ae38b 100644
--- a/cmd/containerd-shim/main_unix.go
@ -144,7 +91,7 @@ index 7d8d674c8..4236fecd2 100644
t := &task{
client: c.client,
diff --git a/container_checkpoint_opts.go b/container_checkpoint_opts.go
index a64ef618b..c39628535 100644
index a64ef618b..ee2fa1b97 100644
--- a/container_checkpoint_opts.go
+++ b/container_checkpoint_opts.go
@@ -28,9 +28,9 @@ import (
@ -158,7 +105,7 @@ index a64ef618b..c39628535 100644
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
)
@@ -56,7 +57,7 @@ func WithCheckpointImage(ctx context.Context, client *Client, c *containers.Cont
@@ -56,7 +56,7 @@ func WithCheckpointImage(ctx context.Context, client *Client, c *containers.Cont
// WithCheckpointTask includes the running task
func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error {
@ -167,7 +114,7 @@ index a64ef618b..c39628535 100644
if err != nil {
return nil
}
@@ -97,8 +98,8 @@ func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Conta
@@ -97,8 +97,8 @@ func WithCheckpointTask(ctx context.Context, client *Client, c *containers.Conta
// WithCheckpointRuntime includes the container runtime info
func WithCheckpointRuntime(ctx context.Context, client *Client, c *containers.Container, index *imagespec.Index, copts *options.CheckpointOptions) error {
@ -420,7 +367,7 @@ index a1f385d7a..7f085dc91 100644
if err != nil {
diff --git a/go.mod b/go.mod
index e49859e83..61cea501a 100644
index 77f07d3ae..f42acf904 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require (
@ -430,13 +377,13 @@ index e49859e83..61cea501a 100644
- github.com/containerd/typeurl v1.0.2
+ github.com/containerd/typeurl v1.0.3-0.20220324183432-6193a0e03259
github.com/containerd/zfs v1.0.0
github.com/containernetworking/cni v1.1.1
github.com/containernetworking/plugins v1.1.1
github.com/coreos/go-systemd/v22 v22.3.2
diff --git a/go.sum b/go.sum
index fa93eb9ff..dc179935a 100644
index eefcc88f7..e4816994f 100644
--- a/go.sum
+++ b/go.sum
@@ -257,8 +257,9 @@ github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Ev
@@ -260,8 +260,9 @@ github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Ev
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd/go.mod h1:GeKYzf2pQcqv7tJ0AoCuuhtnqhva5LNU3U+OyKxxJpk=
github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg=
@ -468,7 +415,7 @@ index d05ebd1ec..c12645e66 100644
}
diff --git a/integration/client/go.mod b/integration/client/go.mod
index f8aaabd20..542d2ce8f 100644
index f49dca653..bfd8b24ba 100644
--- a/integration/client/go.mod
+++ b/integration/client/go.mod
@@ -10,7 +10,7 @@ require (
@ -481,10 +428,10 @@ index f8aaabd20..542d2ce8f 100644
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
diff --git a/integration/client/go.sum b/integration/client/go.sum
index 0d6a9ef9b..f6bd8ea5b 100644
index 9ca7044a8..5351d9eb6 100644
--- a/integration/client/go.sum
+++ b/integration/client/go.sum
@@ -145,8 +145,9 @@ github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8h
@@ -146,8 +146,9 @@ github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8h
github.com/containerd/ttrpc v1.1.0 h1:GbtyLRxb0gOLR0TYQWt3O6B0NvT8tMdorEHqIQo/lWI=
github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ=
github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg=
@ -802,7 +749,7 @@ index c0192a458..7be6e0f2d 100644
func testEnv(t *testing.T) (context.Context, *bolt.DB, func()) {
diff --git a/pkg/cri/server/events.go b/pkg/cri/server/events.go
index b98dd1fd3..ca817d0fb 100644
index c8ffdadbf..fbecb29a0 100644
--- a/pkg/cri/server/events.go
+++ b/pkg/cri/server/events.go
@@ -32,7 +32,6 @@ import (
@ -823,10 +770,10 @@ index b98dd1fd3..ca817d0fb 100644
evt, err := typeurl.UnmarshalAny(e)
if err != nil {
diff --git a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go
index abc66e389..de9bdddc1 100644
index a8498116d..2b9c115e7 100644
--- a/pkg/cri/server/helpers.go
+++ b/pkg/cri/server/helpers.go
@@ -374,10 +374,11 @@ func getRuntimeOptionsType(t string) interface{} {
@@ -375,10 +375,11 @@ func getRuntimeOptionsType(t string) interface{} {
// getRuntimeOptions get runtime options from container metadata.
func getRuntimeOptions(c containers.Container) (interface{}, error) {
@ -1202,7 +1149,7 @@ index 4ad70dad3..1d6ff1714 100644
}
diff --git a/runtime/v2/runc/v1/service.go b/runtime/v2/runc/v1/service.go
index 0c84c1403..b27e59bbe 100644
index 8c473430e..8fdac3f8a 100644
--- a/runtime/v2/runc/v1/service.go
+++ b/runtime/v2/runc/v1/service.go
@@ -41,6 +41,7 @@ import (
@ -1222,7 +1169,7 @@ index 0c84c1403..b27e59bbe 100644
if err != nil {
return nil, fmt.Errorf("failed to marshal process %d info: %w", pid, err)
}
@@ -617,7 +618,7 @@ func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.
@@ -621,7 +622,7 @@ func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.
return nil, err
}
return &taskAPI.StatsResponse{
@ -1436,28 +1383,238 @@ index 692d92c1d..7d8d477ab 100644
}
if i.Annotations != nil {
request.Annotations = i.Annotations
diff --git a/metrics/cgroups/metrics_test.go b/metrics/cgroups/metrics_test.go
--- a/metrics/cgroups/metrics_test.go
+++ b/metrics/cgroups/metrics_test.go
@@ -32,7 +32,7 @@ import (
v2 "github.com/containerd/containerd/metrics/cgroups/v2"
v1types "github.com/containerd/containerd/metrics/types/v1"
v2types "github.com/containerd/containerd/metrics/types/v2"
- "github.com/containerd/typeurl"
+ "github.com/containerd/containerd/protobuf"
"github.com/prometheus/client_golang/prometheus"
diff --git a/vendor/github.com/containerd/typeurl/README.md b/vendor/github.com/containerd/typeurl/README.md
index d021e9672..e3d0742f4 100644
--- a/vendor/github.com/containerd/typeurl/README.md
+++ b/vendor/github.com/containerd/typeurl/README.md
@@ -7,7 +7,7 @@
metrics "github.com/docker/go-metrics"
@@ -152,7 +152,7 @@ func (t *mockStatT) Namespace() string {
A Go package for managing the registration, marshaling, and unmarshaling of encoded types.
func (t *mockStatT) Stats(context.Context) (*types.Any, error) {
if t.isV1 {
- return typeurl.MarshalAny(&v1types.Metrics{})
+ return protobuf.MarshalAnyToProto(&v1types.Metrics{})
-This package helps when types are sent over a GRPC API and marshaled as a [protobuf.Any](https://github.com/gogo/protobuf/blob/master/protobuf/google/protobuf/any.proto).
+This package helps when types are sent over a ttrpc/GRPC API and marshaled as a protobuf [Any](https://pkg.go.dev/google.golang.org/protobuf@v1.27.1/types/known/anypb#Any)
## Project details
diff --git a/vendor/github.com/containerd/typeurl/types.go b/vendor/github.com/containerd/typeurl/types.go
index 647d419a2..189730996 100644
--- a/vendor/github.com/containerd/typeurl/types.go
+++ b/vendor/github.com/containerd/typeurl/types.go
@@ -18,13 +18,14 @@ package typeurl
import (
"encoding/json"
+ "errors"
+ "fmt"
"path"
"reflect"
"sync"
- "github.com/gogo/protobuf/proto"
- "github.com/gogo/protobuf/types"
- "github.com/pkg/errors"
+ gogoproto "github.com/gogo/protobuf/proto"
+ "google.golang.org/protobuf/proto"
)
var (
@@ -39,10 +40,35 @@ var (
//
// To detect an error class, use errors.Is() functions to tell whether an
// error is of this type.
+
var (
ErrNotFound = errors.New("not found")
)
+type Any interface {
+ GetTypeUrl() string
+ GetValue() []byte
+}
+
+type any struct {
+ typeURL string
+ value []byte
+}
+
+func (a *any) GetTypeUrl() string {
+ if a == nil {
+ return ""
+ }
+ return a.typeURL
+}
+
+func (a *any) GetValue() []byte {
+ if a == nil {
+ return nil
+ }
+ return a.value
+}
+
// Register a type with a base URL for JSON marshaling. When the MarshalAny and
// UnmarshalAny functions are called they will treat the Any type value as JSON.
// To use protocol buffers for handling the Any value the proto.Register
@@ -56,7 +82,7 @@ func Register(v interface{}, args ...string) {
defer mu.Unlock()
if et, ok := registry[t]; ok {
if et != p {
- panic(errors.Errorf("type registered with alternate path %q != %q", et, p))
+ panic(fmt.Errorf("type registered with alternate path %q != %q", et, p))
}
return
}
- return typeurl.MarshalAny(&v2types.Metrics{})
+ return protobuf.MarshalAnyToProto(&v2types.Metrics{})
@@ -69,41 +95,47 @@ func TypeURL(v interface{}) (string, error) {
u, ok := registry[tryDereference(v)]
mu.RUnlock()
if !ok {
- // fallback to the proto registry if it is a proto message
- pb, ok := v.(proto.Message)
- if !ok {
- return "", errors.Wrapf(ErrNotFound, "type %s", reflect.TypeOf(v))
+ switch t := v.(type) {
+ case proto.Message:
+ return string(t.ProtoReflect().Descriptor().FullName()), nil
+ case gogoproto.Message:
+ return gogoproto.MessageName(t), nil
+ default:
+ return "", fmt.Errorf("type %s: %w", reflect.TypeOf(v), ErrNotFound)
}
- return proto.MessageName(pb), nil
}
return u, nil
}
--
2.37.2
// Is returns true if the type of the Any is the same as v.
-func Is(any *types.Any, v interface{}) bool {
+func Is(any Any, v interface{}) bool {
// call to check that v is a pointer
tryDereference(v)
url, err := TypeURL(v)
if err != nil {
return false
}
- return any.TypeUrl == url
+ return any.GetTypeUrl() == url
}
// MarshalAny marshals the value v into an any with the correct TypeUrl.
// If the provided object is already a proto.Any message, then it will be
// returned verbatim. If it is of type proto.Message, it will be marshaled as a
// protocol buffer. Otherwise, the object will be marshaled to json.
-func MarshalAny(v interface{}) (*types.Any, error) {
+func MarshalAny(v interface{}) (Any, error) {
var marshal func(v interface{}) ([]byte, error)
switch t := v.(type) {
- case *types.Any:
+ case Any:
// avoid reserializing the type if we have an any.
return t, nil
case proto.Message:
marshal = func(v interface{}) ([]byte, error) {
return proto.Marshal(t)
}
+ case gogoproto.Message:
+ marshal = func(v interface{}) ([]byte, error) {
+ return gogoproto.Marshal(t)
+ }
default:
marshal = json.Marshal
}
@@ -117,15 +149,15 @@ func MarshalAny(v interface{}) (*types.Any, error) {
if err != nil {
return nil, err
}
- return &types.Any{
- TypeUrl: url,
- Value: data,
+ return &any{
+ typeURL: url,
+ value: data,
}, nil
}
// UnmarshalAny unmarshals the any type into a concrete type.
-func UnmarshalAny(any *types.Any) (interface{}, error) {
- return UnmarshalByTypeURL(any.TypeUrl, any.Value)
+func UnmarshalAny(any Any) (interface{}, error) {
+ return UnmarshalByTypeURL(any.GetTypeUrl(), any.GetValue())
}
// UnmarshalByTypeURL unmarshals the given type and value to into a concrete type.
@@ -136,11 +168,11 @@ func UnmarshalByTypeURL(typeURL string, value []byte) (interface{}, error) {
// UnmarshalTo unmarshals the any type into a concrete type passed in the out
// argument. It is identical to UnmarshalAny, but lets clients provide a
// destination type through the out argument.
-func UnmarshalTo(any *types.Any, out interface{}) error {
- return UnmarshalToByTypeURL(any.TypeUrl, any.Value, out)
+func UnmarshalTo(any Any, out interface{}) error {
+ return UnmarshalToByTypeURL(any.GetTypeUrl(), any.GetValue(), out)
}
-// UnmarshalTo unmarshals the given type and value into a concrete type passed
+// UnmarshalToByTypeURL unmarshals the given type and value into a concrete type passed
// in the out argument. It is identical to UnmarshalByTypeURL, but lets clients
// provide a destination type through the out argument.
func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error {
@@ -149,6 +181,10 @@ func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error {
}
func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error) {
+ if value == nil {
+ return nil, nil
+ }
+
t, err := getTypeByUrl(typeURL)
if err != nil {
return nil, err
@@ -163,12 +199,17 @@ func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error)
return nil, err
}
if typeURL != vURL {
- return nil, errors.Errorf("can't unmarshal type %q to output %q", typeURL, vURL)
+ return nil, fmt.Errorf("can't unmarshal type %q to output %q", typeURL, vURL)
}
}
if t.isProto {
- err = proto.Unmarshal(value, v.(proto.Message))
+ switch t := v.(type) {
+ case proto.Message:
+ err = proto.Unmarshal(value, t)
+ case gogoproto.Message:
+ err = gogoproto.Unmarshal(value, t)
+ }
} else {
err = json.Unmarshal(value, v)
}
@@ -193,7 +234,7 @@ func getTypeByUrl(url string) (urlType, error) {
}
mu.RUnlock()
// fallback to proto registry
- t := proto.MessageType(url)
+ t := gogoproto.MessageType(url)
if t != nil {
return urlType{
// get the underlying Elem because proto returns a pointer to the type
@@ -201,7 +242,7 @@ func getTypeByUrl(url string) (urlType, error) {
isProto: true,
}, nil
}
- return urlType{}, errors.Wrapf(ErrNotFound, "type with url %s", url)
+ return urlType{}, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
}
func tryDereference(v interface{}) reflect.Type {
diff --git a/vendor/modules.txt b/vendor/modules.txt
index e8bd4111c..42df8130b 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -116,7 +116,7 @@ github.com/containerd/nri/types/v1
## explicit; go 1.13
github.com/containerd/ttrpc
github.com/containerd/ttrpc/plugin
-# github.com/containerd/typeurl v1.0.2
+# github.com/containerd/typeurl v1.0.3-0.20220324183432-6193a0e03259
## explicit; go 1.13
github.com/containerd/typeurl
# github.com/containerd/zfs v1.0.0

View File

@ -1,8 +1,9 @@
diff --color -Naur a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go
--- a/pkg/cri/server/helpers.go 2021-11-17 21:04:57.000000000 +0100
+++ b/pkg/cri/server/helpers.go 2021-11-22 22:39:01.743745977 +0100
@@ -39,7 +39,7 @@ import (
"github.com/containerd/typeurl"
diff --git a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go
index a8498116d..3682be668 100644
--- a/pkg/cri/server/helpers.go
+++ b/pkg/cri/server/helpers.go
@@ -40,7 +40,7 @@ import (
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
- runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
@ -10,7 +11,7 @@ diff --color -Naur a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go
imagedigest "github.com/opencontainers/go-digest"
"github.com/pelletier/go-toml"
"golang.org/x/net/context"
@@ -365,8 +365,8 @@ func getRuntimeOptionsType(t string) int
@@ -366,8 +366,8 @@ func getRuntimeOptionsType(t string) interface{} {
return &runcoptions.Options{}
case plugin.RuntimeLinuxV1:
return &runctypes.RuncOptions{}

View File

@ -7,7 +7,7 @@
# https://github.com/containerd/containerd
%global goipath github.com/containerd/containerd
Version: 1.6.8
Version: 1.6.9
%gometa

View File

@ -1 +1 @@
SHA512 (containerd-1.6.8.tar.gz) = c204c028cdfd76537d1da01c66526fc85b29b02d2412569bb9b265375603614b037356c61846025a72281398f0f46df326a5ea3df97f57901cce85f2f728f0ba
SHA512 (containerd-1.6.9.tar.gz) = fabe29103c431fb02ba55342e7cd3d41865803389b941fca9fea4449180d4dbc8eafafd6a8a1174997a7cd3bc2b6111960ccf51042792809b145ea500a534f53