Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Convert affinity group to pod group
Browse files Browse the repository at this point in the history
Convert AlgoAffinityGroup to PodGroupSchedulingStatus before intra VC
scheduler.
  • Loading branch information
abuccts committed Mar 4, 2021
1 parent 76fd537 commit e56fe3b
Show file tree
Hide file tree
Showing 7 changed files with 530 additions and 203 deletions.
17 changes: 15 additions & 2 deletions pkg/algorithm/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
package algorithm

import (
"github.com/microsoft/hivedscheduler/pkg/api"
"math"

"github.com/microsoft/hivedscheduler/pkg/api"
)

const (
Expand Down Expand Up @@ -57,7 +58,19 @@ const (
// will respect the group that reserved the cell, i.e., a group with a non-higher priority cannot get this cell.
cellReserved CellState = "Reserved"

// internal affinity group states
// internal pod group states

// The pod group has been allocated cells.
// All cells in the group must be in Used state.
podGroupAllocated PodGroupState = "Allocated"
// The pod group is preempting other groups to get free resource.
// Cells in the group must be in either Reserving or Reserved states.
podGroupPreempting PodGroupState = "Preempting"
// The pod group is being preempted by some other groups.
// Cells in the group must be in either Used or Reserving states.
podGroupBeingPreempted PodGroupState = "BeingPreempted"

// TODO: to remove

// The affinity group has been allocated cells.
// All cells in the group must be in Used state.
Expand Down
337 changes: 171 additions & 166 deletions pkg/algorithm/hived_algorithm.go

Large diffs are not rendered by default.

59 changes: 30 additions & 29 deletions pkg/algorithm/intra_vc_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ import (

// intraVCScheduler is an interface for scheduling pods inside a VC.
// It stores two maps of ChainCellList, one for pinned cells, the other for non-pinned ones.
// It should be able to return a set of leaf cell placements in the VC for a scheduling request.
// It should be able to return a set of cell placements in the VC for a scheduling request.
type intraVCScheduler interface {
getNonPinnedFullCellList() map[CellChain]ChainCellList
getNonPinnedPreassignedCells() map[CellChain]ChainCellList
getPinnedCells() map[api.PinnedCellId]ChainCellList

// Schedule an affinity group inside a VC. We use topologyAwareScheduler by default.
schedule(schedulingRequest) (groupVirtualPlacement, string)
// Schedule a pod group inside a VC. We use skuScheduler.
schedule(PodGroupSchedulingRequest) (groupVirtualPlacement, string)
}

type defaultIntraVCScheduler struct {
nonPinnedFullCellList map[CellChain]ChainCellList
nonPinnedPreassignedCells map[CellChain]ChainCellList
pinnedCells map[api.PinnedCellId]ChainCellList
// Currently we create a topologyAwareScheduler for each cluster view (each chain, each pinned cell).
// Currently we create a skuScheduler for each cluster view (each chain, each pinned cell).
// We plan to support multiple cluster views in one scheduler, and to support schedule pods
// across different cluster views.
// TODO: Support an affinity group can relax to be allocated across multiple chains.
nonPinnedCellSchedulers map[CellChain]*topologyAwareScheduler
pinnedCellSchedulers map[api.PinnedCellId]*topologyAwareScheduler
// TODO: Support a pod group can relax to be allocated across multiple chains.
nonPinnedCellSchedulers map[CellChain]*skuScheduler
pinnedCellSchedulers map[api.PinnedCellId]*skuScheduler
}

func newDefaultIntraVCScheduler(
Expand All @@ -60,13 +60,13 @@ func newDefaultIntraVCScheduler(
pinnedList map[api.PinnedCellId]ChainCellList,
leafCellNums map[CellChain]map[CellLevel]int32) *defaultIntraVCScheduler {

snr := map[CellChain]*topologyAwareScheduler{}
sr := map[api.PinnedCellId]*topologyAwareScheduler{}
snr := map[CellChain]*skuScheduler{}
sr := map[api.PinnedCellId]*skuScheduler{}
for chain, ccl := range nonPinnedFullList {
snr[chain] = NewTopologyAwareScheduler(ccl, leafCellNums[chain], true)
snr[chain] = NewSkuScheduler(ccl, leafCellNums[chain], true)
}
for pid, ccl := range pinnedList {
sr[pid] = NewTopologyAwareScheduler(ccl, leafCellNums[ccl[CellLevel(1)][0].GetChain()], true)
sr[pid] = NewSkuScheduler(ccl, leafCellNums[ccl[CellLevel(1)][0].GetChain()], true)
}
return &defaultIntraVCScheduler{
nonPinnedFullCellList: nonPinnedFullList,
Expand All @@ -90,28 +90,29 @@ func (s *defaultIntraVCScheduler) getPinnedCells() map[api.PinnedCellId]ChainCel
}

func (s *defaultIntraVCScheduler) schedule(
sr schedulingRequest) (
placement groupVirtualPlacement,
podGroupSchedRequest PodGroupSchedulingRequest) (
oldPlacement groupVirtualPlacement,
failedReason string) {

scheduler := s.nonPinnedCellSchedulers[sr.chain]
str := fmt.Sprintf("chain %v", sr.chain)
if sr.pinnedCellId != "" {
scheduler = s.pinnedCellSchedulers[sr.pinnedCellId]
str = fmt.Sprintf("pinned cell %v", sr.pinnedCellId)
var placement podGroupPlacement

scheduler := s.nonPinnedCellSchedulers[podGroupSchedRequest.chain]
str := fmt.Sprintf("chain %v", podGroupSchedRequest.chain)
if podGroupSchedRequest.pinnedCellId != "" {
scheduler = s.pinnedCellSchedulers[podGroupSchedRequest.pinnedCellId]
str = fmt.Sprintf("pinned cell %v", podGroupSchedRequest.pinnedCellId)
}
klog.Infof("Processing scheduling request in VC %v: %v, leaf cell numbers %v, priority %v",
sr.vc, str, common.ToJson(sr.affinityGroupPodNums), sr.priority)
klog.Infof("Processing scheduling request in VC %v: %v, pod group %v, priority %v",
podGroupSchedRequest.vc, str, common.ToJson(podGroupSchedRequest.podRootGroup), podGroupSchedRequest.priority)
if scheduler != nil {
placement, failedReason = scheduler.Schedule(
sr.affinityGroupPodNums,
sr.priority,
sr.suggestedNodes,
sr.ignoreSuggestedNodes)
placement, failedReason = scheduler.SkuSchedule(
&podGroupSchedRequest.podRootGroup,
podGroupSchedRequest.priority,
)
}
if placement == nil {
return nil, fmt.Sprintf("%v when scheduling in VC %v", failedReason, sr.vc)
if placement.IsEmpty() {
return nil, fmt.Sprintf("%v when scheduling in VC %v", failedReason, podGroupSchedRequest.vc)
}
klog.Infof("Found placement in VC %v: %v", sr.vc, placement)
return placement, ""
klog.Infof("Found placement in VC %v: %v", podGroupSchedRequest.vc, placement)
return groupVirtualPlacement{}, ""
}
Loading

0 comments on commit e56fe3b

Please sign in to comment.