interfaces

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxClusterScore is the maximum score a Score plugin is expected to return.
	MaxClusterScore int64 = 100

	// MinClusterScore is the minimum score a Score plugin is expected to return.
	MinClusterScore int64 = 0

	// MaxTotalScore is the maximum total score.
	MaxTotalScore int64 = math.MaxInt64
)
View Source
const (
	// NoClusterAvailableMsg is used to format message when no clusters available.
	NoClusterAvailableMsg = "0/%v clusters are available"
)

Variables

View Source
var (
	// ErrNotFound is the not found error message.
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type AssignPlugin added in v0.10.0

type AssignPlugin interface {
	Plugin

	// Assign is called on each selected cluster. It will assign replicas for each
	// selected cluster. The return result is a map whose key is feed key and
	// value is respective assigned replicas for each selected cluster.
	Assign(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, availableReplicas TargetClusters) (TargetClusters, *Status)
}

AssignPlugin is an interface that must be implemented by "Assign" plugins to assign replicas for each selected cluster.

type BindPlugin

type BindPlugin interface {
	Plugin

	// Bind plugins will not be called until all pre-bind plugins have completed. Each
	// bind plugin is called in the configured order. A bind plugin may choose whether
	// or not to handle the given Subscription. If a bind plugin chooses to handle a Subscription, the
	// remaining bind plugins are skipped. When a bind plugin does not handle a Subscription,
	// it must return Skip in its Status code. If a bind plugin returns an Error, the
	// subscription is rejected and will not be bound.
	Bind(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status
}

BindPlugin is an interface that must be implemented by "Bind" plugins. Bind plugins are used to bind a subscription to a group of ManagedCluster.

type ClusterScore

type ClusterScore struct {
	NamespacedName       string // the namespaced name key of a ManagedCluster
	Score                int64
	MaxAvailableReplicas FeedReplicas
}

ClusterScore is a struct with cluster id and score.

type ClusterScoreList

type ClusterScoreList []ClusterScore

ClusterScoreList declares a list of clusters and their scores.

func (ClusterScoreList) ClusterNames added in v0.10.0

func (cs ClusterScoreList) ClusterNames() []string

func (ClusterScoreList) Len added in v0.10.0

func (cs ClusterScoreList) Len() int

func (ClusterScoreList) Less added in v0.10.0

func (cs ClusterScoreList) Less(i, j int) bool

func (ClusterScoreList) Swap added in v0.10.0

func (cs ClusterScoreList) Swap(i, j int)

type ClusterToStatusMap

type ClusterToStatusMap map[string]*Status

ClusterToStatusMap declares map from cluster namespaced key to its status.

type Code

type Code int

Code is the Status code/type which is returned from plugins.

const (
	// Success means that plugin ran correctly and found subscription schedulable.
	// NOTE: A nil status is also considered as "Success".
	Success Code = iota
	// Error is used for internal plugin errors, unexpected input, etc.
	Error
	// Unschedulable is used when a plugin finds a subscription unschedulable. The scheduler might attempt to
	// preempt other subscriptions to get this subscription scheduled. Use UnschedulableAndUnresolvable to make the
	// scheduler skip preemption.
	// The accompanying status message should explain why the subscription is unschedulable.
	Unschedulable
	// UnschedulableAndUnresolvable is used when a plugin finds a subscription unschedulable and
	// preemption would not change anything. Plugins should return Unschedulable if it is possible
	// that the subscription can get scheduled with preemption.
	// The accompanying status message should explain why the subscription is unschedulable.
	UnschedulableAndUnresolvable
	// Wait is used when a Permit plugin finds a subscription scheduling should wait.
	Wait
	// Skip is used when a Bind plugin chooses to skip binding.
	Skip
)

These are predefined codes used in a Status.

func (Code) String

func (c Code) String() string

type CycleState added in v0.11.0

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

CycleState provides a mechanism for plugins to store and retrieve arbitrary data. StateData stored by one plugin can be read, altered, or deleted by another plugin. CycleState does not provide any data protection, as all plugins are assumed to be trusted. Note: CycleState uses a sync.Map to back the storage. It's aimed to optimize for the "write once and read many times" scenarios. It is the recommended pattern used in all in-tree plugins - plugin-specific state is written once in PreFilter/PreScore and afterwards read many times in Filter/Score.

func NewCycleState added in v0.11.0

func NewCycleState() *CycleState

NewCycleState initializes a new CycleState and returns its pointer.

func (*CycleState) Clone added in v0.11.0

func (c *CycleState) Clone() *CycleState

Clone creates a copy of CycleState and returns its pointer. Clone returns nil if the context being cloned is nil.

func (*CycleState) Delete added in v0.11.0

func (c *CycleState) Delete(key StateKey)

Delete deletes data with the given key from CycleState. This function is thread safe by using sync.Map.

func (*CycleState) Read added in v0.11.0

func (c *CycleState) Read(key StateKey) (StateData, error)

Read retrieves data with the given "key" from CycleState. If the key is not present an error is returned. This function is thread safe by using sync.Map.

func (*CycleState) SetRecordPluginMetrics added in v0.11.0

func (c *CycleState) SetRecordPluginMetrics(flag bool)

SetRecordPluginMetrics sets recordPluginMetrics to the given value.

func (*CycleState) ShouldRecordPluginMetrics added in v0.11.0

func (c *CycleState) ShouldRecordPluginMetrics() bool

ShouldRecordPluginMetrics returns whether PluginExecutionDuration metrics should be recorded.

func (*CycleState) Write added in v0.11.0

func (c *CycleState) Write(key StateKey, val StateData)

Write stores the given "val" in CycleState with the given "key". This function is thread safe by using sync.Map.

type Diagnosis

type Diagnosis struct {
	ClusterToStatusMap   ClusterToStatusMap
	UnschedulablePlugins sets.String
}

Diagnosis records the details to diagnose a scheduling failure.

type FeedReplicas added in v0.10.0

type FeedReplicas []*int32

type FilterPlugin

type FilterPlugin interface {
	Plugin

	// Filter is called by the scheduling framework.
	// All FilterPlugins should return "Success" to declare that
	// the given managed cluster fits the subscription. If Filter doesn't return "Success",
	// it will return Unschedulable, UnschedulableAndUnresolvable or Error.
	// For the cluster being evaluated, Filter plugins should look at the passed
	// cluster's information (e.g., subscriptions considered to be running on the cluster).
	Filter(ctx context.Context, state *CycleState, sub *appsapi.Subscription, cluster *clusterapi.ManagedCluster) *Status
}

FilterPlugin is an interface for Filter plugins. These plugins are called at the filter extension point for filtering out hosts that cannot run a subscription. This concept used to be called 'predicate' in the original scheduler. These plugins should return Success, Unschedulable or Error in Status.code. However, the scheduler accepts other valid codes as well. Anything other than "Success" will lead to exclusion of the given host from running the subscription.

type FitError

type FitError struct {
	Subscription   *appsapi.Subscription
	NumAllClusters int
	Diagnosis      Diagnosis
}

FitError describes a fit error of a subscription.

func (*FitError) Error

func (f *FitError) Error() string

Error returns detailed information of why the subscription failed to fit on each cluster

type Framework

type Framework interface {
	Handle

	// RunPreFilterPlugins runs the set of configured PreFilter plugins. It returns
	// *Status and its code is set to non-success if any of the plugins returns
	// anything but Success. If a non-success status is returned, then the scheduling
	// cycle is aborted.
	RunPreFilterPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription) *Status

	// RunPostFilterPlugins runs the set of configured PostFilter plugins.
	// PostFilter plugins can either be informational, in which case should be configured
	// to execute first and return Unschedulable status, or ones that try to change the
	// cluster state to make the subscription potentially schedulable in a future scheduling cycle.
	RunPostFilterPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, filteredClusterStatusMap ClusterToStatusMap) (*PostFilterResult, *Status)

	// RunPrePredictPlugins runs the set of configured PrePredict plugins. It returns
	// *Status and its code is set to non-success if any of the plugins returns
	// anything but Success. If a non-success status is returned, then the scheduling
	// cycle is aborted.
	RunPrePredictPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, clusters []*clusterapi.ManagedCluster) *Status

	// RunPredictPlugins runs the set of configured Predict plugins. It returns a map that
	// stores for each Predict plugin name the corresponding ClusterScoreList(s).
	// It also returns *Status, which is set to non-success if any of the plugins returns
	// a non-success status.
	RunPredictPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, clusters []*clusterapi.ManagedCluster, availableList ClusterScoreList) (ClusterScoreList, *Status)

	// RunPreAssignPlugins runs the set of configured PreAssign plugins. It returns
	// *Status and its code is set to non-success if any of the plugins returns
	// anything but Success. If a non-success status is returned, then the scheduling
	// cycle is aborted.
	RunPreAssignPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, selected TargetClusters) *Status

	// RunAssignPlugins runs the set of configured Assign plugins. An Assign plugin may choose
	// whether to handle the given subscription. If an Assign plugin chooses to skip the
	// assigning, it should return code=5("skip") status. Otherwise, it should return "Error"
	// or "Success". If none of the plugins handled assigning, RunAssignPlugins returns
	// code=5("skip") status.
	RunAssignPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, selected TargetClusters) (TargetClusters, *Status)

	// RunReservePluginsReserve runs the Reserve method of the set of
	// configured Reserve plugins. If any of these calls returns an error, it
	// does not continue running the remaining ones and returns the error. In
	// such case, subscription will not be scheduled.
	RunReservePluginsReserve(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status

	// RunReservePluginsUnreserve runs the Unreserve method of the set of
	// configured Reserve plugins.
	RunReservePluginsUnreserve(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters)

	// RunPermitPlugins runs the set of configured Permit plugins. If any of these
	// plugins returns a status other than "Success" or "Wait", it does not continue
	// running the remaining plugins and returns an error. Otherwise, if any of the
	// plugins returns "Wait", then this function will create and add waiting subscription
	// to a map of currently waiting subscriptions and return status with "Wait" code.
	// Subscription will remain waiting subscription for the minimum duration returned by the Permit plugins.
	RunPermitPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status

	// WaitOnPermit will block, if the subscription is a waiting subscription, until the waiting subscription is rejected or allowed.
	WaitOnPermit(ctx context.Context, sub *appsapi.Subscription) *Status

	// RunPreBindPlugins runs the set of configured PreBind plugins. It returns
	// *Status and its code is set to non-success if any of the plugins returns
	// anything but Success. If the Status code is Unschedulable, it is
	// considered as a scheduling check failure, otherwise, it is considered as an
	// internal error. In either case the subscription is not going to be bound.
	RunPreBindPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status

	// RunPostBindPlugins runs the set of configured PostBind plugins.
	RunPostBindPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters)

	// RunBindPlugins runs the set of configured Bind plugins. A Bind plugin may choose
	// whether or not to handle the given subscription. If a Bind plugin chooses to skip the
	// binding, it should return code=5("skip") status. Otherwise, it should return "Error"
	// or "Success". If none of the plugins handled binding, RunBindPlugins returns
	// code=5("skip") status.
	RunBindPlugins(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status

	// HasFilterPlugins returns true if at least one Filter plugin is defined.
	HasFilterPlugins() bool

	// HasPostFilterPlugins returns true if at least one PostFilter plugin is defined.
	HasPostFilterPlugins() bool

	// HasScorePlugins returns true if at least one Score plugin is defined.
	HasScorePlugins() bool

	// HasPredictPlugins returns true if at least one Predict plugin is defined.
	HasPredictPlugins() bool

	// ListPlugins returns a map of extension point name to list of configured Plugins.
	ListPlugins() *schedulerapis.Plugins

	// ProfileName returns the profile name associated to this framework.
	ProfileName() string
}

