Skip to content

Commit 3c5bdfe

Browse files
committed
Adding maxAvailableComponentSets to estimator interface
Signed-off-by: mszacillo <[email protected]>
1 parent f9cd5c9 commit 3c5bdfe

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

pkg/estimator/client/accurate.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ func (se *SchedulerEstimator) MaxAvailableReplicas(
6767
})
6868
}
6969

70+
// MaxAvailableComponentSets returns the maximum number of complete multi-component sets (in terms of replicas) that each cluster can host.
71+
func (se *SchedulerEstimator) MaxAvailableComponentSets(
72+
_ context.Context,
73+
_ *ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error) {
74+
// Dummy implementation: return nothing for now
75+
// TODO: Implement as part of #6734
76+
return nil, nil
77+
}
78+
7079
// GetUnschedulableReplicas gets the unschedulable replicas which belong to a specified workload by calling karmada-scheduler-estimator.
7180
func (se *SchedulerEstimator) GetUnschedulableReplicas(
7281
parentCtx context.Context,

pkg/estimator/client/general.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ func (ge *GeneralEstimator) MaxAvailableReplicas(_ context.Context, clusters []*
5353
return availableTargetClusters, nil
5454
}
5555

56+
// MaxAvailableComponentSets returns the maximum number of complete multi-component sets (in terms of replicas) that each cluster can host.
57+
func (ge *GeneralEstimator) MaxAvailableComponentSets(
58+
_ context.Context,
59+
_ *ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error) {
60+
// Dummy implementation: return nothing for now
61+
// TODO: Implement as part of #6734
62+
return nil, nil
63+
}
64+
5665
func (ge *GeneralEstimator) maxAvailableReplicas(cluster *clusterv1alpha1.Cluster, replicaRequirements *workv1alpha2.ReplicaRequirements) int32 {
5766
//Note: resourceSummary must be deep-copied before using in the function to avoid modifying the original data structure.
5867
resourceSummary := cluster.Status.ResourceSummary.DeepCopy()

pkg/estimator/client/interface.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,34 @@ var (
3434
unschedulableReplicaEstimators = map[string]UnschedulableReplicaEstimator{}
3535
)
3636

37-
// ReplicaEstimator is an estimator which estimates the maximum replicas that can be applied to the target cluster.
37+
// ReplicaEstimator estimates how many replicas a workload can run on each target cluster,
38+
// based on resource availability and node constraints.
3839
type ReplicaEstimator interface {
40+
// MaxAvailableReplicas returns the maximum number of replicas of a single-component workload that each cluster can host.
3941
MaxAvailableReplicas(ctx context.Context, clusters []*clusterv1alpha1.Cluster, replicaRequirements *workv1alpha2.ReplicaRequirements) ([]workv1alpha2.TargetCluster, error)
42+
// MaxAvailableComponentSets returns the maximum number of complete multi-component sets (in terms of replicas) that each cluster can host.
43+
MaxAvailableComponentSets(ctx context.Context, req *ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error)
44+
}
45+
46+
// ComponentSetEstimationRequest carries input parameters for estimating multi-component set availability per cluster.
47+
// Fields can be extended over time without changing the method signature.
48+
type ComponentSetEstimationRequest struct {
49+
// Clusters represents a list of feasible clusters to estimate against.
50+
Clusters []*clusterv1alpha1.Cluster
51+
// Components are the components that form a multi-component workload.
52+
Components []*workv1alpha2.Component
53+
// Namespace is the namespace of the workload being estimated.
54+
// It is used by the accurate estimator to check the quota configurations
55+
// in the target member cluster. This field is required for quota-aware estimation.
56+
Namespace string
57+
}
58+
59+
// ComponentSetEstimationResponse represents how many complete component sets a cluster can accommodate.
60+
type ComponentSetEstimationResponse struct {
61+
// Name is the cluster name.
62+
Name string
63+
// Sets is the maximum number of complete component sets that can be scheduled on the cluster.
64+
Sets int32
4065
}
4166

4267
// UnschedulableReplicaEstimator is an estimator which estimates the unschedulable replicas which belong to a specified workload.

0 commit comments

Comments
 (0)