Skip to content

Commit

Permalink
chore: remove GetAllocationSummary from RM interface (#8846)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaecalderon authored Feb 16, 2024
1 parent de28a57 commit a5f38cb
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 58 deletions.
14 changes: 0 additions & 14 deletions master/internal/rm/agentrm/agent_resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,6 @@ func (a *ResourceManager) GetAllocationSummaries(
return summaries, nil
}

// GetAllocationSummary implements rm.ResourceManager.
func (a *ResourceManager) GetAllocationSummary(
msg sproto.GetAllocationSummary,
) (*sproto.AllocationSummary, error) {
for _, pool := range a.pools {
summary, ok := pool.GetAllocationSummary(msg)
if !ok {
continue
}
return &summary, nil
}
return nil, errors.New("allocation not found")
}

// GetDefaultAuxResourcePool implements rm.ResourceManager.
func (a *ResourceManager) GetDefaultAuxResourcePool(
sproto.GetDefaultAuxResourcePoolRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ func TestAgentRMRoutingTaskRelatedMessages(t *testing.T) {
require.NoError(t, err)

// Check the resource pools of the tasks are correct.
taskSummary, err := agentRM.GetAllocationSummary(sproto.GetAllocationSummary{ID: cpuTask1.ID})
require.NoError(t, err)
assert.Equal(t, taskSummary.ResourcePool, cpuTask1.ResourcePool)

taskSummaries, err = agentRM.GetAllocationSummaries(sproto.GetAllocationSummaries{})
require.NoError(t, err)
assert.Equal(
Expand All @@ -122,10 +118,6 @@ func TestAgentRMRoutingTaskRelatedMessages(t *testing.T) {
require.NoError(t, err)

// Check the resource pools of the tasks are correct.
taskSummary, err = agentRM.GetAllocationSummary(sproto.GetAllocationSummary{ID: gpuTask1.ID})
require.NoError(t, err)
assert.Equal(t, taskSummary.ResourcePool, gpuTask1.ResourcePool)

taskSummaries, err = agentRM.GetAllocationSummaries(sproto.GetAllocationSummaries{})
require.NoError(t, err)
assert.Equal(
Expand Down
11 changes: 0 additions & 11 deletions master/internal/rm/agentrm/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,17 +559,6 @@ func (rp *resourcePool) NotifyAgentUpdated() {
rp.reschedule = true
}

func (rp *resourcePool) GetAllocationSummary(msg sproto.GetAllocationSummary) (sproto.AllocationSummary, bool) {
rp.mu.Lock()
defer rp.mu.Unlock()

resp := rp.taskList.TaskSummary(msg.ID, rp.groups, rp.config.Scheduler.GetType())
if resp == nil {
return sproto.AllocationSummary{}, false
}
return *resp, true
}

func (rp *resourcePool) GetAllocationSummaries(
msg sproto.GetAllocationSummaries,
) map[model.AllocationID]sproto.AllocationSummary {
Expand Down
11 changes: 0 additions & 11 deletions master/internal/rm/kubernetesrm/kubernetes_resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,6 @@ func (k *ResourceManager) GetAllocationSummaries(
return summaries, nil
}

// GetAllocationSummary implements rm.ResourceManager.
func (k *ResourceManager) GetAllocationSummary(msg sproto.GetAllocationSummary) (*sproto.AllocationSummary, error) {
for _, rp := range k.pools {
resp := rp.GetAllocationSummary(msg)
if resp != nil {
return resp, nil
}
}
return nil, fmt.Errorf("allocation not found: %s", msg.ID)
}

// GetDefaultAuxResourcePool implements rm.ResourceManager.
func (k *ResourceManager) GetDefaultAuxResourcePool(
sproto.GetDefaultAuxResourcePoolRequest,
Expand Down
11 changes: 0 additions & 11 deletions master/internal/rm/kubernetesrm/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,6 @@ func (k *kubernetesResourcePool) RecoverJobPosition(msg sproto.RecoverJobPositio
k.queuePositions.RecoverJobPosition(msg.JobID, msg.JobPosition)
}

func (k *kubernetesResourcePool) GetAllocationSummary(msg sproto.GetAllocationSummary) *sproto.AllocationSummary {
k.mu.Lock()
defer k.mu.Unlock()

if resp := k.reqList.TaskSummary(
msg.ID, k.groups, kubernetesScheduler); resp != nil {
return resp
}
return nil
}

func (k *kubernetesResourcePool) GetAllocationSummaries(
msg sproto.GetAllocationSummaries,
) map[model.AllocationID]sproto.AllocationSummary {
Expand Down
1 change: 0 additions & 1 deletion master/internal/rm/resource_manager_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
// ResourceManager is an interface for a resource manager, which can allocate and manage resources.
type ResourceManager interface {
// Basic functionality
GetAllocationSummary(sproto.GetAllocationSummary) (*sproto.AllocationSummary, error)
GetAllocationSummaries(sproto.GetAllocationSummaries) (map[model.AllocationID]sproto.AllocationSummary, error)
Allocate(sproto.AllocateRequest) (*sproto.ResourcesSubscription, error)
Release(sproto.ResourcesReleased)
Expand Down
2 changes: 0 additions & 2 deletions master/internal/sproto/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ type (
ResourcesID *ResourcesID
ResourcePool string
}
// GetAllocationSummary returns the summary of the specified task.
GetAllocationSummary struct{ ID model.AllocationID }
// GetAllocationSummaries returns the summaries of all the tasks in the cluster.
GetAllocationSummaries struct{}
// AllocationSummary contains information about a task for external display.
Expand Down

0 comments on commit a5f38cb

Please sign in to comment.