Framework manages the set of plugins in use by the scheduling framework. Configured plugins are called at specified points in a scheduling context.

type Handle

type Handle interface {
	// PluginsRunner abstracts operations to run some plugins.
	PluginsRunner

	// ClusterCache returns a cluster cache.
	ClusterCache() cache.Cache

	// IterateOverWaitingSubscriptions acquires a read lock and iterates over the WaitingSubscriptions map.
	IterateOverWaitingSubscriptions(callback func(WaitingSubscription))

	// GetWaitingSubscription returns a waiting subscription given its UID.
	GetWaitingSubscription(uid types.UID) WaitingSubscription

	// RejectWaitingSubscription rejects a waiting subscription given its UID.
	RejectWaitingSubscription(uid types.UID)

	// ClientSet returns a clusternet clientSet.
	ClientSet() clusternet.Interface

	// KubeConfig returns the raw kubeconfig.
	KubeConfig() *restclient.Config

	// EventRecorder returns an event recorder.
	EventRecorder() record.EventRecorder

	SharedInformerFactory() informers.SharedInformerFactory

	// Parallelizer returns a parallelizer holding parallelism for scheduler.
	Parallelizer() parallelize.Parallelizer
}

Handle provides data and some tools that plugins can use. It is passed to the plugin factories at the time of plugin initialization. Plugins must store and use this handle to call framework functions.

