Skip to content

Commit

Permalink
chore: cluster connect to replica whose pod role label is set as prim…
Browse files Browse the repository at this point in the history
…ary (#65)
  • Loading branch information
xuriwuyun authored Nov 22, 2023
1 parent 756333e commit e4302b6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/cluster/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,17 @@ func getInstanceInfoByList(dynamic dynamic.Interface, name, componentName, names
}

for _, o := range objs.Items {
infos = append(infos, &InstanceInfo{Name: o.GetName()})
info := &InstanceInfo{Name: o.GetName()}
podLabels := o.GetLabels()
role, ok := podLabels[constant.RoleLabelKey]
if ok {
info.Role = role
}
if role == constant.Primary || role == constant.Leader {
infos = append([]*InstanceInfo{info}, infos...)
} else {
infos = append(infos, info)
}
}
return infos
}
Expand Down

0 comments on commit e4302b6

Please sign in to comment.