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

Commit

Permalink
Merge pull request #393 from justinsb/openstack_order_keys
Browse files Browse the repository at this point in the history
openstack: try to consistently return addresses from the first network
  • Loading branch information
k8s-ci-robot committed Apr 6, 2024
2 parents 065e93b + 734b7c4 commit 885e1ca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion etcd-manager/pkg/volumes/openstack/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package openstack
import (
"fmt"
"net"
"sort"
)

const (
Expand All @@ -28,7 +29,15 @@ const (
)

func GetServerFixedIP(addrs map[string]interface{}, name string, networkCIDR *net.IPNet) (poolAddress string, err error) {
for _, address := range addrs {
// Introduce some determinism, even though map ordering is random
var addressKeys []string
for addressKey := range addrs {
addressKeys = append(addressKeys, addressKey)
}
sort.Strings(addressKeys)

for _, addressKey := range addressKeys {
address := addrs[addressKey]
if addresses, ok := address.([]interface{}); ok {
for _, addr := range addresses {
addrMap := addr.(map[string]interface{})
Expand Down

0 comments on commit 885e1ca

Please sign in to comment.