Skip to content

Commit d958a57

Browse files
committed
Update ReplicaEstimator interface signature, remove unncessary pointer type
Signed-off-by: RainbowMango <[email protected]>
1 parent b0cb266 commit d958a57

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

pkg/estimator/client/accurate.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ func (se *SchedulerEstimator) MaxAvailableReplicas(
6868
}
6969

7070
// 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) {
71+
func (se *SchedulerEstimator) MaxAvailableComponentSets(_ context.Context, _ ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error) {
7472
// Dummy implementation: return nothing for now
7573
// TODO: Implement as part of #6734
7674
return nil, nil

pkg/estimator/client/general.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (ge *GeneralEstimator) maxAvailableReplicas(cluster *clusterv1alpha1.Cluste
9494
}
9595

9696
// MaxAvailableComponentSets (generic estimator) – resourceSummary only.
97-
func (ge *GeneralEstimator) MaxAvailableComponentSets(_ context.Context, req *ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error) {
97+
func (ge *GeneralEstimator) MaxAvailableComponentSets(_ context.Context, req ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error) {
9898
responses := make([]ComponentSetEstimationResponse, len(req.Clusters))
9999
for i, cluster := range req.Clusters {
100100
maxComponentSets := ge.maxAvailableComponentSets(cluster, req.Components)
@@ -103,7 +103,7 @@ func (ge *GeneralEstimator) MaxAvailableComponentSets(_ context.Context, req *Co
103103
return responses, nil
104104
}
105105

106-
func (ge *GeneralEstimator) maxAvailableComponentSets(cluster *clusterv1alpha1.Cluster, components []*workv1alpha2.Component) int32 {
106+
func (ge *GeneralEstimator) maxAvailableComponentSets(cluster *clusterv1alpha1.Cluster, components []workv1alpha2.Component) int32 {
107107
resourceSummary := cluster.Status.ResourceSummary.DeepCopy()
108108
if resourceSummary == nil {
109109
return 0
@@ -163,14 +163,14 @@ func (ge *GeneralEstimator) maxAvailableComponentSets(cluster *clusterv1alpha1.C
163163
// getMaximumSetsBasedOnResourceModels is a placeholder for future implementation.
164164
// It should refine the maximum sets based on cluster resource models, similar
165165
// to getMaximumReplicasBasedOnResourceModels but adapted to full component sets.
166-
func getMaximumSetsBasedOnResourceModels(_ *clusterv1alpha1.Cluster, _ []*workv1alpha2.Component) (int64, error) {
166+
func getMaximumSetsBasedOnResourceModels(_ *clusterv1alpha1.Cluster, _ []workv1alpha2.Component) (int64, error) {
167167
// TODO: implement logic based on cluster.Spec.ResourceModels
168168
// For now, just return MaxInt64 so it never reduces the upper bound.
169169
return math.MaxInt64, nil
170170
}
171171

172172
// podsInSet computes the total number of pods in the CRD
173-
func podsInSet(components []*workv1alpha2.Component) int64 {
173+
func podsInSet(components []workv1alpha2.Component) int64 {
174174
var sum int64
175175
for _, c := range components {
176176
sum += int64(c.Replicas)
@@ -179,7 +179,7 @@ func podsInSet(components []*workv1alpha2.Component) int64 {
179179
}
180180

181181
// perSetRequirement computes the aggregate resource(such as CPU, Memory, GPU, etc) demand of one set of components.
182-
func perSetRequirement(components []*workv1alpha2.Component) map[corev1.ResourceName]int64 {
182+
func perSetRequirement(components []workv1alpha2.Component) map[corev1.ResourceName]int64 {
183183
resourceRequirements := map[corev1.ResourceName]int64{}
184184
for _, c := range components {
185185
if c.ReplicaRequirements == nil || c.ReplicaRequirements.ResourceRequest == nil {

pkg/estimator/client/interface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ReplicaEstimator interface {
4040
// MaxAvailableReplicas returns the maximum number of replicas of a single-component workload that each cluster can host.
4141
MaxAvailableReplicas(ctx context.Context, clusters []*clusterv1alpha1.Cluster, replicaRequirements *workv1alpha2.ReplicaRequirements) ([]workv1alpha2.TargetCluster, error)
4242
// 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)
43+
MaxAvailableComponentSets(ctx context.Context, req ComponentSetEstimationRequest) ([]ComponentSetEstimationResponse, error)
4444
}
4545

4646
// ComponentSetEstimationRequest carries input parameters for estimating multi-component set availability per cluster.
@@ -49,7 +49,7 @@ type ComponentSetEstimationRequest struct {
4949
// Clusters represents a list of feasible clusters to estimate against.
5050
Clusters []*clusterv1alpha1.Cluster
5151
// Components are the components that form a multi-component workload.
52-
Components []*workv1alpha2.Component
52+
Components []workv1alpha2.Component
5353
// Namespace is the namespace of the workload being estimated.
5454
// It is used by the accurate estimator to check the quota configurations
5555
// in the target member cluster. This field is required for quota-aware estimation.

0 commit comments

Comments
 (0)