Skip to content

Commit

Permalink
Adopt zones in scheduler spread by constraints
Browse files Browse the repository at this point in the history
Signed-off-by: Tanggui Bian <softwarebtg@163.com>
  • Loading branch information
zishen committed Aug 25, 2023
1 parent fb4c16d commit 6ac7049
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions pkg/scheduler/core/spreadconstraint/group_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,29 @@ func (info *GroupClustersInfo) generateZoneInfo(spreadConstraints []policyv1alph
}

for _, clusterInfo := range info.Clusters {
zone := clusterInfo.Cluster.Spec.Zone
if zone == "" {
zones := clusterInfo.Cluster.Spec.Zones
if len(zones) == 0 {
continue
}

zoneInfo, ok := info.Zones[zone]
if !ok {
zoneInfo = ZoneInfo{
Name: zone,
Clusters: make([]ClusterDetailInfo, 0),
for _, zone := range zones {
zoneInfo, ok := info.Zones[zone]
if !ok {
zoneInfo = ZoneInfo{
Name: zone,
Clusters: make([]ClusterDetailInfo, 0),
}
}
zoneInfo.Clusters = append(zoneInfo.Clusters, clusterInfo)
zoneInfo.AvailableReplicas += clusterInfo.AvailableReplicas
info.Zones[zone] = zoneInfo
}

zoneInfo.Clusters = append(zoneInfo.Clusters, clusterInfo)
zoneInfo.AvailableReplicas += clusterInfo.AvailableReplicas
info.Zones[zone] = zoneInfo
}

for zone, zoneInfo := range info.Zones {
zoneInfo.Score = zoneInfo.Clusters[0].Score
for _, cluster := range zoneInfo.Clusters {
zoneInfo.Score += cluster.Score
}
info.Zones[zone] = zoneInfo
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewClusterWithTopology(name, provider, region, zone string) *clusterv1alpha
Spec: clusterv1alpha1.ClusterSpec{
Provider: provider,
Region: region,
Zone: zone,
Zones: []string{zone},
},
}
}
Expand Down

0 comments on commit 6ac7049

Please sign in to comment.