Skip to content

Commit

Permalink
fix: get the highest priority role failed (#552)
Browse files Browse the repository at this point in the history
(cherry picked from commit 56a74e9)
  • Loading branch information
wangyelei committed Feb 7, 2025
1 parent 5c974d2 commit b8ad543
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/cmd/cluster/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,21 @@ func (o *OperationsOptions) validatePromote(clusterObj *appsv1.Cluster) error {
}
// HACK: assume the role with highest priority to be writable
highestPriority := math.MinInt
var role *appsv1.ReplicaRole
for _, r := range compDefObj.Spec.Roles {
if r.UpdatePriority > highestPriority {
highestPriority = r.UpdatePriority
role = &r
var highestPriorityRole appsv1.ReplicaRole
for i := range compDefObj.Spec.Roles {
role := compDefObj.Spec.Roles[i]
if role.UpdatePriority > highestPriority {
highestPriority = role.UpdatePriority
highestPriorityRole = role
}
}
for _, pod := range pods.Items {
if pod.Labels[constant.RoleLabelKey] == role.Name {
if pod.Labels[constant.RoleLabelKey] == highestPriorityRole.Name {
o.Instance = pod.Name
break
}
}
return role.Name, nil
return highestPriorityRole.Name, nil
}

// check componentDefinition exist
Expand Down

0 comments on commit b8ad543

Please sign in to comment.