Merge pull request #9258 from samuelkarp/introspection-deprecation-warning

Expose usage of deprecated features
This commit is contained in:
Samuel Karp 2023-10-26 22:49:37 +00:00 committed by GitHub
commit 332fbd907e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 672 additions and 140 deletions

View File

@ -4344,6 +4344,7 @@ file {
dependency: "github.com/containerd/containerd/api/types/platform.proto" dependency: "github.com/containerd/containerd/api/types/platform.proto"
dependency: "google/rpc/status.proto" dependency: "google/rpc/status.proto"
dependency: "google/protobuf/empty.proto" dependency: "google/protobuf/empty.proto"
dependency: "google/protobuf/timestamp.proto"
message_type { message_type {
name: "Plugin" name: "Plugin"
field { field {
@ -4463,6 +4464,39 @@ file {
type: TYPE_UINT64 type: TYPE_UINT64
json_name: "pidns" json_name: "pidns"
} }
field {
name: "deprecations"
number: 4
label: LABEL_REPEATED
type: TYPE_MESSAGE
type_name: ".containerd.services.introspection.v1.DeprecationWarning"
json_name: "deprecations"
}
}
message_type {
name: "DeprecationWarning"
field {
name: "id"
number: 1
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "id"
}
field {
name: "message"
number: 2
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "message"
}
field {
name: "last_occurrence"
number: 3
label: LABEL_OPTIONAL
type: TYPE_MESSAGE
type_name: ".google.protobuf.Timestamp"
json_name: "lastOccurrence"
}
} }
service { service {
name: "Introspection" name: "Introspection"

View File

@ -27,6 +27,7 @@ import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb" emptypb "google.golang.org/protobuf/types/known/emptypb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
) )
@ -272,9 +273,10 @@ type ServerResponse struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
UUID string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` UUID string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`
Pid uint64 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` Pid uint64 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"`
Pidns uint64 `protobuf:"varint,3,opt,name=pidns,proto3" json:"pidns,omitempty"` // PID namespace, such as 4026531836 Pidns uint64 `protobuf:"varint,3,opt,name=pidns,proto3" json:"pidns,omitempty"` // PID namespace, such as 4026531836
Deprecations []*DeprecationWarning `protobuf:"bytes,4,rep,name=deprecations,proto3" json:"deprecations,omitempty"`
} }
func (x *ServerResponse) Reset() { func (x *ServerResponse) Reset() {
@ -330,6 +332,76 @@ func (x *ServerResponse) GetPidns() uint64 {
return 0 return 0
} }
func (x *ServerResponse) GetDeprecations() []*DeprecationWarning {
if x != nil {
return x.Deprecations
}
return nil
}
type DeprecationWarning struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
LastOccurrence *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=last_occurrence,json=lastOccurrence,proto3" json:"last_occurrence,omitempty"`
}
func (x *DeprecationWarning) Reset() {
*x = DeprecationWarning{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeprecationWarning) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeprecationWarning) ProtoMessage() {}
func (x *DeprecationWarning) ProtoReflect() protoreflect.Message {
mi := &file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeprecationWarning.ProtoReflect.Descriptor instead.
func (*DeprecationWarning) Descriptor() ([]byte, []int) {
return file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDescGZIP(), []int{4}
}
func (x *DeprecationWarning) GetID() string {
if x != nil {
return x.ID
}
return ""
}
func (x *DeprecationWarning) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *DeprecationWarning) GetLastOccurrence() *timestamppb.Timestamp {
if x != nil {
return x.LastOccurrence
}
return nil
}
var File_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto protoreflect.FileDescriptor var File_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto protoreflect.FileDescriptor
var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDesc = []byte{ var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDesc = []byte{
@ -347,63 +419,79 @@ var file_github_com_containerd_containerd_api_services_introspection_v1_introspe
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70,
0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f,
0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe6, 0x02, 0x0a, 0x06, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f,
0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe6, 0x02, 0x0a,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x09, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72,
0x72, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72,
0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x50, 0x6c, 0x61, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x09, 0x70, 0x6c, 0x61, 0x74, 0x66,
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x09, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x6f, 0x72, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6e,
0x12, 0x53, 0x0a, 0x07, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x50, 0x6c,
0x0b, 0x32, 0x39, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x73, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x09, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d,
0x73, 0x12, 0x53, 0x0a, 0x07, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x39, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65,
0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69,
0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x61,
0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x08, 0x69, 0x6e,
0x69, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
0x52, 0x07, 0x69, 0x6e, 0x69, 0x74, 0x45, 0x72, 0x72, 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x78, 0x70,
0x6f, 0x72, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x2a, 0x0a, 0x0e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65,
0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72,
0x73, 0x22, 0x59, 0x0a, 0x0f, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65,
0x72, 0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72,
0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75,
0x67, 0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x22, 0xaa, 0x01, 0x0a,
0x0e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75,
0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04,
0x52, 0x03, 0x70, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x69, 0x64, 0x6e, 0x73, 0x18, 0x03,
0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x70, 0x69, 0x64, 0x6e, 0x73, 0x12, 0x5c, 0x0a, 0x0c, 0x64,
0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x38, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61,
0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x78, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x0c, 0x64, 0x65, 0x70,
0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x83, 0x01, 0x0a, 0x12, 0x44, 0x65,
0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67,
0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x08, 0x69, 0x6e, 0x69, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
0x74, 0x5f, 0x65, 0x72, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x43, 0x0a, 0x0f, 0x6c, 0x61,
0x07, 0x69, 0x6e, 0x69, 0x74, 0x45, 0x72, 0x72, 0x1a, 0x3a, 0x0a, 0x0c, 0x45, 0x78, 0x70, 0x6f, 0x73, 0x74, 0x5f, 0x6f, 0x63, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20,
0x72, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x4f, 0x63, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x32,
0x3a, 0x02, 0x38, 0x01, 0x22, 0x2a, 0x0a, 0x0e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0xdf, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x76, 0x0a, 0x07, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x34, 0x2e, 0x63,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73,
0x22, 0x59, 0x0a, 0x0f, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72,
0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f,
0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67,
0x69, 0x6e, 0x52, 0x07, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x22, 0x4c, 0x0a, 0x0e, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69,
0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03,
0x70, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x69, 0x64, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01,
0x28, 0x04, 0x52, 0x05, 0x70, 0x69, 0x64, 0x6e, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x0d, 0x49, 0x6e,
0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x76, 0x0a, 0x07, 0x50,
0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x34, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e,
0x65, 0x72, 0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74,
0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c,
0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x63,
0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x34, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e,
0x72, 0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x06, 0x53, 0x65, 0x72,
0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4e, 0x5a, 0x4c, 0x67, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x34, 0x2e, 0x63, 0x6f,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x69, 0x6e, 0x65, 0x42, 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61,
0x74, 0x6f, 0x33, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x2f, 0x76, 0x31, 0x3b, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -418,31 +506,35 @@ func file_github_com_containerd_containerd_api_services_introspection_v1_introsp
return file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDescData return file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDescData
} }
var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_goTypes = []interface{}{ var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_goTypes = []interface{}{
(*Plugin)(nil), // 0: containerd.services.introspection.v1.Plugin (*Plugin)(nil), // 0: containerd.services.introspection.v1.Plugin
(*PluginsRequest)(nil), // 1: containerd.services.introspection.v1.PluginsRequest (*PluginsRequest)(nil), // 1: containerd.services.introspection.v1.PluginsRequest
(*PluginsResponse)(nil), // 2: containerd.services.introspection.v1.PluginsResponse (*PluginsResponse)(nil), // 2: containerd.services.introspection.v1.PluginsResponse
(*ServerResponse)(nil), // 3: containerd.services.introspection.v1.ServerResponse (*ServerResponse)(nil), // 3: containerd.services.introspection.v1.ServerResponse
nil, // 4: containerd.services.introspection.v1.Plugin.ExportsEntry (*DeprecationWarning)(nil), // 4: containerd.services.introspection.v1.DeprecationWarning
(*types.Platform)(nil), // 5: containerd.types.Platform nil, // 5: containerd.services.introspection.v1.Plugin.ExportsEntry
(*status.Status)(nil), // 6: google.rpc.Status (*types.Platform)(nil), // 6: containerd.types.Platform
(*emptypb.Empty)(nil), // 7: google.protobuf.Empty (*status.Status)(nil), // 7: google.rpc.Status
(*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp
(*emptypb.Empty)(nil), // 9: google.protobuf.Empty
} }
var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_depIdxs = []int32{ var file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_depIdxs = []int32{
5, // 0: containerd.services.introspection.v1.Plugin.platforms:type_name -> containerd.types.Platform 6, // 0: containerd.services.introspection.v1.Plugin.platforms:type_name -> containerd.types.Platform
4, // 1: containerd.services.introspection.v1.Plugin.exports:type_name -> containerd.services.introspection.v1.Plugin.ExportsEntry 5, // 1: containerd.services.introspection.v1.Plugin.exports:type_name -> containerd.services.introspection.v1.Plugin.ExportsEntry
6, // 2: containerd.services.introspection.v1.Plugin.init_err:type_name -> google.rpc.Status 7, // 2: containerd.services.introspection.v1.Plugin.init_err:type_name -> google.rpc.Status
0, // 3: containerd.services.introspection.v1.PluginsResponse.plugins:type_name -> containerd.services.introspection.v1.Plugin 0, // 3: containerd.services.introspection.v1.PluginsResponse.plugins:type_name -> containerd.services.introspection.v1.Plugin
1, // 4: containerd.services.introspection.v1.Introspection.Plugins:input_type -> containerd.services.introspection.v1.PluginsRequest 4, // 4: containerd.services.introspection.v1.ServerResponse.deprecations:type_name -> containerd.services.introspection.v1.DeprecationWarning
7, // 5: containerd.services.introspection.v1.Introspection.Server:input_type -> google.protobuf.Empty 8, // 5: containerd.services.introspection.v1.DeprecationWarning.last_occurrence:type_name -> google.protobuf.Timestamp
2, // 6: containerd.services.introspection.v1.Introspection.Plugins:output_type -> containerd.services.introspection.v1.PluginsResponse 1, // 6: containerd.services.introspection.v1.Introspection.Plugins:input_type -> containerd.services.introspection.v1.PluginsRequest
3, // 7: containerd.services.introspection.v1.Introspection.Server:output_type -> containerd.services.introspection.v1.ServerResponse 9, // 7: containerd.services.introspection.v1.Introspection.Server:input_type -> google.protobuf.Empty
6, // [6:8] is the sub-list for method output_type 2, // 8: containerd.services.introspection.v1.Introspection.Plugins:output_type -> containerd.services.introspection.v1.PluginsResponse
4, // [4:6] is the sub-list for method input_type 3, // 9: containerd.services.introspection.v1.Introspection.Server:output_type -> containerd.services.introspection.v1.ServerResponse
4, // [4:4] is the sub-list for extension type_name 8, // [8:10] is the sub-list for method output_type
4, // [4:4] is the sub-list for extension extendee 6, // [6:8] is the sub-list for method input_type
0, // [0:4] is the sub-list for field type_name 6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
} }
func init() { func init() {
@ -501,6 +593,18 @@ func file_github_com_containerd_containerd_api_services_introspection_v1_introsp
return nil return nil
} }
} }
file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeprecationWarning); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -508,7 +612,7 @@ func file_github_com_containerd_containerd_api_services_introspection_v1_introsp
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDesc, RawDescriptor: file_github_com_containerd_containerd_api_services_introspection_v1_introspection_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 5, NumMessages: 6,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -21,6 +21,7 @@ package containerd.services.introspection.v1;
import "github.com/containerd/containerd/api/types/platform.proto"; import "github.com/containerd/containerd/api/types/platform.proto";
import "google/rpc/status.proto"; import "google/rpc/status.proto";
import "google/protobuf/empty.proto"; import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/containerd/containerd/api/services/introspection/v1;introspection"; option go_package = "github.com/containerd/containerd/api/services/introspection/v1;introspection";
@ -102,4 +103,11 @@ message ServerResponse {
string uuid = 1; string uuid = 1;
uint64 pid = 2; uint64 pid = 2;
uint64 pidns = 3; // PID namespace, such as 4026531836 uint64 pidns = 3; // PID namespace, such as 4026531836
repeated DeprecationWarning deprecations = 4;
} }
message DeprecationWarning {
string id = 1;
string message = 2;
google.protobuf.Timestamp last_occurrence = 3;
}

