mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
Merge pull request #16161 from zexi/bm-update-status
fix(baremetal): not update hypervisor host's status
This commit is contained in:
@@ -92,6 +92,10 @@ func (job *SStatusProbeJob) Name() string {
|
||||
}
|
||||
|
||||
func (job *SStatusProbeJob) Do(ctx context.Context, now time.Time) error {
|
||||
if job.baremetal.IsHypervisorHost() {
|
||||
log.Infof("baremetal %q is host, skipping status probe", job.baremetal.GetName())
|
||||
return nil
|
||||
}
|
||||
bStatus := job.baremetal.GetStatus()
|
||||
if bStatus == api.BAREMETAL_READY || bStatus == api.BAREMETAL_RUNNING || bStatus == api.BAREMETAL_UNKNOWN {
|
||||
ps, err := job.baremetal.GetPowerStatus()
|
||||
|
||||
@@ -173,7 +173,9 @@ func (m *SBaremetalManager) InitBaremetal(bmId string, update bool) error {
|
||||
if update {
|
||||
bmObj := bmInstance.(*SBaremetalInstance)
|
||||
if !sets.NewString(INIT, PREPARE, UNKNOWN).Has(bmObj.GetStatus()) {
|
||||
bmObj.SyncStatusBackground()
|
||||
if !bmObj.IsHypervisorHost() {
|
||||
bmObj.SyncStatusBackground()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -532,10 +534,7 @@ func newBaremetalInstance(man *SBaremetalManager, desc jsonutils.JSONObject) (*S
|
||||
bm.cronJobs = []IBaremetalCronJob{
|
||||
NewLogFetchJob(bm, time.Duration(o.Options.LogFetchIntervalSeconds)*time.Second),
|
||||
NewSendMetricsJob(bm, time.Duration(o.Options.SendMetricsIntervalSeconds)*time.Second),
|
||||
}
|
||||
hostType, _ := bm.desc.GetString("host_type")
|
||||
if !utils.IsInStringArray(hostType, []string{api.HOST_TYPE_KVM, api.HOST_TYPE_HYPERVISOR}) {
|
||||
bm.cronJobs = append(bm.cronJobs, NewStatusProbeJob(bm, time.Duration(o.Options.StatusProbeIntervalSeconds)*time.Second))
|
||||
NewStatusProbeJob(bm, time.Duration(o.Options.StatusProbeIntervalSeconds)*time.Second),
|
||||
}
|
||||
err := os.MkdirAll(bm.GetDir(), 0755)
|
||||
if err != nil {
|
||||
@@ -549,6 +548,11 @@ func newBaremetalInstance(man *SBaremetalManager, desc jsonutils.JSONObject) (*S
|
||||
return bm, nil
|
||||
}
|
||||
|
||||
func (b *SBaremetalInstance) IsHypervisorHost() bool {
|
||||
hostType, _ := b.desc.GetString("host_type")
|
||||
return utils.IsInStringArray(hostType, []string{api.HOST_TYPE_KVM, api.HOST_TYPE_HYPERVISOR})
|
||||
}
|
||||
|
||||
func (b *SBaremetalInstance) GetDHCPServerIP() (net.IP, error) {
|
||||
return b.manager.Agent.GetDHCPServerIP()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user