resourcemonitors

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 27 Imported by: 3

Documentation

Overview

Package resourcemonitors contains the ResourceReader API that is used to create ResourceOffers, as well as resource monitors implementing this API.

Index

Constants

View Source
const (
	ResourceReader_ReadResources_FullMethodName = "/resource_reader/ReadResources"
	ResourceReader_RemoveCluster_FullMethodName = "/resource_reader/RemoveCluster"
	ResourceReader_Subscribe_FullMethodName     = "/resource_reader/Subscribe"
)
View Source
const (
	// AllClusterIDs useful to update all the clusters.
	AllClusterIDs = ""
)

Variables

View Source
var File_resource_reader_proto protoreflect.FileDescriptor
View Source
var ResourceReader_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "resource_reader",
	HandlerType: (*ResourceReaderServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ReadResources",
			Handler:    _ResourceReader_ReadResources_Handler,
		},
		{
			MethodName: "RemoveCluster",
			Handler:    _ResourceReader_RemoveCluster_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       _ResourceReader_Subscribe_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "resource-reader.proto",
}

ResourceReader_ServiceDesc is the grpc.ServiceDesc for ResourceReader service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterResourceReaderServer

func RegisterResourceReaderServer(s grpc.ServiceRegistrar, srv ResourceReaderServer)

func ScaleResources

func ScaleResources(resourceName corev1.ResourceName, quantity *resource.Quantity, factor float32)

ScaleResources multiplies a resource by a factor.

Types

type ClusterIdentity added in v0.6.0

type ClusterIdentity struct {
	ClusterID string `protobuf:"bytes,1,opt,name=clusterID,proto3" json:"clusterID,omitempty"`
	// contains filtered or unexported fields
}

A request to read resources to be offered to a cluster. The cluster ID is passed so that we don't offer a cluster's resources to itself.

func (*ClusterIdentity) Descriptor deprecated added in v0.6.0

func (*ClusterIdentity) Descriptor() ([]byte, []int)

Deprecated: Use ClusterIdentity.ProtoReflect.Descriptor instead.

func (*ClusterIdentity) GetClusterID added in v0.6.0

func (x *ClusterIdentity) GetClusterID() string

func (*ClusterIdentity) ProtoMessage added in v0.6.0

func (*ClusterIdentity) ProtoMessage()

func (*ClusterIdentity) ProtoReflect added in v0.6.0

func (x *ClusterIdentity) ProtoReflect() protoreflect.Message

func (*ClusterIdentity) Reset added in v0.6.0

func (x *ClusterIdentity) Reset()

func (*ClusterIdentity) String added in v0.6.0

func (x *ClusterIdentity) String() string

type Empty added in v0.6.0

type Empty struct {
	// contains filtered or unexported fields
}

An empty response

func (*Empty) Descriptor deprecated added in v0.6.0

func (*Empty) Descriptor() ([]byte, []int)

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage added in v0.6.0

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect added in v0.6.0

func (x *Empty) ProtoReflect() protoreflect.Message

func (*Empty) Reset added in v0.6.0

func (x *Empty) Reset()

func (*Empty) String added in v0.6.0

func (x *Empty) String() string

type ExternalResourceMonitor

type ExternalResourceMonitor struct {
	ResourceReaderClient
}

ExternalResourceMonitor is an object that keeps track of the cluster's resources.

func NewExternalMonitor

func NewExternalMonitor(ctx context.Context, address string, connectionTimeout time.Duration) (*ExternalResourceMonitor, error)

NewExternalMonitor creates a new ExternalResourceMonitor.

func (*ExternalResourceMonitor) ReadResources

func (m *ExternalResourceMonitor) ReadResources(ctx context.Context, clusterID string) ([]*ResourceList, error)

ReadResources reads the resources from the upstream API.

func (*ExternalResourceMonitor) Register

Register sets an update notifier.

func (*ExternalResourceMonitor) RemoveClusterID

func (m *ExternalResourceMonitor) RemoveClusterID(ctx context.Context, clusterID string) error

