1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-14 20:56:42 +00:00

topologyupdater: gRPC API definition

Setup the topologyupdater API for gRPC communication of
nfd-topology-updater with master

We generate pb.go file to reflect latest dependency changes
using github.com/golang/protobuf/protoc-gen-go and generate
grpc files via:
`protoc pkg/topologyupdater/topology-updater.proto --go_out=plugins=grpc:.`

Please refer to: https://github.com/k8stopologyawareschedwg/noderesourcetopology-api/blob/master/pkg/apis/topology/v1alpha1/types.go

Co-Authored-by: Artyom Lukianov <alukiano@redhat.com>
Co-Authored-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
This commit is contained in:
Francesco Romani 2021-05-13 12:51:15 +02:00 committed by Swati Sehgal
parent 102003f8b3
commit 00cc07da76
10 changed files with 854 additions and 2 deletions

View file

@ -102,6 +102,7 @@ mock:
mockery --name=LabelSource --dir=source --inpkg --note="Re-generate by running 'make mock'"
mockery --name=APIHelpers --dir=pkg/apihelper --inpkg --note="Re-generate by running 'make mock'"
mockery --name=LabelerClient --dir=pkg/labeler --inpkg --note="Re-generate by running 'make mock'"
mockery --name=NodeTopologyClient --dir=pkg/topologyupdater --inpkg --note="Re-generate by running 'make mock'"
apigen:
protoc --go_opt=paths=source_relative --go_out=plugins=grpc:. pkg/labeler/labeler.proto

2
go.mod
View file

@ -4,6 +4,8 @@ go 1.16
require (
github.com/fsnotify/fsnotify v1.4.9
github.com/golang/protobuf v1.5.2
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.9
github.com/klauspost/cpuid/v2 v2.0.9
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1

2
go.sum
View file

@ -406,6 +406,8 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.9 h1:kdyhXrB7d/1atUosPAAeRcAgtjfju6xlzt97PPgXv2o=
github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.9/go.mod h1:zRoCNg6LjSQewUwnpORw1VT9mP0rGNQlYy4WYaGWvHo=
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

View file

@ -17,6 +17,7 @@ limitations under the License.
package apihelper
import (
topologyclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned"
api "k8s.io/api/core/v1"
k8sclient "k8s.io/client-go/kubernetes"
)
@ -40,4 +41,7 @@ type APIHelpers interface {
// PatchNodeStatus updates the node status via the API server using a client.
PatchNodeStatus(*k8sclient.Clientset, string, []JsonPatch) error
// GetTopologyClient returns a topologyclientset
GetTopologyClient() (*topologyclientset.Clientset, error)
}

View file

@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
topologyclientset "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned"
api "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
@ -54,6 +55,27 @@ func (h K8sHelpers) GetClient() (*k8sclient.Clientset, error) {
return clientset, nil
}
func (h K8sHelpers) GetTopologyClient() (*topologyclientset.Clientset, error) {
// Set up an in-cluster K8S client.
var config *restclient.Config
var err error
if h.Kubeconfig == "" {
config, err = restclient.InClusterConfig()
} else {
config, err = clientcmd.BuildConfigFromFlags("", h.Kubeconfig)
}
if err != nil {
return nil, err
}
topologyClient, err := topologyclientset.NewForConfig(config)
if err != nil {
return nil, err
}
return topologyClient, nil
}
func (h K8sHelpers) GetNode(cli *k8sclient.Clientset, nodeName string) (*api.Node, error) {
// Get the node object using node name
node, err := cli.CoreV1().Nodes().Get(context.TODO(), nodeName, meta_v1.GetOptions{})

View file

@ -1,4 +1,4 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
// Code generated by mockery v2.4.0-beta. DO NOT EDIT.
// Re-generate by running 'make mock'
@ -9,6 +9,8 @@ import (
kubernetes "k8s.io/client-go/kubernetes"
v1 "k8s.io/api/core/v1"
versioned "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned"
)
// MockAPIHelpers is an autogenerated mock type for the APIHelpers type
@ -85,6 +87,29 @@ func (_m *MockAPIHelpers) GetNodes(_a0 *kubernetes.Clientset) (*v1.NodeList, err
return r0, r1
}
// GetTopologyClient provides a mock function with given fields:
func (_m *MockAPIHelpers) GetTopologyClient() (*versioned.Clientset, error) {
ret := _m.Called()
var r0 *versioned.Clientset
if rf, ok := ret.Get(0).(func() *versioned.Clientset); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*versioned.Clientset)
}
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// PatchNode provides a mock function with given fields: _a0, _a1, _a2
func (_m *MockAPIHelpers) PatchNode(_a0 *kubernetes.Clientset, _a1 string, _a2 []JsonPatch) error {
ret := _m.Called(_a0, _a1, _a2)

View file

@ -1,4 +1,4 @@
// Code generated by mockery v1.0.0. DO NOT EDIT.
// Code generated by mockery v2.4.0-beta. DO NOT EDIT.
// Re-generate by running 'make mock'

View file

@ -0,0 +1,48 @@
// Code generated by mockery v2.4.0-beta. DO NOT EDIT.
// Re-generate by running 'make mock'
package topologyupdater
import (
context "context"
grpc "google.golang.org/grpc"
mock "github.com/stretchr/testify/mock"
)
// MockNodeTopologyClient is an autogenerated mock type for the NodeTopologyClient type
type MockNodeTopologyClient struct {
mock.Mock
}
// UpdateNodeTopology provides a mock function with given fields: ctx, in, opts
func (_m *MockNodeTopologyClient) UpdateNodeTopology(ctx context.Context, in *NodeTopologyRequest, opts ...grpc.CallOption) (*NodeTopologyResponse, error) {
_va := make([]interface{}, len(opts))
for _i := range opts {
_va[_i] = opts[_i]
}
var _ca []interface{}
_ca = append(_ca, ctx, in)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
var r0 *NodeTopologyResponse
if rf, ok := ret.Get(0).(func(context.Context, *NodeTopologyRequest, ...grpc.CallOption) *NodeTopologyResponse); ok {
r0 = rf(ctx, in, opts...)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*NodeTopologyResponse)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, *NodeTopologyRequest, ...grpc.CallOption) error); ok {
r1 = rf(ctx, in, opts...)
} else {
r1 = ret.Error(1)
}
return r0, r1
}