type PermitPlugin

type PermitPlugin interface {
	Plugin

	// Permit is called before binding a subscription (and before prebind plugins). Permit
	// plugins are used to prevent or delay the binding of a Subscription. A permit plugin
	// must return success or wait with timeout duration, or the subscription will be rejected.
	// The subscription will also be rejected if the wait timeout or the subscription is rejected while
	// waiting. Note that if the plugin returns "wait", the framework will wait only
	// after running the remaining plugins given that no other plugin rejects the subscription.
	Permit(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) (*Status, time.Duration)
}

PermitPlugin is an interface that must be implemented by "Permit" plugins. These plugins are called before a subscription is bound to a group of ManagedCluster.

type Plugin

type Plugin interface {
	Name() string
}

Plugin is the parent type for all the scheduling framework plugins.

type PluginToClusterReplicas added in v0.10.0

type PluginToClusterReplicas map[string]ClusterScoreList

PluginToClusterReplicas declares a map from plugin name to its ClusterScoreList.

type PluginToClusterScores

type PluginToClusterScores map[string]ClusterScoreList

PluginToClusterScores declares a map from plugin name to its ClusterScoreList.

type PluginToStatus

type PluginToStatus map[string]*Status

PluginToStatus maps plugin name to status. Currently, used to identify which Filter plugin returned which status.

