func CalcRequiredNodesCount(
request *RemoteNodesSamplerRequest,
storeReader collections.ConcurrentObjectStoreReader[*core.Node],
) int
Calculates the number of nodes that a sample for the specified request needs to contain.
Default implementation of RemoteSamplerClient.
type DefaultRemoteSamplerClient struct {
// contains filtered or unexported fields
}
func NewDefaultRemoteSamplerClient(
clusterName string,
baseURI string,
samplingStrategyName string,
logger *logr.Logger,
) *DefaultRemoteSamplerClient
func (sc *DefaultRemoteSamplerClient) BaseURI() string
func (sc *DefaultRemoteSamplerClient) ClusterName() string
func (sc *DefaultRemoteSamplerClient) SampleNodes(ctx context.Context, request *RemoteNodesSamplerRequest) (*RemoteNodesSamplerResponse, *RemoteNodesSamplerError)
func (sc *DefaultRemoteSamplerClient) SamplingStrategyName() string
Default implementation of RemoteSamplerClientsManager.
type DefaultRemoteSamplerClientsManager struct {
// contains filtered or unexported fields
}
func NewDefaultRemoteSamplerClientsManager(
remoteClusters map[string]*config.RemoteClusterConfig,
samplingStrategy string,
maxConcurrentRequests int,
logger *logr.Logger,
) *DefaultRemoteSamplerClientsManager
func (scm *DefaultRemoteSamplerClientsManager) SampleNodesFromClusters( ctx context.Context, request *RemoteNodesSamplerRequest, percentageOfClustersToSample float64, ) (map[string]*RemoteNodesSamplerResult, error)
DTO for error responses.
type RemoteNodesSamplerError struct {
Error *client.PolarisErrorDto `json:"error" yaml:"error"`
}
DTO for requesting a nodes sample from a remote nodes sampler.
type RemoteNodesSamplerRequest struct {
// Information about the pod that should be scheduled.
PodInfo *pipeline.PodInfo `json:"podInfo" yaml:"podInfo"`
// The number of nodes to sample defined as basis points (bp) of the total number of nodes.
// 1 bp = 0.01%
NodesToSampleBp uint32 `json:"nodesToSampleBp" yaml:"nodesToSampleBp"`
}
DTO for the response from a remote nodes sampler.
type RemoteNodesSamplerResponse struct {
// The nodes that have been sampled.
Nodes []*pipeline.NodeInfo `json:"nodes" yaml:"nodes"`
}
Combines a RemoteNodesSamplerResponse and a RemoteNodesSamplerError in one object. At all times, only one of its fields is set.
type RemoteNodesSamplerResult struct {
// The response from the remote nodes sampler, if the request was successful.
Response *RemoteNodesSamplerResponse
// The error, if the request failed.
Error *RemoteNodesSamplerError
}
A client for obtaining node samples from a remote sampler.
This is intentionally not part of the ClusterClient interface, because ClusterClient architecturally resides at a lower level.
type RemoteSamplerClient interface {
// The name of the cluster, where the remote sampler is running.
ClusterName() string
// The base URI of the remote sampler.
BaseURI() string
// The name of the sampling strategy.
SamplingStrategyName() string
// Executes a request to the remote sampler to obtain a sample of nodes.
//
// Returns a sample of nodes or an error.
SampleNodes(ctx context.Context, request *RemoteNodesSamplerRequest) (*RemoteNodesSamplerResponse, *RemoteNodesSamplerError)
}
Facilitates the use of multiple RemoteSamplerClients.
type RemoteSamplerClientsManager interface {
// Executes a request to the specified percentage of all configured remote samplers to obtain node samples.
//
// The percentageOfClustersToSample needs to be specified as a percentage in the range (0.0, 1.0].
//
// Returns a map of responses indexed by cluster name or an error.
// Note that an error is only returned in case of a fatal issue - if single clusters return an error, they will be contained in the results map.
SampleNodesFromClusters(ctx context.Context, request *RemoteNodesSamplerRequest, percentageOfClustersToSample float64) (map[string]*RemoteNodesSamplerResult, error)
}