Skip to content

Commit c0562f2

Browse files
authored
fix(region,host): host nic add default secret ipv4 address (#23014)
1 parent 66901a4 commit c0562f2

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

pkg/compute/models/hosts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type SHost struct {
116116
AccessMac string `width:"32" charset:"ascii" nullable:"true" index:"true" list:"domain" update:"domain"`
117117

118118
// 管理口Ip地址
119-
AccessIp string `width:"16" charset:"ascii" nullable:"true" list:"domain" update:"domain"`
119+
AccessIp string `width:"64" charset:"ascii" nullable:"true" list:"domain" update:"domain"`
120120

121121
// 管理地址
122122
ManagerUri string `width:"256" charset:"ascii" nullable:"true" list:"domain" update:"domain" create:"domain_optional"`

pkg/hostman/hostinfo/hostbridge/hostbridge.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,14 @@ func (d *SBaseBridgeDriver) SetupAddresses() error {
429429
addr string
430430
masklen int
431431
)
432-
if len(d.ip) == 0 && len(d.ip6) == 0 {
432+
if len(d.ip) == 0 {
433433
addr, masklen = netutils2.GetSecretInterfaceAddress()
434434
} else {
435435
addr = d.ip
436436
masklen = d.maskLen
437437
}
438438
addrStr := []string{}
439-
if len(d.ip) > 0 {
440-
addrStr = append(addrStr, fmt.Sprintf("%s/%d", addr, masklen))
441-
}
439+
addrStr = append(addrStr, fmt.Sprintf("%s/%d", addr, masklen))
442440
if len(d.ip6) > 0 {
443441
addrStr = append(addrStr, fmt.Sprintf("%s/%d", d.ip6, d.mask6Len))
444442
}

pkg/util/netutils2/netutils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ func (n *SNetInterface) FetchConfig2(expectIp string, expectIp6 string) {
520520
for _, addr := range addrs {
521521
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
522522
if ipnet.IP.To4() != nil {
523+
if len(expectIp) == 0 && n.Addr == "" && strings.HasPrefix(ipnet.IP.To4().String(), SECRET_PREFIX) {
524+
continue
525+
}
523526
if (len(expectIp) > 0 && ipnet.IP.String() == expectIp) || (len(expectIp) == 0 && n.Addr == "") {
524527
n.Addr = ipnet.IP.String()
525528
n.Mask = ipnet.Mask

0 commit comments

Comments
 (0)