From 83c1073f688e908a442ad063e632c0a4ebcdc4eb Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Sat, 21 Nov 2020 17:05:38 +0800 Subject: [PATCH] fix(host): wait put host offline success Unregister host wait for host offline success, in case region is in upgrading. cherrypick: release/3.4 --- pkg/hostman/hostinfo/hostinfo.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index df72242e1a..9b57210c19 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -1608,12 +1608,17 @@ func (h *SHostInfo) stop() { } func (h *SHostInfo) unregister() { - h.stopped = true - _, err := modules.Hosts.PerformAction( - h.GetSession(), h.HostId, "offline", nil) - if err != nil { - log.Errorln(err) + for { + _, err := modules.Hosts.PerformAction( + h.GetSession(), h.HostId, "offline", nil) + if err != nil { + log.Errorf("put host offline failed: %s", err) + time.Sleep(time.Second * 1) + } else { + break + } } + h.stopped = true } func (h *SHostInfo) OnCatalogChanged(catalog mcclient.KeystoneServiceCatalogV3) {