Skip to content

Commit

Permalink
add description for nodes in the cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
gujingit committed Oct 23, 2019
1 parent a222809 commit 6bd487e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cloud-controller-manager/vgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ func (v *vgroup) diff(apis, nodes []slb.VBackendServerType) (
for _, node := range nodes {
for _, api := range apis {
if node.ServerId == api.ServerId &&
node.Weight != api.Weight {
node.ServerIp == api.ServerIp &&
(node.Weight != api.Weight ||
api.Description != v.NamedKey.Key()) {
updates = append(updates, node)
break
}
Expand All @@ -267,7 +269,6 @@ func Ensure(v *vgroup, nodes interface{}) error {
}
if _, ok := node.Labels["weight"]; !ok {
nodeWeight = 100
glog.Infof("Warning: cannot get node %s weight. So set the node weight to 100.", node.Name)
} else {
nodeWeight, err = strconv.Atoi(node.Labels["weight"])
if err != nil {
Expand All @@ -279,10 +280,11 @@ func Ensure(v *vgroup, nodes interface{}) error {
}
}
backend = append(backend, slb.VBackendServerType{
ServerId: string(id),
Weight: nodeWeight,
Port: int(v.NamedKey.Port),
Type: "ecs",
ServerId: string(id),
Weight: nodeWeight,
Port: int(v.NamedKey.Port),
Type: "ecs",
Description: v.NamedKey.Key(),
})
}
case *v1.Endpoints:
Expand Down Expand Up @@ -312,11 +314,12 @@ func Ensure(v *vgroup, nodes interface{}) error {
backend = append(
backend,
slb.VBackendServerType{
ServerId: eniid,
Weight: 100,
Type: "eni",
Port: int(v.NamedKey.Port),
ServerIp: addrIP,
ServerId: eniid,
Weight: 100,
Type: "eni",
Port: int(v.NamedKey.Port),
ServerIp: addrIP,
Description: v.NamedKey.Key(),
},
)
}
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/denverdino/aliyungo/slb/vserver_group.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6bd487e

Please sign in to comment.