func (PluginToStatus) Merge

func (p PluginToStatus) Merge() *Status

Merge merges the statuses in the map into one. The resulting status code have the following precedence: Error, UnschedulableAndUnresolvable, Unschedulable.

type PluginsRunner

type PluginsRunner interface {
	// RunPreScorePlugins runs the set of configured PreScore plugins. If any
	// of these plugins returns any status other than "Success", the given subscription is rejected.
	RunPreScorePlugins(context.Context, *CycleState, *appsapi.Subscription, []*clusterapi.ManagedCluster) *Status

	// RunScorePlugins runs the set of configured Score plugins. It returns a map that
	// stores for each Score plugin name the corresponding ClusterScoreList(s).
	// It also returns *Status, which is set to non-success if any of the plugins returns
	// a non-success status.
	RunScorePlugins(context.Context, *CycleState, *appsapi.Subscription, []*clusterapi.ManagedCluster) (PluginToClusterScores, *Status)

	// RunFilterPlugins runs the set of configured Filter plugins for subscription on
	// the given cluster.
	RunFilterPlugins(context.Context, *CycleState, *appsapi.Subscription, *clusterapi.ManagedCluster) PluginToStatus
}

PluginsRunner abstracts operations to run some plugins. This is used by preemption PostFilter plugins when evaluating the feasibility of scheduling the subscription on clusters when certain running subscriptions get evicted.

