From 3d1507b0e40c31e19b091ecf2bc1ff0a088c0e03 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Wed, 20 Sep 2023 22:25:01 +0800 Subject: [PATCH 1/2] fix(host): cancel backup guest prelaunch --- pkg/hostman/guestman/qemu-kvm.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/hostman/guestman/qemu-kvm.go b/pkg/hostman/guestman/qemu-kvm.go index 43ae971792..6261a57795 100644 --- a/pkg/hostman/guestman/qemu-kvm.go +++ b/pkg/hostman/guestman/qemu-kvm.go @@ -2446,18 +2446,20 @@ func (s *SKVMGuestInstance) doBlockIoThrottle() { func (s *SKVMGuestInstance) onGuestPrelaunch() error { s.LiveMigrateDestPort = nil - if options.HostOptions.SetVncPassword { - s.SetVncPassword() - } - if s.isMemcleanEnabled() { - if err := s.startMemCleaner(); err != nil { - return err + if !s.Desc.IsSlave { + if options.HostOptions.SetVncPassword { + s.SetVncPassword() } + if s.isMemcleanEnabled() { + if err := s.startMemCleaner(); err != nil { + return err + } + } + s.OnResumeSyncMetadataInfo() + s.GuestPrelaunchSetCgroup() + s.optimizeOom() + s.doBlockIoThrottle() } - s.OnResumeSyncMetadataInfo() - s.GuestPrelaunchSetCgroup() - s.optimizeOom() - s.doBlockIoThrottle() return nil } From 9d7a49ebdf9d4bd1c01080291e508671c142073b Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Thu, 21 Sep 2023 11:03:38 +0800 Subject: [PATCH 2/2] fix(host): avoid panic on host record not init --- pkg/hostman/hostinfo/hostinfo.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index d0f1d3b893..44e14e65a9 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -1305,16 +1305,16 @@ func (h *SHostInfo) ensureHostRecord(zoneId string) (*api.HostDetails, error) { h.Domain_id = hosts[0].DomainId h.HostId = hosts[0].Id h.Project_domain = strings.ReplaceAll(hosts[0].ProjectDomain, " ", "+") - } - // 上次未能正常offline, 补充一次健康日志 - if hosts[0].HostStatus == api.HOST_ONLINE { - reason := fmt.Sprintf("The host status is online when it staring. Maybe the control center was down earlier") - logclient.AddSimpleActionLog(h, logclient.ACT_HEALTH_CHECK, map[string]string{"reason": reason}, hostutils.GetComputeSession(context.Background()).GetToken(), false) - data := jsonutils.NewDict() - data.Add(jsonutils.NewString(h.GetName()), "name") - data.Add(jsonutils.NewString(reason), "message") - notifyclient.SystemExceptionNotify(context.TODO(), napi.ActionSystemException, napi.TOPIC_RESOURCE_HOST, data) + // 上次未能正常offline, 补充一次健康日志 + if hosts[0].HostStatus == api.HOST_ONLINE { + reason := fmt.Sprintf("The host status is online when it staring. Maybe the control center was down earlier") + logclient.AddSimpleActionLog(h, logclient.ACT_HEALTH_CHECK, map[string]string{"reason": reason}, hostutils.GetComputeSession(context.Background()).GetToken(), false) + data := jsonutils.NewDict() + data.Add(jsonutils.NewString(h.GetName()), "name") + data.Add(jsonutils.NewString(reason), "message") + notifyclient.SystemExceptionNotify(context.TODO(), napi.ActionSystemException, napi.TOPIC_RESOURCE_HOST, data) + } } return h.updateOrCreateHost(h.HostId)