mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(scheduler): cpu arch match
This commit is contained in:
@@ -54,13 +54,25 @@ func (f *CPUPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.Pr
|
||||
|
||||
useRsvd := h.UseReserved()
|
||||
getter := c.Getter()
|
||||
|
||||
archMatch := true
|
||||
isArmHost := getter.IsArmHost()
|
||||
if apis.IsARM(d.OsArch) {
|
||||
host := getter.Host()
|
||||
if !host.IsArmHost() {
|
||||
h.Exclude(predicates.ErrHostCpuArchitectureNotMatch)
|
||||
return h.GetResult()
|
||||
// process arm64 host
|
||||
if !isArmHost {
|
||||
archMatch = false
|
||||
}
|
||||
} else {
|
||||
// process x86_64 host
|
||||
if isArmHost {
|
||||
archMatch = false
|
||||
}
|
||||
}
|
||||
if !archMatch {
|
||||
h.Exclude2(predicates.ErrHostCpuArchitectureNotMatch, getter.CPUArch(), d.OsArch)
|
||||
return h.GetResult()
|
||||
}
|
||||
|
||||
freeCPUCount := getter.FreeCPUCount(useRsvd)
|
||||
reqCPUCount := int64(d.Ncpu)
|
||||
if freeCPUCount < reqCPUCount {
|
||||
|
||||
+8
@@ -82,6 +82,14 @@ func (b baseHostGetter) Host() *computemodels.SHost {
|
||||
return b.h.SHost
|
||||
}
|
||||
|
||||
func (b baseHostGetter) IsArmHost() bool {
|
||||
return b.h.IsArmHost()
|
||||
}
|
||||
|
||||
func (b baseHostGetter) CPUArch() string {
|
||||
return b.h.CpuArchitecture
|
||||
}
|
||||
|
||||
func (b baseHostGetter) Cloudprovider() *computemodels.SCloudprovider {
|
||||
return b.h.Cloudprovider
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ type CandidatePropertyGetter interface {
|
||||
ProjectGuests() map[string]int64
|
||||
CreatingGuestCount() int
|
||||
|
||||
CPUArch() string
|
||||
IsArmHost() bool
|
||||
RunningCPUCount() int64
|
||||
TotalCPUCount(useRsvd bool) int64
|
||||
FreeCPUCount(useRsvd bool) int64
|
||||
|
||||
@@ -285,6 +285,14 @@ func (m *MockCandidatePropertyGetter) Host() *models.SHost {
|
||||
return ret0
|
||||
}
|
||||
|
||||
func (m *MockCandidatePropertyGetter) IsArmHost() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *MockCandidatePropertyGetter) CPUArch() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Host indicates an expected call of Host
|
||||
func (mr *MockCandidatePropertyGetterMockRecorder) Host() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
|
||||
Reference in New Issue
Block a user