resourcemonitors

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 29 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

This section is empty.

Variables

View Source
var File_pkg_liqo_controller_manager_resource_request_controller_resource_monitors_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: "pkg/liqo-controller-manager/resource-request-controller/resource-monitors/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 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) (*ExternalResourceMonitor, error)

NewExternalMonitor creates a new ExternalResourceMonitor.

func (*ExternalResourceMonitor) ReadResources

func (m *ExternalResourceMonitor) ReadResources(ctx context.Context, clusterID string) corev1.ResourceList

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)

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) corev1.ResourceList

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)

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 ReadRequest

type ReadRequest struct {
	Originator string `protobuf:"bytes,1,opt,name=originator,proto3" json:"originator,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 (*ReadRequest) Descriptor deprecated

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

Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead.

func (*ReadRequest) GetOriginator

func (x *ReadRequest) GetOriginator() string

func (*ReadRequest) ProtoMessage

func (*ReadRequest) ProtoMessage()

func (*ReadRequest) ProtoReflect

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

func (*ReadRequest) Reset

func (x *ReadRequest) Reset()

func (*ReadRequest) String

func (x *ReadRequest) String() string

type ReadResponse

type ReadResponse struct {
	Resources map[string]string `` /* 159-byte string literal not displayed */
	// contains filtered or unexported fields
}

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

func (*ReadResponse) Descriptor deprecated

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

Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead.

func (*ReadResponse) GetResources

func (x *ReadResponse) GetResources() map[string]string

func (*ReadResponse) ProtoMessage

func (*ReadResponse) ProtoMessage()

func (*ReadResponse) ProtoReflect

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

func (*ReadResponse) Reset

func (x *ReadResponse) Reset()

func (*ReadResponse) String

func (x *ReadResponse) String() string

type RemoveRequest

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

A request to remove a cluster from a reader's data structures.

func (*RemoveRequest) Descriptor deprecated

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

Deprecated: Use RemoveRequest.ProtoReflect.Descriptor instead.

func (*RemoveRequest) GetCluster

func (x *RemoveRequest) GetCluster() string

func (*RemoveRequest) ProtoMessage

func (*RemoveRequest) ProtoMessage()

func (*RemoveRequest) ProtoReflect

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

func (*RemoveRequest) Reset

func (x *RemoveRequest) Reset()

func (*RemoveRequest) String

func (x *RemoveRequest) String() string

type RemoveResponse

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

func (*RemoveResponse) Descriptor deprecated

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

Deprecated: Use RemoveResponse.ProtoReflect.Descriptor instead.

func (*RemoveResponse) ProtoMessage

func (*RemoveResponse) ProtoMessage()

func (*RemoveResponse) ProtoReflect

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

func (*RemoveResponse) Reset

func (x *RemoveResponse) Reset()

func (*RemoveResponse) String

func (x *RemoveResponse) String() string

type ResourceReader

type ResourceReader interface {
	// ReadResources returns the resources available for usage by the given cluster.
	ReadResources(ctx context.Context, clusterID string) corev1.ResourceList
	// 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)
}

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

type ResourceReaderClient

type ResourceReaderClient interface {
	ReadResources(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error)
	RemoveCluster(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error)
	Subscribe(ctx context.Context, in *SubscribeRequest, 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, *ReadRequest) (*ReadResponse, error)
	RemoveCluster(context.Context, *RemoveRequest) (*RemoveResponse, error)
	Subscribe(*SubscribeRequest, 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() (*UpdateNotification, error)
	grpc.ClientStream
}

type ResourceReader_SubscribeServer

type ResourceReader_SubscribeServer interface {
	Send(*UpdateNotification) 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) corev1.ResourceList

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)

RemoveClusterID removes the given clusterID from the provider.

type ResourceUpdateNotifier

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

ResourceUpdateNotifier represents an interface for OfferUpdater to receive resource updates.

type SubscribeRequest

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

A request to subscribe to a stream of notifications representing possible changes in resources.

func (*SubscribeRequest) Descriptor deprecated

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

Deprecated: Use SubscribeRequest.ProtoReflect.Descriptor instead.

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) ProtoReflect

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

func (*SubscribeRequest) Reset

func (x *SubscribeRequest) Reset()

func (*SubscribeRequest) String

func (x *SubscribeRequest) String() string

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.

type UpdateNotification

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

func (*UpdateNotification) Descriptor deprecated

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

Deprecated: Use UpdateNotification.ProtoReflect.Descriptor instead.

func (*UpdateNotification) ProtoMessage

func (*UpdateNotification) ProtoMessage()

func (*UpdateNotification) ProtoReflect

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

func (*UpdateNotification) Reset

func (x *UpdateNotification) Reset()

func (*UpdateNotification) String

func (x *UpdateNotification) String() string

Jump to

Keyboard shortcuts

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