Convert k8s.io/kubelet/pkg/apis/podresources from gogo to protoc

Use standard protoc for the pod resources instead of gogo.

Part of kubernetes#96564

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
Sascha Grunert
2025-07-17 13:33:46 +02:00
parent b2d7149090
commit 532d48fe6a
14 changed files with 1436 additions and 5244 deletions

View File

@@ -1021,8 +1021,6 @@ function codegen::protobindings() {
# Each element of this array is a directory containing subdirectories which
# eventually contain a file named "api.proto".
local apis_using_gogo=(
"staging/src/k8s.io/kubelet/pkg/apis/podresources"
"staging/src/k8s.io/kubelet/pkg/apis/deviceplugin"
@@ -1033,6 +1031,7 @@ function codegen::protobindings() {
)
local apis_using_protoc=(
"staging/src/k8s.io/kubelet/pkg/apis/podresources"
"staging/src/k8s.io/kms/apis"
"staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/kmsv2"
"staging/src/k8s.io/cri-api/pkg/apis/runtime"

View File

@@ -38,6 +38,7 @@ type v1PodResourcesServer struct {
memoryProvider MemoryProvider
dynamicResourcesProvider DynamicResourcesProvider
useActivePods bool
podresourcesv1.UnsafePodResourcesListerServer
}
// NewV1PodResourcesServer returns a PodResourcesListerServer which lists pods provided by the PodsProvider

View File

@@ -58,12 +58,12 @@ func TestListPodResourcesV1(t *testing.T) {
memory := []*podresourcesapi.ContainerMemory{
{
MemoryType: "memory",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
{
MemoryType: "hugepages-1Gi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
}
@@ -94,7 +94,7 @@ func TestListPodResourcesV1(t *testing.T) {
{
ClaimName: "claim-name",
ClaimNamespace: "default",
ClaimResources: []*podresourcesapi.ClaimResource{{CDIDevices: pluginCDIDevices, DriverName: draDriverName, PoolName: poolName, DeviceName: deviceName}},
ClaimResources: []*podresourcesapi.ClaimResource{{CdiDevices: pluginCDIDevices, DriverName: draDriverName, PoolName: poolName, DeviceName: deviceName}},
},
}
@@ -245,8 +245,8 @@ func TestListPodResourcesV1(t *testing.T) {
if err != nil {
t.Errorf("want err = %v, got %q", nil, err)
}
if diff := cmp.Diff(tc.expectedResponse, resp, cmpopts.EquateEmpty()); diff != "" {
t.Fatal(diff)
if tc.expectedResponse.String() != resp.String() {
t.Fatalf("want: %+v; got: %+v", tc.expectedResponse, resp)
}
})
}
@@ -310,12 +310,12 @@ func TestListPodResourcesUsesOnlyActivePodsV1(t *testing.T) {
mems := []*podresourcesapi.ContainerMemory{
{
MemoryType: "memory",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
{
MemoryType: "hugepages-1Gi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
}
@@ -429,12 +429,12 @@ func TestListPodResourcesWithInitContainersV1(t *testing.T) {
memory := []*podresourcesapi.ContainerMemory{
{
MemoryType: "memory",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
{
MemoryType: "hugepages-1Gi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
}
@@ -594,8 +594,8 @@ func TestListPodResourcesWithInitContainersV1(t *testing.T) {
if err != nil {
t.Errorf("want err = %v, got %q", nil, err)
}
if diff := cmp.Diff(tc.expectedResponse, resp, cmpopts.EquateEmpty()); diff != "" {
t.Fatal(diff)
if tc.expectedResponse.String() != resp.String() {
t.Fatalf("want: %+v; got: %+v", tc.expectedResponse, resp)
}
})
}
@@ -661,7 +661,7 @@ func TestAllocatableResources(t *testing.T) {
allMemory := []*podresourcesapi.ContainerMemory{
{
MemoryType: "memory",
Size_: 5368709120,
Size: 5368709120,
Topology: &podresourcesapi.TopologyInfo{
Nodes: []*podresourcesapi.NUMANode{
{
@@ -672,7 +672,7 @@ func TestAllocatableResources(t *testing.T) {
},
{
MemoryType: "hugepages-2Mi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{
Nodes: []*podresourcesapi.NUMANode{
{
@@ -683,7 +683,7 @@ func TestAllocatableResources(t *testing.T) {
},
{
MemoryType: "memory",
Size_: 5368709120,
Size: 5368709120,
Topology: &podresourcesapi.TopologyInfo{
Nodes: []*podresourcesapi.NUMANode{
{
@@ -694,7 +694,7 @@ func TestAllocatableResources(t *testing.T) {
},
{
MemoryType: "hugepages-2Mi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{
Nodes: []*podresourcesapi.NUMANode{
{
@@ -885,8 +885,8 @@ func TestAllocatableResources(t *testing.T) {
t.Errorf("want err = %v, got %q", nil, err)
}
if diff := cmp.Diff(tc.expectedAllocatableResourcesResponse, resp, cmpopts.EquateEmpty()); diff != "" {
t.Fatal(diff)
if tc.expectedAllocatableResourcesResponse.String() != resp.String() {
t.Fatalf("want: %+v; got: %+v", tc.expectedAllocatableResourcesResponse, resp)
}
})
}
@@ -915,12 +915,12 @@ func TestGetPodResourcesV1(t *testing.T) {
memory := []*podresourcesapi.ContainerMemory{
{
MemoryType: "memory",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
{
MemoryType: "hugepages-1Gi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
}
@@ -947,7 +947,7 @@ func TestGetPodResourcesV1(t *testing.T) {
{
ClaimName: "claim-name",
ClaimNamespace: "default",
ClaimResources: []*podresourcesapi.ClaimResource{{CDIDevices: pluginCDIDevices}},
ClaimResources: []*podresourcesapi.ClaimResource{{CdiDevices: pluginCDIDevices}},
},
}
@@ -1059,8 +1059,8 @@ func TestGetPodResourcesV1(t *testing.T) {
if err != tc.err {
t.Errorf("want exit = %v, got %v", tc.err, err)
} else {
if diff := cmp.Diff(tc.expectedResponse, resp, cmpopts.EquateEmpty()); diff != "" {
t.Fatal(diff)
if tc.expectedResponse.String() != resp.String() {
t.Fatalf("want: %+v; got: %+v", tc.expectedResponse, resp)
}
}
}
@@ -1094,12 +1094,12 @@ func TestGetPodResourcesWithInitContainersV1(t *testing.T) {
memory := []*podresourcesapi.ContainerMemory{
{
MemoryType: "memory",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
{
MemoryType: "hugepages-1Gi",
Size_: 1073741824,
Size: 1073741824,
Topology: &podresourcesapi.TopologyInfo{Nodes: []*podresourcesapi.NUMANode{{ID: numaID}}},
},
}
@@ -1251,8 +1251,8 @@ func TestGetPodResourcesWithInitContainersV1(t *testing.T) {
if err != nil {
t.Errorf("want err = %v, got %q", nil, err)
}
if diff := cmp.Diff(tc.expectedResponse, resp, cmpopts.EquateEmpty()); diff != "" {
t.Fatal(diff)
if tc.expectedResponse.String() != resp.String() {
t.Fatalf("want: %+v; got: %+v", tc.expectedResponse, resp)
}
})
}

View File

@@ -21,7 +21,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubelet/pkg/apis/podresources/v1"
v1 "k8s.io/kubelet/pkg/apis/podresources/v1"
"k8s.io/kubelet/pkg/apis/podresources/v1alpha1"
)
@@ -29,6 +29,7 @@ import (
type v1alpha1PodResourcesServer struct {
podsProvider PodsProvider
devicesProvider DevicesProvider
v1alpha1.UnsafePodResourcesListerServer
}
// NewV1alpha1PodResourcesServer returns a PodResourcesListerServer which lists pods provided by the PodsProvider

View File

@@ -985,7 +985,7 @@ func (cm *containerManagerImpl) GetDynamicResources(pod *v1.Pod, container *v1.C
cdiDevices = append(cdiDevices, &podresourcesapi.CDIDevice{Name: cdiDeviceID})
}
resources := &podresourcesapi.ClaimResource{
CDIDevices: cdiDevices,
CdiDevices: cdiDevices,
DriverName: driverName,
PoolName: device.PoolName,
DeviceName: device.DeviceName,
@@ -1017,7 +1017,7 @@ func containerMemoryFromBlock(blocks []memorymanagerstate.Block) []*podresources
for _, b := range blocks {
containerMemory := podresourcesapi.ContainerMemory{
MemoryType: string(b.Type),
Size_: b.Size,
Size: b.Size,
Topology: &podresourcesapi.TopologyInfo{
Nodes: []*podresourcesapi.NUMANode{},
},

View File

@@ -12,6 +12,7 @@ require (
github.com/stretchr/testify v1.10.0
go.uber.org/goleak v1.3.0
google.golang.org/grpc v1.72.1
google.golang.org/protobuf v1.36.5
k8s.io/api v0.0.0
k8s.io/apimachinery v0.0.0
k8s.io/apiserver v0.0.0
@@ -56,7 +57,6 @@ require (
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect

File diff suppressed because it is too large Load Diff

View File

@@ -4,16 +4,6 @@ syntax = "proto3";
package v1;
option go_package = "k8s.io/kubelet/pkg/apis/podresources/v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = true;
option (gogoproto.goproto_getters_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_unrecognized_all) = false;
// PodResourcesLister is a service provided by the kubelet that provides information about the
// node resources consumed by pods and containers on the node
@@ -94,7 +84,7 @@ message DynamicResource {
// of resources, then device_name will be empty and other fields will get added.
// Each device at the DRA API level may map to zero or more CDI devices.
message ClaimResource {
repeated CDIDevice cdi_devices = 1 [(gogoproto.customname) = "CDIDevices"];
repeated CDIDevice cdi_devices = 1;
string driver_name = 2;
string pool_name = 3;
string device_name = 4;

View File

@@ -0,0 +1,221 @@
/*
Copyright The Kubernetes 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.
*/
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v4.23.4
// source: staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto
package v1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
PodResourcesLister_List_FullMethodName = "/v1.PodResourcesLister/List"
PodResourcesLister_GetAllocatableResources_FullMethodName = "/v1.PodResourcesLister/GetAllocatableResources"
PodResourcesLister_Get_FullMethodName = "/v1.PodResourcesLister/Get"
)
// PodResourcesListerClient is the client API for PodResourcesLister service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// PodResourcesLister is a service provided by the kubelet that provides information about the
// node resources consumed by pods and containers on the node
type PodResourcesListerClient interface {
List(ctx context.Context, in *ListPodResourcesRequest, opts ...grpc.CallOption) (*ListPodResourcesResponse, error)
GetAllocatableResources(ctx context.Context, in *AllocatableResourcesRequest, opts ...grpc.CallOption) (*AllocatableResourcesResponse, error)
Get(ctx context.Context, in *GetPodResourcesRequest, opts ...grpc.CallOption) (*GetPodResourcesResponse, error)
}
type podResourcesListerClient struct {
cc grpc.ClientConnInterface
}
func NewPodResourcesListerClient(cc grpc.ClientConnInterface) PodResourcesListerClient {
return &podResourcesListerClient{cc}
}
func (c *podResourcesListerClient) List(ctx context.Context, in *ListPodResourcesRequest, opts ...grpc.CallOption) (*ListPodResourcesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListPodResourcesResponse)
err := c.cc.Invoke(ctx, PodResourcesLister_List_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *podResourcesListerClient) GetAllocatableResources(ctx context.Context, in *AllocatableResourcesRequest, opts ...grpc.CallOption) (*AllocatableResourcesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AllocatableResourcesResponse)
err := c.cc.Invoke(ctx, PodResourcesLister_GetAllocatableResources_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *podResourcesListerClient) Get(ctx context.Context, in *GetPodResourcesRequest, opts ...grpc.CallOption) (*GetPodResourcesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetPodResourcesResponse)
err := c.cc.Invoke(ctx, PodResourcesLister_Get_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// PodResourcesListerServer is the server API for PodResourcesLister service.
// All implementations must embed UnimplementedPodResourcesListerServer
// for forward compatibility.
//
// PodResourcesLister is a service provided by the kubelet that provides information about the
// node resources consumed by pods and containers on the node
type PodResourcesListerServer interface {
List(context.Context, *ListPodResourcesRequest) (*ListPodResourcesResponse, error)
GetAllocatableResources(context.Context, *AllocatableResourcesRequest) (*AllocatableResourcesResponse, error)
Get(context.Context, *GetPodResourcesRequest) (*GetPodResourcesResponse, error)
mustEmbedUnimplementedPodResourcesListerServer()
}
// UnimplementedPodResourcesListerServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedPodResourcesListerServer struct{}
func (UnimplementedPodResourcesListerServer) List(context.Context, *ListPodResourcesRequest) (*ListPodResourcesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (UnimplementedPodResourcesListerServer) GetAllocatableResources(context.Context, *AllocatableResourcesRequest) (*AllocatableResourcesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAllocatableResources not implemented")
}
func (UnimplementedPodResourcesListerServer) Get(context.Context, *GetPodResourcesRequest) (*GetPodResourcesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Get not implemented")
}
func (UnimplementedPodResourcesListerServer) mustEmbedUnimplementedPodResourcesListerServer() {}
func (UnimplementedPodResourcesListerServer) testEmbeddedByValue() {}
// UnsafePodResourcesListerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to PodResourcesListerServer will
// result in compilation errors.
type UnsafePodResourcesListerServer interface {
mustEmbedUnimplementedPodResourcesListerServer()
}
func RegisterPodResourcesListerServer(s grpc.ServiceRegistrar, srv PodResourcesListerServer) {
// If the following call pancis, it indicates UnimplementedPodResourcesListerServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&PodResourcesLister_ServiceDesc, srv)
}
func _PodResourcesLister_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListPodResourcesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PodResourcesListerServer).List(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PodResourcesLister_List_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PodResourcesListerServer).List(ctx, req.(*ListPodResourcesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PodResourcesLister_GetAllocatableResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AllocatableResourcesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PodResourcesListerServer).GetAllocatableResources(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PodResourcesLister_GetAllocatableResources_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PodResourcesListerServer).GetAllocatableResources(ctx, req.(*AllocatableResourcesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PodResourcesLister_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPodResourcesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PodResourcesListerServer).Get(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PodResourcesLister_Get_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PodResourcesListerServer).Get(ctx, req.(*GetPodResourcesRequest))
}
return interceptor(ctx, in, info, handler)
}
// PodResourcesLister_ServiceDesc is the grpc.ServiceDesc for PodResourcesLister service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PodResourcesLister_ServiceDesc = grpc.ServiceDesc{
ServiceName: "v1.PodResourcesLister",
HandlerType: (*PodResourcesListerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "List",
Handler: _PodResourcesLister_List_Handler,
},
{
MethodName: "GetAllocatableResources",
Handler: _PodResourcesLister_GetAllocatableResources_Handler,
},
{
MethodName: "Get",
Handler: _PodResourcesLister_Get_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "staging/src/k8s.io/kubelet/pkg/apis/podresources/v1/api.proto",
}

View File

@@ -4,17 +4,6 @@ syntax = "proto3";
package v1alpha1;
option go_package = "k8s.io/kubelet/pkg/apis/podresources/v1alpha1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = true;
option (gogoproto.goproto_getters_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_unrecognized_all) = false;
// PodResourcesLister is a service provided by the kubelet that provides information about the
// node resources consumed by pods and containers on the node
service PodResourcesLister {

View File

@@ -0,0 +1,145 @@
/*
Copyright The Kubernetes 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.
*/
// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v4.23.4
// source: staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto
package v1alpha1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
PodResourcesLister_List_FullMethodName = "/v1alpha1.PodResourcesLister/List"
)
// PodResourcesListerClient is the client API for PodResourcesLister service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// PodResourcesLister is a service provided by the kubelet that provides information about the
// node resources consumed by pods and containers on the node
type PodResourcesListerClient interface {
List(ctx context.Context, in *ListPodResourcesRequest, opts ...grpc.CallOption) (*ListPodResourcesResponse, error)
}
type podResourcesListerClient struct {
cc grpc.ClientConnInterface
}
func NewPodResourcesListerClient(cc grpc.ClientConnInterface) PodResourcesListerClient {
return &podResourcesListerClient{cc}
}
func (c *podResourcesListerClient) List(ctx context.Context, in *ListPodResourcesRequest, opts ...grpc.CallOption) (*ListPodResourcesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListPodResourcesResponse)
err := c.cc.Invoke(ctx, PodResourcesLister_List_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// PodResourcesListerServer is the server API for PodResourcesLister service.
// All implementations must embed UnimplementedPodResourcesListerServer
// for forward compatibility.
//
// PodResourcesLister is a service provided by the kubelet that provides information about the
// node resources consumed by pods and containers on the node
type PodResourcesListerServer interface {
List(context.Context, *ListPodResourcesRequest) (*ListPodResourcesResponse, error)
mustEmbedUnimplementedPodResourcesListerServer()
}
// UnimplementedPodResourcesListerServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedPodResourcesListerServer struct{}
func (UnimplementedPodResourcesListerServer) List(context.Context, *ListPodResourcesRequest) (*ListPodResourcesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (UnimplementedPodResourcesListerServer) mustEmbedUnimplementedPodResourcesListerServer() {}
func (UnimplementedPodResourcesListerServer) testEmbeddedByValue() {}
// UnsafePodResourcesListerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to PodResourcesListerServer will
// result in compilation errors.
type UnsafePodResourcesListerServer interface {
mustEmbedUnimplementedPodResourcesListerServer()
}
func RegisterPodResourcesListerServer(s grpc.ServiceRegistrar, srv PodResourcesListerServer) {
// If the following call pancis, it indicates UnimplementedPodResourcesListerServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&PodResourcesLister_ServiceDesc, srv)
}
func _PodResourcesLister_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListPodResourcesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PodResourcesListerServer).List(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PodResourcesLister_List_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PodResourcesListerServer).List(ctx, req.(*ListPodResourcesRequest))
}
return interceptor(ctx, in, info, handler)
}
// PodResourcesLister_ServiceDesc is the grpc.ServiceDesc for PodResourcesLister service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PodResourcesLister_ServiceDesc = grpc.ServiceDesc{
ServiceName: "v1alpha1.PodResourcesLister",
HandlerType: (*PodResourcesListerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "List",
Handler: _PodResourcesLister_List_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "staging/src/k8s.io/kubelet/pkg/apis/podresources/v1alpha1/api.proto",
}

View File

@@ -408,7 +408,7 @@ var _ = SIGDescribe("Memory Manager", "[LinuxOnly]", framework.WithDisruptive(),
continue
}
gomega.Expect(containerMemory.Size_).To(gomega.BeEquivalentTo(numaStateMemory.Size))
gomega.Expect(containerMemory.Size).To(gomega.BeEquivalentTo(numaStateMemory.Size))
}
}
@@ -541,7 +541,7 @@ var _ = SIGDescribe("Memory Manager", "[LinuxOnly]", framework.WithDisruptive(),
q := c.Resources.Limits[v1.ResourceName(containerMemory.MemoryType)]
value, ok := q.AsInt64()
gomega.Expect(ok).To(gomega.BeTrueBecause("cannot convert value to integer"))
gomega.Expect(value).To(gomega.BeEquivalentTo(containerMemory.Size_))
gomega.Expect(value).To(gomega.BeEquivalentTo(containerMemory.Size))
}
}
}

View File

@@ -283,17 +283,17 @@ func logPodResources(podIdx int, pr *kubeletpodresourcesv1.PodResources) {
}
}
type podResMap map[string]map[string]kubeletpodresourcesv1.ContainerResources
type podResMap map[string]map[string]*kubeletpodresourcesv1.ContainerResources
func convertToMap(podsResources []*kubeletpodresourcesv1.PodResources) podResMap {
res := make(map[string]map[string]kubeletpodresourcesv1.ContainerResources)
res := make(map[string]map[string]*kubeletpodresourcesv1.ContainerResources)
for idx, podResource := range podsResources {
// to make troubleshooting easier
logPodResources(idx, podResource)
cnts := make(map[string]kubeletpodresourcesv1.ContainerResources)
cnts := make(map[string]*kubeletpodresourcesv1.ContainerResources)
for _, cnt := range podResource.GetContainers() {
cnts[cnt.GetName()] = *cnt
cnts[cnt.GetName()] = cnt
}
res[podResource.GetName()] = cnts
}