Skip to content

Commit ce66819

Browse files
authored
Merge pull request #6859 from RainbowMango/pr_amend_component_scheduling_interface_type
Update ReplicaEstimator interface signature, remove unncessary pointer type
2 parents aac8d1a + a61df36 commit ce66819

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
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/general_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ func TestGetMaxAvailableComponentSetsGeneral(t *testing.T) {
805805
tests := []struct {
806806
name string
807807
cluster *clusterv1alpha1.Cluster
808-
components []*workv1alpha2.Component
808+
components []workv1alpha2.Component
809809
expected int32
810810
}{
811811
{
@@ -862,7 +862,7 @@ func TestGetMaxAvailableComponentSetsGeneral(t *testing.T) {
862862
},
863863
},
864864
},
865-
components: []*workv1alpha2.Component{
865+
components: []workv1alpha2.Component{
866866
{
867867
Name: "jobmanager",
868868
Replicas: 1,
@@ -902,7 +902,7 @@ func TestGetMaxAvailableComponentSetsGeneral(t *testing.T) {
902902
},
903903
},
904904
},
905-
components: []*workv1alpha2.Component{
905+
components: []workv1alpha2.Component{
906906
{
907907
Name: "jobmanager",
908908
Replicas: 1,
@@ -943,7 +943,7 @@ func TestGetMaxAvailableComponentSetsGeneral(t *testing.T) {
943943
},
944944
},
945945
},
946-
components: []*workv1alpha2.Component{
946+
components: []workv1alpha2.Component{
947947
{
948948
Name: "small-component",
949949
Replicas: 3,
@@ -977,7 +977,7 @@ func TestGetMaxAvailableComponentSetsGeneral(t *testing.T) {
977977
},
978978
},
979979
},
980-
components: []*workv1alpha2.Component{
980+
components: []workv1alpha2.Component{
981981
{
982982
Name: "gpu-worker",
983983
Replicas: 2,

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)