type PostBindPlugin

type PostBindPlugin interface {
	Plugin

	// PostBind is called after a subscription is successfully bound. These plugins are
	// informational. A common application of this extension point is for cleaning
	// up. If a plugin needs to clean-up its state after a subscription is scheduled and
	// bound, PostBind is the extension point that it should register.
	PostBind(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters)
}

PostBindPlugin is an interface that must be implemented by "PostBind" plugins. These plugins are called after a subscription is successfully bound to a group of ManagedCluster.

type PostFilterPlugin

type PostFilterPlugin interface {
	Plugin

	// PostFilter is called by the scheduling framework.
	// A PostFilter plugin should return one of the following statuses:
	// - Unschedulable: the plugin gets executed successfully but the subscription cannot be made schedulable.
	// - Success: the plugin gets executed successfully and the subscription can be made schedulable.
	// - Error: the plugin aborts due to some internal error.
	//
	// Informational plugins should be configured ahead of other ones, and always return Unschedulable status.
	// Optionally, a non-nil PostFilterResult may be returned along with a Success status. For example,
	// a preemption plugin may choose to return nominatedClusterName, so that framework can reuse that to update the
	// preemptor subscription's .spec.status.nominatedClusterName field.
	PostFilter(ctx context.Context, state *CycleState, sub *appsapi.Subscription, filteredClusterStatusMap ClusterToStatusMap) (*PostFilterResult, *Status)
}

PostFilterPlugin is an interface for "PostFilter" plugins. These plugins are called after a subscription cannot be scheduled.

type PostFilterResult

type PostFilterResult struct {
	NominatedtargetClusters TargetClusters
}

PostFilterResult wraps needed info for scheduler framework to act upon PostFilter phase.

type PreAssignPlugin added in v0.10.0

type PreAssignPlugin interface {
	Plugin

	// PreAssign is called by the scheduling framework after a list of managed clusters
	// passed the filtering phase. All pre-predict plugins must return success or
	// the subscription will be rejected.
	PreAssign(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, availableReplicas TargetClusters) *Status
}

PreAssignPlugin is an interface for "PreAssign" plugin. PreAssign is an informational extension point. These are meant to prepare the state of the assign.

type PreBindPlugin