RemoveClusterID calls the method on the upstream API.

type LocalResourceMonitor

type LocalResourceMonitor struct {
	// contains filtered or unexported fields
}

LocalResourceMonitor is an object that keeps track of the cluster's resources.

func NewLocalMonitor

func NewLocalMonitor(ctx context.Context, clientset kubernetes.Interface,
	resyncPeriod time.Duration) *LocalResourceMonitor

NewLocalMonitor creates a new LocalResourceMonitor.

func (*LocalResourceMonitor) ReadResources

func (m *LocalResourceMonitor) ReadResources(_ context.Context, clusterID string) ([]*ResourceList, error)

ReadResources returns the resources available in the cluster (total minus used), multiplied by resourceSharingPercentage.

func (*LocalResourceMonitor) Register

Register sets an update notifier.

func (*LocalResourceMonitor) RemoveClusterID

func (m *LocalResourceMonitor) RemoveClusterID(_ context.Context, clusterID string) error

RemoveClusterID removes a clusterID from all broadcaster internal structures it is useful when a particular foreign cluster has no more peering and its ResourceRequest has been deleted.

type PodTransition

type PodTransition uint8

PodTransition represents a podReady condition possible transitions.

const (
	// PendingToReady represents a transition from PodReady status = false to PodReady status = true.
	PendingToReady PodTransition = iota
	// ReadyToReady represents no change in PodReady status when status = true.
	ReadyToReady
	// ReadyToPending represents a transition from PodReady status = true to PodReady status = false.
	ReadyToPending
	// PendingToPending represents no change in PodReady status when status = false.
	PendingToPending
)

type PoolResourceList added in v0.9.0

type PoolResourceList struct {
	ResourceLists []*ResourceList `protobuf:"bytes,1,rep,name=resource_lists,json=resourceLists,proto3" json:"resource_lists,omitempty"`
	// contains filtered or unexported fields
}

func (*PoolResourceList) Descriptor deprecated added in v0.9.0

func (*PoolResourceList) Descriptor() ([]byte, []int)

Deprecated: Use PoolResourceList.ProtoReflect.Descriptor instead.

func (*PoolResourceList) GetResourceLists added in v0.9.0

func (x *PoolResourceList) GetResourceLists() []*ResourceList

func (*PoolResourceList) ProtoMessage added in v0.9.0

func (*PoolResourceList) ProtoMessage()

func (*PoolResourceList) ProtoReflect added in v0.9.0

func (x *PoolResourceList) ProtoReflect() protoreflect.Message

func (*PoolResourceList) Reset added in v0.9.0

func (x *PoolResourceList) Reset()

func (*PoolResourceList) String added in v0.9.0

func (x *PoolResourceList) String() string

type ResourceList added in v0.6.0

type ResourceList struct {
	Resources  map[string]*resource.Quantity `` /* 159-byte string literal not displayed */
	PoolName   string                        `protobuf:"bytes,2,opt,name=pool_name,json=poolName,proto3" json:"pool_name,omitempty"`
	PoolPrefix string                        `protobuf:"bytes,3,opt,name=pool_prefix,json=poolPrefix,proto3" json:"pool_prefix,omitempty"`
	// contains filtered or unexported fields
}

A response representing a Kubernetes ResourceList. Quantities are represented as string values (eg. "ram": "1Gi").

func (*ResourceList) Descriptor deprecated added in v0.6.0

func (*ResourceList) Descriptor() ([]byte, []int)

Deprecated: Use ResourceList.ProtoReflect.Descriptor instead.

func (*ResourceList) GetPoolName added in v0.9.0

func (x *ResourceList) GetPoolName() string

func (*ResourceList) GetPoolPrefix added in v0.9.0

func (x *ResourceList) GetPoolPrefix() string

func (*ResourceList) GetResources added in v0.6.0

func (x *ResourceList) GetResources() map[string]*resource.Quantity

func (*ResourceList) ProtoMessage added in v0.6.0

func (*ResourceList) ProtoMessage()