View File

@ -46,4 +46,5 @@ import (
_ "github.com/containerd/containerd/services/tasks" _ "github.com/containerd/containerd/services/tasks"
_ "github.com/containerd/containerd/services/transfer" _ "github.com/containerd/containerd/services/transfer"
_ "github.com/containerd/containerd/services/version" _ "github.com/containerd/containerd/services/version"
_ "github.com/containerd/containerd/services/warning"
) )

View File

@ -20,8 +20,13 @@ import (
"fmt" "fmt"
"io" "io"
"github.com/containerd/log"
"github.com/urfave/cli"
"google.golang.org/grpc/grpclog"
"github.com/containerd/containerd/cmd/ctr/commands/containers" "github.com/containerd/containerd/cmd/ctr/commands/containers"
"github.com/containerd/containerd/cmd/ctr/commands/content" "github.com/containerd/containerd/cmd/ctr/commands/content"
"github.com/containerd/containerd/cmd/ctr/commands/deprecations"
"github.com/containerd/containerd/cmd/ctr/commands/events" "github.com/containerd/containerd/cmd/ctr/commands/events"
"github.com/containerd/containerd/cmd/ctr/commands/images" "github.com/containerd/containerd/cmd/ctr/commands/images"
"github.com/containerd/containerd/cmd/ctr/commands/info" "github.com/containerd/containerd/cmd/ctr/commands/info"
@ -39,9 +44,6 @@ import (
"github.com/containerd/containerd/defaults" "github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/version" "github.com/containerd/containerd/version"
"github.com/containerd/log"
"github.com/urfave/cli"
"google.golang.org/grpc/grpclog"
) )
var extraCmds = []cli.Command{} var extraCmds = []cli.Command{}
@ -118,6 +120,7 @@ containerd CLI
ociCmd.Command, ociCmd.Command,
sandboxes.Command, sandboxes.Command,
info.Command, info.Command,
deprecations.Command,
}, extraCmds...) }, extraCmds...)
app.Before = func(context *cli.Context) error { app.Before = func(context *cli.Context) error {
if context.GlobalBool("debug") { if context.GlobalBool("debug") {

View File

@ -0,0 +1,113 @@
/*
Copyright 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 deprecations
import (
"fmt"
"os"
"text/tabwriter"
"time"
"github.com/urfave/cli"
api "github.com/containerd/containerd/api/services/introspection/v1"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/protobuf"
ptypes "github.com/containerd/containerd/protobuf/types"
)
// Command is the parent for all commands under "deprecations"
var Command = cli.Command{
Name: "deprecations",
Subcommands: []cli.Command{
listCommand,
},
}
var listCommand = cli.Command{
Name: "list",
Usage: "Print warnings for deprecations",
Flags: []cli.Flag{
cli.StringFlag{
Name: "format",
Usage: "output format to use (Examples: 'default', 'json')",
},
},
Action: func(context *cli.Context) error {
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
return err
}
defer cancel()
resp, err := client.IntrospectionService().Server(ctx, &ptypes.Empty{})
if err != nil {
return err
}
wrn := warnings(resp)
if len(wrn) > 0 {
switch context.String("format") {
case "json":
commands.PrintAsJSON(warnings(resp))
return nil
default:
w := tabwriter.NewWriter(os.Stdout, 4, 8, 4, ' ', 0)
fmt.Fprintln(w, "ID\tLAST OCCURRENCE\tMESSAGE\t")
for _, dw := range wrn {
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\n",
dw.ID,
dw.LastOccurrence.Format(time.RFC3339Nano),
dw.Message,
); err != nil {
return err
}
}
return w.Flush()
}
}
return nil
},
}
type deprecationWarning struct {
ID string `json:"id"`
Message string `json:"message"`
LastOccurrence time.Time `json:"lastOccurrence"`
}
func warnings(in *api.ServerResponse) []deprecationWarning {
var warnings []deprecationWarning
for _, dw := range in.Deprecations {
wrn := deprecationWarningFromPB(dw)
if wrn == nil {
continue
}
warnings = append(warnings, *wrn)
}
return warnings
}
func deprecationWarningFromPB(in *api.DeprecationWarning) *deprecationWarning {
if in == nil {
return nil
}
lo := protobuf.FromTimestamp(in.LastOccurrence)
return &deprecationWarning{
ID: in.ID,
Message: in.Message,
LastOccurrence: lo,
}
}

21
images/labels.go Normal file
View File

@ -0,0 +1,21 @@
/*
Copyright 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 images
const (
ConvertedDockerSchema1LabelKey = "io.containerd.image/converted-docker-schema1"
)

View File

@ -0,0 +1,46 @@
/*
Copyright 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 deprecation
type Warning string
const (
// Prefix is a standard prefix for all Warnings, used for filtering plugin Exports
Prefix = "io.containerd.deprecation/"
// PullSchema1Image is a warning for the use of schema 1 images
PullSchema1Image Warning = Prefix + "pull-schema-1-image"
// GoPluginLibrary is a warning for the use of dynamic library Go plugins
GoPluginLibrary Warning = Prefix + "go-plugin-library"
)
var messages = map[Warning]string{
PullSchema1Image: "Schema 1 images are deprecated since containerd v1.7 and removed in containerd v2.0. " +
`Since containerd v1.7.8, schema 1 images are identified by the "io.containerd.image/converted-docker-schema1" label.`,
GoPluginLibrary: "Dynamically-linked Go plugins as containerd runtimes are deprecated since containerd v2.0 and removed in containerd v2.1.",
}
// Valid checks whether a given Warning is valid
func Valid(id Warning) bool {
_, ok := messages[id]
return ok
}
// Message returns the human-readable message for a given Warning
func Message(id Warning) (string, bool) {
msg, ok := messages[id]
return msg, ok
}

View File

@ -127,6 +127,19 @@ func (ps *Set) Get(t Type) (interface{}, error) {
return nil, fmt.Errorf("no plugins registered for %s: %w", t, ErrPluginNotFound) return nil, fmt.Errorf("no plugins registered for %s: %w", t, ErrPluginNotFound)
} }
// GetByID returns the plugin of the given type and ID
func (ps *Set) GetByID(t Type, id string) (*Plugin, error) {
typSet, ok := ps.byTypeAndID[t]
if !ok || len(typSet) == 0 {
return nil, fmt.Errorf("no plugins registered for %s: %w", t, ErrPluginNotFound)
}
p, ok := typSet[id]
if !ok {
return nil, fmt.Errorf("no plugins registered for %s %q: %w", t, id, ErrPluginNotFound)
}
return p, nil
}
// GetAll returns all initialized plugins // GetAll returns all initialized plugins
func (ps *Set) GetAll() []*Plugin { func (ps *Set) GetAll() []*Plugin {
return ps.ordered return ps.ordered

View File

@ -23,7 +23,7 @@ import "fmt"
// Load is currently only implemented on non-static, non-gccgo builds for amd64 // Load is currently only implemented on non-static, non-gccgo builds for amd64
// and arm64, and plugins must be built with the exact same version of Go as // and arm64, and plugins must be built with the exact same version of Go as
// containerd itself. // containerd itself.
func Load(path string) (err error) { func Load(path string) (loaded int, err error) {
defer func() { defer func() {
if v := recover(); v != nil { if v := recover(); v != nil {
rerr, ok := v.(error) rerr, ok := v.(error)

View File

@ -25,12 +25,13 @@ import (
"runtime" "runtime"
) )
// loadPlugins loads all plugins for the OS and Arch // loadPlugins loads all plugins for the OS and Arch that containerd is built
// that containerd is built for inside the provided path // for inside the provided path and returns the count of successfully-loaded
func loadPlugins(path string) error { // plugins
func loadPlugins(path string) (int, error) {
abs, err := filepath.Abs(path) abs, err := filepath.Abs(path)
if err != nil { if err != nil {
return err return 0, err
} }
pattern := filepath.Join(abs, fmt.Sprintf( pattern := filepath.Join(abs, fmt.Sprintf(
"*-%s-%s.%s", "*-%s-%s.%s",
@ -40,14 +41,16 @@ func loadPlugins(path string) error {
)) ))
libs, err := filepath.Glob(pattern) libs, err := filepath.Glob(pattern)
if err != nil { if err != nil {
return err return 0, err
} }
loaded := 0
for _, lib := range libs { for _, lib := range libs {
if _, err := plugin.Open(lib); err != nil { if _, err := plugin.Open(lib); err != nil {
return err return loaded, err
} }
loaded++
} }
return nil return loaded, nil
} }
// getLibExt returns a platform specific lib extension for // getLibExt returns a platform specific lib extension for

View File

@ -23,6 +23,6 @@ package dynamic
// - with gccgo: gccgo has no plugin support golang/go#36403 // - with gccgo: gccgo has no plugin support golang/go#36403
// - on static builds; https://github.com/containerd/containerd/commit/0d682e24a1ba8e93e5e54a73d64f7d256f87492f // - on static builds; https://github.com/containerd/containerd/commit/0d682e24a1ba8e93e5e54a73d64f7d256f87492f
// - on architectures other than amd64 and arm64 (other architectures need to be tested) // - on architectures other than amd64 and arm64 (other architectures need to be tested)
func loadPlugins(path string) error { func loadPlugins(path string) (int, error) {
return nil return 0, nil
} }

View File

@ -65,11 +65,15 @@ const (
SandboxControllerPlugin plugin.Type = "io.containerd.sandbox.controller.v1" SandboxControllerPlugin plugin.Type = "io.containerd.sandbox.controller.v1"
// ImageVerifierPlugin implements an image verifier service // ImageVerifierPlugin implements an image verifier service
ImageVerifierPlugin plugin.Type = "io.containerd.image-verifier.v1" ImageVerifierPlugin plugin.Type = "io.containerd.image-verifier.v1"
// WarningPlugin implements a warning service
WarningPlugin plugin.Type = "io.containerd.warning.v1"
) )
const ( const (
// RuntimeRuncV2 is the runc runtime that supports multiple containers per shim // RuntimeRuncV2 is the runc runtime that supports multiple containers per shim
RuntimeRuncV2 = "io.containerd.runc.v2" RuntimeRuncV2 = "io.containerd.runc.v2"
DeprecationsPlugin = "deprecations"
) )
const ( const (

10
pull.go
View File

@ -21,6 +21,9 @@ import (
"errors" "errors"
"fmt" "fmt"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/sync/semaphore"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/pkg/unpack" "github.com/containerd/containerd/pkg/unpack"
@ -29,13 +32,10 @@ import (
"github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker"
"github.com/containerd/containerd/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/containerd/containerd/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/containerd/containerd/tracing" "github.com/containerd/containerd/tracing"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/sync/semaphore"
) )
const ( const (
pullSpanPrefix = "pull" pullSpanPrefix = "pull"
convertedDockerSchema1LabelKey = "io.containerd.image/converted-docker-schema1"
) )
// Pull downloads the provided content into containerd's content store // Pull downloads the provided content into containerd's content store
@ -278,7 +278,7 @@ func (c *Client) fetch(ctx context.Context, rCtx *RemoteContext, ref string, lim
if rCtx.Labels == nil { if rCtx.Labels == nil {
rCtx.Labels = make(map[string]string) rCtx.Labels = make(map[string]string)
} }
rCtx.Labels[convertedDockerSchema1LabelKey] = originalSchema1Digest rCtx.Labels[images.ConvertedDockerSchema1LabelKey] = originalSchema1Digest
} }
return images.Image{ return images.Image{

View File

@ -19,6 +19,11 @@ package images
import ( import (
"context" "context"
"github.com/containerd/log"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
eventstypes "github.com/containerd/containerd/api/events" eventstypes "github.com/containerd/containerd/api/events"
imagesapi "github.com/containerd/containerd/api/services/images/v1" imagesapi "github.com/containerd/containerd/api/services/images/v1"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
@ -26,16 +31,14 @@ import (
"github.com/containerd/containerd/gc" "github.com/containerd/containerd/gc"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/metadata" "github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/pkg/deprecation"
"github.com/containerd/containerd/pkg/epoch" "github.com/containerd/containerd/pkg/epoch"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin/registry" "github.com/containerd/containerd/plugin/registry"
"github.com/containerd/containerd/plugins" "github.com/containerd/containerd/plugins"
ptypes "github.com/containerd/containerd/protobuf/types" ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/services" "github.com/containerd/containerd/services"
"github.com/containerd/log" "github.com/containerd/containerd/services/warning"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
func init() { func init() {
@ -46,6 +49,7 @@ func init() {
plugins.EventPlugin, plugins.EventPlugin,
plugins.MetadataPlugin, plugins.MetadataPlugin,
plugins.GCPlugin, plugins.GCPlugin,
plugins.WarningPlugin,
}, },
InitFn: func(ic *plugin.InitContext) (interface{}, error) { InitFn: func(ic *plugin.InitContext) (interface{}, error) {
m, err := ic.Get(plugins.MetadataPlugin) m, err := ic.Get(plugins.MetadataPlugin)
@ -56,16 +60,20 @@ func init() {
if err != nil { if err != nil {
return nil, err return nil, err
} }
ep, err := ic.Get(plugins.EventPlugin) ep, err := ic.Get(plugins.EventPlugin)
if err != nil { if err != nil {
return nil, err return nil, err
} }
w, err := ic.Get(plugins.WarningPlugin)
if err != nil {
return nil, err
}
return &local{ return &local{
store: metadata.NewImageStore(m.(*metadata.DB)), store: metadata.NewImageStore(m.(*metadata.DB)),
publisher: ep.(events.Publisher), publisher: ep.(events.Publisher),
gc: g.(gcScheduler), gc: g.(gcScheduler),
warnings: w.(warning.Service),
}, nil }, nil
}, },
}) })
@ -79,6 +87,7 @@ type local struct {
store images.Store store images.Store
gc gcScheduler gc gcScheduler
publisher events.Publisher publisher events.Publisher
warnings warning.Service
} }
var _ imagesapi.ImagesClient = &local{} var _ imagesapi.ImagesClient = &local{}
@ -134,6 +143,7 @@ func (l *local) Create(ctx context.Context, req *imagesapi.CreateImageRequest, _
return nil, err return nil, err
} }
l.emitSchema1DeprecationWarning(ctx, &image)
return &resp, nil return &resp, nil
} }
@ -172,6 +182,7 @@ func (l *local) Update(ctx context.Context, req *imagesapi.UpdateImageRequest, _
return nil, err return nil, err
} }
l.emitSchema1DeprecationWarning(ctx, &image)
return &resp, nil return &resp, nil
} }
@ -203,3 +214,15 @@ func (l *local) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest, _
return &ptypes.Empty{}, nil return &ptypes.Empty{}, nil
} }
func (l *local) emitSchema1DeprecationWarning(ctx context.Context, image *images.Image) {
if image == nil {
return
}
dgst, ok := image.Labels[images.ConvertedDockerSchema1LabelKey]
if !ok {
return
}
log.G(ctx).WithField("name", image.Name).WithField("schema1digest", dgst).Warn("conversion from schema 1 images is deprecated")
l.warnings.Emit(ctx, deprecation.PullSchema1Image)
}

View File

@ -18,11 +18,18 @@ package introspection
import ( import (
context "context" context "context"
"errors"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"sync" "sync"
"github.com/google/uuid"
"google.golang.org/genproto/googleapis/rpc/code"
rpc "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
api "github.com/containerd/containerd/api/services/introspection/v1" api "github.com/containerd/containerd/api/services/introspection/v1"
"github.com/containerd/containerd/api/types" "github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
@ -30,25 +37,42 @@ import (
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin/registry" "github.com/containerd/containerd/plugin/registry"
"github.com/containerd/containerd/plugins" "github.com/containerd/containerd/plugins"
"github.com/containerd/containerd/protobuf"
ptypes "github.com/containerd/containerd/protobuf/types" ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/services" "github.com/containerd/containerd/services"
"github.com/google/uuid" "github.com/containerd/containerd/services/warning"
"google.golang.org/genproto/googleapis/rpc/code"
rpc "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
) )
func init() { func init() {
registry.Register(&plugin.Registration{ registry.Register(&plugin.Registration{
Type: plugins.ServicePlugin, Type: plugins.ServicePlugin,
ID: services.IntrospectionService, ID: services.IntrospectionService,
Requires: []plugin.Type{}, Requires: []plugin.Type{plugins.WarningPlugin},
InitFn: func(ic *plugin.InitContext) (interface{}, error) { InitFn: func(ic *plugin.InitContext) (interface{}, error) {
sps, err := ic.GetByType(plugins.WarningPlugin)
if err != nil {
return nil, err
}
p, ok := sps[plugins.DeprecationsPlugin]
if !ok {
return nil, errors.New("warning service not found")
}
i, err := p.Instance()
if err != nil {
return nil, err
}
warningClient, ok := i.(warning.Service)
if !ok {
return nil, errors.New("could not create a local client for warning service")
}
// this service fetches all plugins through the plugin set of the plugin context // this service fetches all plugins through the plugin set of the plugin context
return &Local{ return &Local{
plugins: ic.Plugins(), plugins: ic.Plugins(),
root: ic.Properties[plugins.PropertyRootDir], root: ic.Properties[plugins.PropertyRootDir],
warningClient: warningClient,
}, nil }, nil
}, },
}) })
@ -56,10 +80,11 @@ func init() {
// Local is a local implementation of the introspection service // Local is a local implementation of the introspection service
type Local struct { type Local struct {
mu sync.Mutex mu sync.Mutex
root string root string
plugins *plugin.Set plugins *plugin.Set
pluginCache []*api.Plugin pluginCache []*api.Plugin
warningClient warning.Service
} }
var _ = (api.IntrospectionClient)(&Local{}) var _ = (api.IntrospectionClient)(&Local{})
@ -117,9 +142,10 @@ func (l *Local) Server(ctx context.Context, _ *ptypes.Empty, _ ...grpc.CallOptio
} }
} }
return &api.ServerResponse{ return &api.ServerResponse{
UUID: u, UUID: u,
Pid: uint64(pid), Pid: uint64(pid),
Pidns: pidns, Pidns: pidns,
Deprecations: l.getWarnings(ctx),
}, nil }, nil
} }
@ -161,6 +187,10 @@ func (l *Local) uuidPath() string {
return filepath.Join(l.root, "uuid") return filepath.Join(l.root, "uuid")
} }
func (l *Local) getWarnings(ctx context.Context) []*api.DeprecationWarning {
return warningsPB(ctx, l.warningClient.Warnings())
}
func adaptPlugin(o interface{}) filters.Adaptor { func adaptPlugin(o interface{}) filters.Adaptor {
obj := o.(*api.Plugin) obj := o.(*api.Plugin)
return filters.AdapterFunc(func(fieldpath []string) (string, bool) { return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
@ -233,3 +263,16 @@ func pluginsToPB(plugins []*plugin.Plugin) []*api.Plugin {
return pluginsPB return pluginsPB
} }
func warningsPB(ctx context.Context, warnings []warning.Warning) []*api.DeprecationWarning {
var pb []*api.DeprecationWarning
for _, w := range warnings {
pb = append(pb, &api.DeprecationWarning{
ID: string(w.ID),
Message: w.Message,
LastOccurrence: protobuf.ToTimestamp(w.LastOccurrence),
})
}
return pb
}

View File

@ -34,26 +34,6 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
csapi "github.com/containerd/containerd/api/services/content/v1"
diffapi "github.com/containerd/containerd/api/services/diff/v1"
sbapi "github.com/containerd/containerd/api/services/sandbox/v1"
ssapi "github.com/containerd/containerd/api/services/snapshots/v1"
"github.com/containerd/containerd/content/local"
csproxy "github.com/containerd/containerd/content/proxy"
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/diff"
diffproxy "github.com/containerd/containerd/diff/proxy"
"github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/pkg/timeout"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin/dynamic"
"github.com/containerd/containerd/plugin/registry"
"github.com/containerd/containerd/plugins"
sbproxy "github.com/containerd/containerd/sandbox/proxy"
srvconfig "github.com/containerd/containerd/services/server/config"
ssproxy "github.com/containerd/containerd/snapshots/proxy"
"github.com/containerd/containerd/sys"
"github.com/containerd/log" "github.com/containerd/log"
"github.com/containerd/ttrpc" "github.com/containerd/ttrpc"
"github.com/docker/go-metrics" "github.com/docker/go-metrics"
@ -65,6 +45,29 @@ import (
"google.golang.org/grpc/backoff" "google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
csapi "github.com/containerd/containerd/api/services/content/v1"
diffapi "github.com/containerd/containerd/api/services/diff/v1"
sbapi "github.com/containerd/containerd/api/services/sandbox/v1"
ssapi "github.com/containerd/containerd/api/services/snapshots/v1"
"github.com/containerd/containerd/content/local"
csproxy "github.com/containerd/containerd/content/proxy"
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/diff"
diffproxy "github.com/containerd/containerd/diff/proxy"
"github.com/containerd/containerd/pkg/deprecation"
"github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/pkg/timeout"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin/dynamic"
"github.com/containerd/containerd/plugin/registry"
"github.com/containerd/containerd/plugins"
sbproxy "github.com/containerd/containerd/sandbox/proxy"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/services/warning"
ssproxy "github.com/containerd/containerd/snapshots/proxy"
"github.com/containerd/containerd/sys"
) )
// CreateTopLevelDirectories creates the top-level root and state directories. // CreateTopLevelDirectories creates the top-level root and state directories.
@ -330,9 +333,35 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
return nil, err return nil, err
} }
} }
recordConfigDeprecations(ctx, config, initialized)
return s, nil return s, nil
} }
// recordConfigDeprecations attempts to record use of any deprecated config field. Failures are logged and ignored.
func recordConfigDeprecations(ctx context.Context, config *srvconfig.Config, set *plugin.Set) {
// record any detected deprecations without blocking server startup
plugin, err := set.GetByID(plugins.WarningPlugin, plugins.DeprecationsPlugin)
if err != nil {
log.G(ctx).WithError(err).Warn("failed to load warning service to record deprecations")
return
}
instance, err := plugin.Instance()
if err != nil {
log.G(ctx).WithError(err).Warn("failed to load warning service to record deprecations")
return
}
warn, ok := instance.(warning.Service)
if !ok {
log.G(ctx).WithError(err).Warn("failed to load warning service to record deprecations, unexpected plugin type")
return
}
if config.PluginDir != "" { //nolint:staticcheck
warn.Emit(ctx, deprecation.GoPluginLibrary)
}
}
// Server is the containerd main daemon // Server is the containerd main daemon
type Server struct { type Server struct {
grpcServer *grpc.Server grpcServer *grpc.Server
@ -433,13 +462,15 @@ func (s *Server) Wait() {
// of all plugins. // of all plugins.
func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]plugin.Registration, error) { func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]plugin.Registration, error) {
// load all plugins into containerd // load all plugins into containerd
path := config.PluginDir //nolint: staticcheck path := config.PluginDir //nolint:staticcheck
if path == "" { if path == "" {
path = filepath.Join(config.Root, "plugins") path = filepath.Join(config.Root, "plugins")
} }
log.G(ctx).Warning("`go_plugin` is deprecated, please use `external plugins` instead") if count, err := dynamic.Load(path); err != nil {
if err := dynamic.Load(path); err != nil {
return nil, err return nil, err
} else if count > 0 || config.PluginDir != "" { //nolint:staticcheck
config.PluginDir = path //nolint:staticcheck
log.G(ctx).Warningf("loaded %d dynamic plugins. `go_plugin` is deprecated, please use `external plugins` instead", count)
} }
// load additional plugins that don't automatically register themselves // load additional plugins that don't automatically register themselves
registry.Register(&plugin.Registration{ registry.Register(&plugin.Registration{

View File

@ -0,0 +1,85 @@
/*
Copyright 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 warning
import (
"context"
"sync"
"time"
"github.com/containerd/log"
deprecation "github.com/containerd/containerd/pkg/deprecation"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin/registry"
"github.com/containerd/containerd/plugins"
)
type Service interface {
Emit(context.Context, deprecation.Warning)
Warnings() []Warning
}
func init() {
registry.Register(&plugin.Registration{
Type: plugins.WarningPlugin,
ID: plugins.DeprecationsPlugin,
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
return &service{warnings: make(map[deprecation.Warning]time.Time)}, nil
},
})
}
type Warning struct {
ID deprecation.Warning
LastOccurrence time.Time
Message string
}
var _ Service = (*service)(nil)
type service struct {
warnings map[deprecation.Warning]time.Time
m sync.RWMutex
}
func (s *service) Emit(ctx context.Context, warning deprecation.Warning) {
if !deprecation.Valid(warning) {
log.G(ctx).WithField("warningID", string(warning)).Warn("invalid deprecation warning")
return
}
s.m.Lock()
defer s.m.Unlock()
s.warnings[warning] = time.Now()
}
func (s *service) Warnings() []Warning {
s.m.RLock()
defer s.m.RUnlock()
var warnings []Warning
for k, v := range s.warnings {
msg, ok := deprecation.Message(k)
if !ok {
continue
}
warnings = append(warnings, Warning{
ID: k,
LastOccurrence: v,
Message: msg,
})
}
return warnings
}