type PreBindPlugin interface {
	Plugin

	// PreBind is called before binding a subscription. All prebind plugins must return
	// success or the subscription will be rejected and won't be sent for binding.
	PreBind(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status
}

PreBindPlugin is an interface that must be implemented by "PreBind" plugins. These plugins are called before a subscription being scheduled.

type PreFilterPlugin

type PreFilterPlugin interface {
	Plugin

	// PreFilter is called at the beginning of the scheduling cycle. All PreFilter
	// plugins must return success or the subscription will be rejected.
	PreFilter(ctx context.Context, state *CycleState, sub *appsapi.Subscription) *Status
}

PreFilterPlugin is an interface that must be implemented by "PreFilter" plugins. These plugins are called at the beginning of the scheduling cycle.

type PrePredictPlugin added in v0.10.0

type PrePredictPlugin interface {
	Plugin

	// PrePredict is called by the scheduling framework after a list of managed clusters
	// passed the filtering phase. All pre-predict plugins must return success or
	// the subscription will be rejected.
	PrePredict(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, clusters []*clusterapi.ManagedCluster) *Status
}

PrePredictPlugin is an interface for "PrePredict" plugin. PrePredict is an informational extension point. Plugins will be called with a list of clusters that passed the filtering phase.

type PreScorePlugin

type PreScorePlugin interface {
	Plugin

	// PreScore is called by the scheduling framework after a list of managed clusters
	// passed the filtering phase. All prescore plugins must return success or
	// the subscription will be rejected
	PreScore(ctx context.Context, state *CycleState, sub *appsapi.Subscription, clusters []*clusterapi.ManagedCluster) *Status
}

PreScorePlugin is an interface for "PreScore" plugin. PreScore is an informational extension point. Plugins will be called with a list of clusters that passed the filtering phase. A plugin may use this data to update internal state or to generate logs/metrics.

type PredictPlugin added in v0.10.0

type PredictPlugin interface {
	Plugin

	// Predict is called on each filtered cluster. It must return success and available
	// replicas indicating the feasible domain for sake of division. All predict plugins
	// must return success or the subscription will be rejected.
	Predict(ctx context.Context, state *CycleState, sub *appsapi.Subscription, finv *appsapi.FeedInventory, cluster *clusterapi.ManagedCluster) (FeedReplicas, *Status)
}

PredictPlugin is an interface that must be implemented by "Predict" plugins to predict max available replicas for clusters that passed the filtering phase.

type ReservePlugin

type ReservePlugin interface {
	Plugin

	// Reserve is called by the scheduling framework when the scheduler cache is
	// updated. If this method returns a failed Status, the scheduler will call
	// the Unreserve method for all enabled ReservePlugins.
	Reserve(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters) *Status
	// Unreserve is called by the scheduling framework when a reserved subscription was
	// rejected, an error occurred during reservation of subsequent plugins, or
	// in a later phase. The Unreserve method implementation must be idempotent
	// and may be called by the scheduler even if the corresponding Reserve
	// method for the same plugin was not called.
	Unreserve(ctx context.Context, state *CycleState, sub *appsapi.Subscription, targetClusters TargetClusters)
}

ReservePlugin is an interface for plugins with Reserve and Unreserve methods. These are meant to update the state of the plugin. This concept used to be called 'assume' in the original scheduler. These plugins should return only Success or Error in Status.code. However, the scheduler accepts other valid codes as well. Anything other than Success will lead to rejection of the subscription.

type ScoreExtensions

type ScoreExtensions interface {
	// NormalizeScore is called for all cluster scores produced by the same plugin's "Score"
	// method. A successful run of NormalizeScore will update the scores list and return
	// a success status.
	NormalizeScore(ctx context.Context, state *CycleState, sub *appsapi.Subscription, scores ClusterScoreList) *Status
}

ScoreExtensions is an interface for Score extended functionality.

type ScorePlugin

type ScorePlugin interface {
	Plugin

	// Score is called on each filtered cluster. It must return success and an integer
	// indicating the rank of the cluster. All scoring plugins must return success or
	// the subscription will be rejected.
	Score(ctx context.Context, state *CycleState, sub *appsapi.Subscription, namespacedCluster string) (int64, *Status)

	// ScoreExtensions returns a ScoreExtensions interface if it implements one, or nil if not.
	ScoreExtensions() ScoreExtensions
}

ScorePlugin is an interface that must be implemented by "Score" plugins to rank clusters that passed the filtering phase.

type StateData added in v0.11.0

type StateData interface {
	// Clone is an interface to make a copy of StateData. For performance reasons,
	// clone should make shallow copies for members (e.g., slices or maps) that are not
	// impacted by PreFilter's optional AddPod/RemovePod methods.
	Clone() StateData
}

StateData is a generic type for arbitrary data stored in CycleState.

type StateKey added in v0.11.0

type StateKey string

StateKey is the type of keys stored in CycleState.

type Status

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

Status indicates the result of running a plugin. It consists of a code, a message, (optionally) an error and an plugin name it fails by. When the status code is not `Success`, the reasons should explain why. NOTE: A nil Status is also considered as Success. Copied from k8s.io/kubernetes/pkg/scheduler/framework/interface.go and modified

func AsStatus

func AsStatus(err error) *Status

AsStatus wraps an error in a Status.

func NewStatus

func NewStatus(code Code, reasons ...string) *Status

NewStatus makes a Status out of the given arguments and returns its pointer.

func (*Status) AppendReason

func (s *Status) AppendReason(reason string)

AppendReason appends given reason to the Status.

func (*Status) AsError

func (s *Status) AsError() error

AsError returns nil if the status is a success; otherwise returns an "error" object with a concatenated message on reasons of the Status.

func (*Status) Code

func (s *Status) Code() Code

Code returns code of the Status.

func (*Status) Equal

func (s *Status) Equal(x *Status) bool

Equal checks equality of two statuses. This is useful for testing with cmp.Equal.

func (*Status) FailedPlugin

func (s *Status) FailedPlugin() string

FailedPlugin returns the failed plugin name.

func (*Status) IsSuccess

func (s *Status) IsSuccess() bool

IsSuccess returns true if and only if "Status" is nil or Code is "Success".

func (*Status) IsUnschedulable

func (s *Status) IsUnschedulable() bool

IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).