func (*ResourceList) ProtoReflect added in v0.6.0

func (x *ResourceList) ProtoReflect() protoreflect.Message

func (*ResourceList) Reset added in v0.6.0

func (x *ResourceList) Reset()

func (*ResourceList) String added in v0.6.0

func (x *ResourceList) String() string

type ResourceListInfo added in v0.9.0

type ResourceListInfo struct {
	Resources  []corev1.ResourceList
	PoolName   string
	PoolPrefix string
}

ResourceListInfo contains the list of resources to monitor and the name of the pool they belong to.

type ResourceReader

type ResourceReader interface {
	// ReadResources returns the resources available for usage by the given cluster.
	ReadResources(ctx context.Context, clusterID string) ([]*ResourceList, error)
	// Register sets the component that will be notified of changes.
	Register(context.Context, ResourceUpdateNotifier)
	// RemoveClusterID removes the given clusterID from all internal structures.
	RemoveClusterID(ctx context.Context, clusterID string) error
}

ResourceReader represents an interface to read the available resources in this cluster.

type ResourceReaderClient

type ResourceReaderClient interface {
	ReadResources(ctx context.Context, in *ClusterIdentity, opts ...grpc.CallOption) (*PoolResourceList, error)
	RemoveCluster(ctx context.Context, in *ClusterIdentity, opts ...grpc.CallOption) (*Empty, error)
	Subscribe(ctx context.Context, in *Empty, opts ...grpc.CallOption) (ResourceReader_SubscribeClient, error)
}

ResourceReaderClient is the client API for ResourceReader 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.

type ResourceReaderServer

type ResourceReaderServer interface {
	ReadResources(context.Context, *ClusterIdentity) (*PoolResourceList, error)
	RemoveCluster(context.Context, *ClusterIdentity) (*Empty, error)
	Subscribe(*Empty, ResourceReader_SubscribeServer) error
	// contains filtered or unexported methods
}

ResourceReaderServer is the server API for ResourceReader service. All implementations must embed UnimplementedResourceReaderServer for forward compatibility

type ResourceReader_SubscribeClient

type ResourceReader_SubscribeClient interface {
	Recv() (*ClusterIdentity, error)
	grpc.ClientStream
}

type ResourceReader_SubscribeServer

type ResourceReader_SubscribeServer interface {
	Send(*ClusterIdentity) error
	grpc.ServerStream
}

type ResourceScaler

type ResourceScaler struct {
	Provider ResourceReader
	Factor   float32
	Notifier ResourceUpdateNotifier
}

ResourceScaler scales the resources of a ResourceReader by a given amount. It is used to let one reserve resources for local usage and not share them (Factor < 1).

func (*ResourceScaler) ReadResources

func (s *ResourceScaler) ReadResources(ctx context.Context, clusterID string) ([]*ResourceList, error)

ReadResources returns the provider's resources scaled by the given amount.

func (*ResourceScaler) Register

func (s *ResourceScaler) Register(ctx context.Context, notifier ResourceUpdateNotifier)

Register sets an update notifier.

func (*ResourceScaler) RemoveClusterID

func (s *ResourceScaler) RemoveClusterID(ctx context.Context, clusterID string) error

RemoveClusterID removes the given clusterID from the provider.

type ResourceUpdateNotifier

type ResourceUpdateNotifier interface {
	// NotifyChange signals that a change in resources may have occurred.
	NotifyChange(clusterID string)
}

ResourceUpdateNotifier represents an interface for OfferUpdater to receive resource updates.

type UnimplementedResourceReaderServer

type UnimplementedResourceReaderServer struct {
}

UnimplementedResourceReaderServer must be embedded to have forward compatible implementations.

func (UnimplementedResourceReaderServer) ReadResources

func (UnimplementedResourceReaderServer) RemoveCluster

func (UnimplementedResourceReaderServer) Subscribe

type UnsafeResourceReaderServer

type UnsafeResourceReaderServer interface {
	// contains filtered or unexported methods
}

UnsafeResourceReaderServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ResourceReaderServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL