Merge pull request #16890 from zexi/automated-cherry-pick-of-#16888-upstream-master

Automated cherry pick of #16888: fix(scheduler): skip load esxi network free-port cache
This commit is contained in:
Zexi Li
2023-04-27 09:35:55 +08:00
committed by GitHub
+9 -2
View File
@@ -337,8 +337,15 @@ func newNetworkGetter() *networkGetter {
}
}
func shouldSkipLoadNetFromCache(host *computemodels.SHost) bool {
if host.IsEmulated || host.HostType == computeapi.HOST_TYPE_ESXI {
return true
}
return false
}
func (g *networkGetter) GetFreePort(host *computemodels.SHost, n *computemodels.SNetwork) (int, error) {
if host.IsEmulated {
if shouldSkipLoadNetFromCache(host) {
// not calculate emulated host's network free address
return -1, nil
}
@@ -453,7 +460,7 @@ func (b *BaseHostDesc) GetFreePort(netId string) int {
if selNet == nil {
return 0
}
if b.IsEmulated {
if shouldSkipLoadNetFromCache(b.SHost) {
freeCount, _ := selNet.GetFreeAddressCount()
return freeCount
}