func (*Status) Message

func (s *Status) Message() string

Message returns a concatenated message on reasons of the Status.

func (*Status) Reasons

func (s *Status) Reasons() []string

Reasons returns reasons of the Status.

func (*Status) SetFailedPlugin

func (s *Status) SetFailedPlugin(plugin string)

SetFailedPlugin sets the given plugin name to s.failedPlugin.

func (*Status) WithFailedPlugin

func (s *Status) WithFailedPlugin(plugin string) *Status

WithFailedPlugin sets the given plugin name to s.failedPlugin, and returns the given status object.

type TargetClusters added in v0.9.0

type TargetClusters struct {
	// Namespaced names of targeted clusters that Subscription binds to.
	BindingClusters []string

	// Desired replicas of targeted clusters for each feed.
	Replicas map[string][]int32
}

TargetClusters represents the scheduling result.

func NewTargetClusters added in v0.11.0

func NewTargetClusters(bindingClusters []string, replicas map[string][]int32) *TargetClusters

func (*TargetClusters) DeepCopy added in v0.11.0

func (t *TargetClusters) DeepCopy() *TargetClusters

func (TargetClusters) Len added in v0.9.0

func (t TargetClusters) Len() int

func (TargetClusters) Less added in v0.9.0

func (t TargetClusters) Less(i, j int) bool

func (*TargetClusters) MergeOneFeed added in v0.15.0

func (t *TargetClusters) MergeOneFeed(b *TargetClusters)

If b.Replicas have feed more then one , use this method, it works good https://github.com/clusternet/clusternet/blob/v0.14.0/pkg/scheduler/framework/interfaces/types.go#L100 MergeOneFeed use for merge two TargetClusters when b.Replicas only one feed

func (TargetClusters) Swap added in v0.9.0

func (t TargetClusters) Swap(i, j int)

type WaitingSubscription

type WaitingSubscription interface {
	// GetSubscription returns a reference to the waiting subscription.
	GetSubscription() *appsapi.Subscription

	// GetPendingPlugins returns a list of pending Permit plugin's name.
	GetPendingPlugins() []string

	// Allow declares the waiting subscription is allowed to be scheduled by the plugin named as "pluginName".
	// If this is the last remaining plugin to allow, then a success signal is delivered
	// to unblock the subscription.
	Allow(pluginName string)

	// Reject declares the waiting subscription Unschedulable.
	Reject(pluginName, msg string)
}

WaitingSubscription represents a subscription currently waiting in the permit phase.

Jump to

Keyboard shortcuts

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