View file

@ -0,0 +1,688 @@
//
//Copyright 2021 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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.6.1
// source: pkg/topologyupdater/topology-updater.proto
//option go_package = "topologyupdater";
package topologyupdater
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type NodeTopologyRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
NfdVersion string `protobuf:"bytes,1,opt,name=nfd_version,json=nfdVersion,proto3" json:"nfd_version,omitempty"`
NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
TopologyPolicies []string `protobuf:"bytes,3,rep,name=topology_policies,json=topologyPolicies,proto3" json:"topology_policies,omitempty"`
Zones []*Zone `protobuf:"bytes,4,rep,name=zones,proto3" json:"zones,omitempty"`
}
func (x *NodeTopologyRequest) Reset() {
*x = NodeTopologyRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NodeTopologyRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NodeTopologyRequest) ProtoMessage() {}
func (x *NodeTopologyRequest) ProtoReflect() protoreflect.Message {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[0]
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 NodeTopologyRequest.ProtoReflect.Descriptor instead.
func (*NodeTopologyRequest) Descriptor() ([]byte, []int) {
return file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP(), []int{0}
}
func (x *NodeTopologyRequest) GetNfdVersion() string {
if x != nil {
return x.NfdVersion
}
return ""
}
func (x *NodeTopologyRequest) GetNodeName() string {
if x != nil {
return x.NodeName
}
return ""
}
func (x *NodeTopologyRequest) GetTopologyPolicies() []string {
if x != nil {
return x.TopologyPolicies
}
return nil
}
func (x *NodeTopologyRequest) GetZones() []*Zone {
if x != nil {
return x.Zones
}
return nil
}
type Zone struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
Parent string `protobuf:"bytes,3,opt,name=parent,proto3" json:"parent,omitempty"`
Costs []*CostInfo `protobuf:"bytes,4,rep,name=costs,proto3" json:"costs,omitempty"`
Attributes []*AttributeInfo `protobuf:"bytes,5,rep,name=attributes,proto3" json:"attributes,omitempty"`
Resources []*ResourceInfo `protobuf:"bytes,6,rep,name=resources,proto3" json:"resources,omitempty"`
}
func (x *Zone) Reset() {
*x = Zone{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Zone) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Zone) ProtoMessage() {}
func (x *Zone) ProtoReflect() protoreflect.Message {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[1]
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 Zone.ProtoReflect.Descriptor instead.
func (*Zone) Descriptor() ([]byte, []int) {
return file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP(), []int{1}
}
func (x *Zone) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Zone) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *Zone) GetParent() string {
if x != nil {
return x.Parent
}
return ""
}
func (x *Zone) GetCosts() []*CostInfo {
if x != nil {
return x.Costs
}
return nil
}
func (x *Zone) GetAttributes() []*AttributeInfo {
if x != nil {
return x.Attributes
}
return nil
}
func (x *Zone) GetResources() []*ResourceInfo {
if x != nil {
return x.Resources
}
return nil
}
type CostInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Value int32 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"`
}
func (x *CostInfo) Reset() {
*x = CostInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CostInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CostInfo) ProtoMessage() {}
func (x *CostInfo) ProtoReflect() protoreflect.Message {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[2]
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 CostInfo.ProtoReflect.Descriptor instead.
func (*CostInfo) Descriptor() ([]byte, []int) {
return file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP(), []int{2}
}
func (x *CostInfo) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CostInfo) GetValue() int32 {
if x != nil {
return x.Value
}
return 0
}
type AttributeInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}
func (x *AttributeInfo) Reset() {
*x = AttributeInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AttributeInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AttributeInfo) ProtoMessage() {}
func (x *AttributeInfo) ProtoReflect() protoreflect.Message {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[3]
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 AttributeInfo.ProtoReflect.Descriptor instead.
func (*AttributeInfo) Descriptor() ([]byte, []int) {
return file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP(), []int{3}
}
func (x *AttributeInfo) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *AttributeInfo) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
type ResourceInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Allocatable string `protobuf:"bytes,2,opt,name=allocatable,proto3" json:"allocatable,omitempty"`
Capacity string `protobuf:"bytes,3,opt,name=capacity,proto3" json:"capacity,omitempty"`
}
func (x *ResourceInfo) Reset() {
*x = ResourceInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ResourceInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ResourceInfo) ProtoMessage() {}
func (x *ResourceInfo) ProtoReflect() protoreflect.Message {
mi := &file_pkg_topologyupdater_topology_updater_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 ResourceInfo.ProtoReflect.Descriptor instead.
func (*ResourceInfo) Descriptor() ([]byte, []int) {
return file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP(), []int{4}
}
func (x *ResourceInfo) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *ResourceInfo) GetAllocatable() string {
if x != nil {
return x.Allocatable
}
return ""
}
func (x *ResourceInfo) GetCapacity() string {
if x != nil {
return x.Capacity
}
return ""
}
type NodeTopologyResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *NodeTopologyResponse) Reset() {
*x = NodeTopologyResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *NodeTopologyResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NodeTopologyResponse) ProtoMessage() {}
func (x *NodeTopologyResponse) ProtoReflect() protoreflect.Message {
mi := &file_pkg_topologyupdater_topology_updater_proto_msgTypes[5]
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 NodeTopologyResponse.ProtoReflect.Descriptor instead.
func (*NodeTopologyResponse) Descriptor() ([]byte, []int) {
return file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP(), []int{5}
}
var File_pkg_topologyupdater_topology_updater_proto protoreflect.FileDescriptor
var file_pkg_topologyupdater_topology_updater_proto_rawDesc = []byte{
0x0a, 0x2a, 0x70, 0x6b, 0x67, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x75, 0x70,
0x64, 0x61, 0x74, 0x65, 0x72, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2d, 0x75,
0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x74, 0x6f,
0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x22, 0xad, 0x01,
0x0a, 0x13, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, 0x66, 0x64, 0x5f, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6e, 0x66, 0x64, 0x56,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e,
0x61, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x5f,
0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10,
0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73,
0x12, 0x2b, 0x0a, 0x05, 0x7a, 0x6f, 0x6e, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x15, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65,
0x72, 0x2e, 0x5a, 0x6f, 0x6e, 0x65, 0x52, 0x05, 0x7a, 0x6f, 0x6e, 0x65, 0x73, 0x22, 0xf4, 0x01,
0x0a, 0x04, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79,
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16,
0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x05, 0x63, 0x6f, 0x73, 0x74, 0x73, 0x18,
0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f,
0x52, 0x05, 0x63, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x3e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69,
0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x6f,
0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x2e, 0x41, 0x74,
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x61, 0x74, 0x74,
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x3b, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x74, 0x6f, 0x70,
0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73,
0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x73, 0x22, 0x34, 0x0a, 0x08, 0x43, 0x6f, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x39, 0x0a, 0x0d, 0x41, 0x74,
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x60, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x6c, 0x6c,
0x6f, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63,
0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63,
0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x22, 0x16, 0x0a, 0x14, 0x4e, 0x6f, 0x64, 0x65, 0x54,
0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32,
0x71, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x12,
0x61, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x6f, 0x70,
0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x12, 0x24, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x6f, 0x70, 0x6f,
0x6c, 0x6f, 0x67, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x74, 0x6f,
0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x72, 0x2e, 0x4e, 0x6f,
0x64, 0x65, 0x54, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_pkg_topologyupdater_topology_updater_proto_rawDescOnce sync.Once
file_pkg_topologyupdater_topology_updater_proto_rawDescData = file_pkg_topologyupdater_topology_updater_proto_rawDesc
)
func file_pkg_topologyupdater_topology_updater_proto_rawDescGZIP() []byte {
file_pkg_topologyupdater_topology_updater_proto_rawDescOnce.Do(func() {
file_pkg_topologyupdater_topology_updater_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_topologyupdater_topology_updater_proto_rawDescData)
})
return file_pkg_topologyupdater_topology_updater_proto_rawDescData
}
var file_pkg_topologyupdater_topology_updater_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_pkg_topologyupdater_topology_updater_proto_goTypes = []interface{}{
(*NodeTopologyRequest)(nil), // 0: topologyupdater.NodeTopologyRequest
(*Zone)(nil), // 1: topologyupdater.Zone
(*CostInfo)(nil), // 2: topologyupdater.CostInfo
(*AttributeInfo)(nil), // 3: topologyupdater.AttributeInfo
(*ResourceInfo)(nil), // 4: topologyupdater.ResourceInfo
(*NodeTopologyResponse)(nil), // 5: topologyupdater.NodeTopologyResponse
}
var file_pkg_topologyupdater_topology_updater_proto_depIdxs = []int32{
1, // 0: topologyupdater.NodeTopologyRequest.zones:type_name -> topologyupdater.Zone
2, // 1: topologyupdater.Zone.costs:type_name -> topologyupdater.CostInfo
3, // 2: topologyupdater.Zone.attributes:type_name -> topologyupdater.AttributeInfo
4, // 3: topologyupdater.Zone.resources:type_name -> topologyupdater.ResourceInfo
0, // 4: topologyupdater.NodeTopology.UpdateNodeTopology:input_type -> topologyupdater.NodeTopologyRequest
5, // 5: topologyupdater.NodeTopology.UpdateNodeTopology:output_type -> topologyupdater.NodeTopologyResponse
5, // [5:6] is the sub-list for method output_type
4, // [4:5] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_pkg_topologyupdater_topology_updater_proto_init() }
func file_pkg_topologyupdater_topology_updater_proto_init() {
if File_pkg_topologyupdater_topology_updater_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_pkg_topologyupdater_topology_updater_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NodeTopologyRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pkg_topologyupdater_topology_updater_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Zone); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pkg_topologyupdater_topology_updater_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CostInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pkg_topologyupdater_topology_updater_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AttributeInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pkg_topologyupdater_topology_updater_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ResourceInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pkg_topologyupdater_topology_updater_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NodeTopologyResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pkg_topologyupdater_topology_updater_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_pkg_topologyupdater_topology_updater_proto_goTypes,
DependencyIndexes: file_pkg_topologyupdater_topology_updater_proto_depIdxs,
MessageInfos: file_pkg_topologyupdater_topology_updater_proto_msgTypes,
}.Build()
File_pkg_topologyupdater_topology_updater_proto = out.File
file_pkg_topologyupdater_topology_updater_proto_rawDesc = nil
file_pkg_topologyupdater_topology_updater_proto_goTypes = nil
file_pkg_topologyupdater_topology_updater_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// NodeTopologyClient is the client API for NodeTopology service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type NodeTopologyClient interface {
UpdateNodeTopology(ctx context.Context, in *NodeTopologyRequest, opts ...grpc.CallOption) (*NodeTopologyResponse, error)
}
type nodeTopologyClient struct {
cc grpc.ClientConnInterface
}
func NewNodeTopologyClient(cc grpc.ClientConnInterface) NodeTopologyClient {
return &nodeTopologyClient{cc}
}
func (c *nodeTopologyClient) UpdateNodeTopology(ctx context.Context, in *NodeTopologyRequest, opts ...grpc.CallOption) (*NodeTopologyResponse, error) {
out := new(NodeTopologyResponse)
err := c.cc.Invoke(ctx, "/topologyupdater.NodeTopology/UpdateNodeTopology", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// NodeTopologyServer is the server API for NodeTopology service.
type NodeTopologyServer interface {
UpdateNodeTopology(context.Context, *NodeTopologyRequest) (*NodeTopologyResponse, error)
}
// UnimplementedNodeTopologyServer can be embedded to have forward compatible implementations.
type UnimplementedNodeTopologyServer struct {
}
func (*UnimplementedNodeTopologyServer) UpdateNodeTopology(context.Context, *NodeTopologyRequest) (*NodeTopologyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateNodeTopology not implemented")
}
func RegisterNodeTopologyServer(s *grpc.Server, srv NodeTopologyServer) {
s.RegisterService(&_NodeTopology_serviceDesc, srv)
}
func _NodeTopology_UpdateNodeTopology_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(NodeTopologyRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NodeTopologyServer).UpdateNodeTopology(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/topologyupdater.NodeTopology/UpdateNodeTopology",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NodeTopologyServer).UpdateNodeTopology(ctx, req.(*NodeTopologyRequest))
}
return interceptor(ctx, in, info, handler)
}
var _NodeTopology_serviceDesc = grpc.ServiceDesc{
ServiceName: "topologyupdater.NodeTopology",
HandlerType: (*NodeTopologyServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "UpdateNodeTopology",
Handler: _NodeTopology_UpdateNodeTopology_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pkg/topologyupdater/topology-updater.proto",
}

View file

@ -0,0 +1,60 @@
/*
Copyright 2021 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.
*/
syntax = "proto3";
//option go_package = "topologyupdater";
package topologyupdater;
service NodeTopology{
rpc UpdateNodeTopology(NodeTopologyRequest) returns (NodeTopologyResponse);
}
message NodeTopologyRequest {
string nfd_version = 1;
string node_name = 2;
repeated string topology_policies = 3;
repeated Zone zones = 4;
}
message Zone {
string name = 1;
string type = 2;
string parent = 3;
repeated CostInfo costs = 4;
repeated AttributeInfo attributes = 5;
repeated ResourceInfo resources = 6;
}
message CostInfo {
string name = 1;
int32 value = 2 ;
}
message AttributeInfo {
string name = 1;
string value = 2 ;
}
message ResourceInfo {
string name = 1;
string allocatable = 2;
string capacity = 3;
}
message NodeTopologyResponse {
}